优化组织和用户创建逻辑,简化插入数据结构并处理可选描述字段

This commit is contained in:
2026-02-07 02:04:17 +08:00
parent 7dfa96d165
commit 0bd634faf2
9 changed files with 302 additions and 947 deletions

View File

@@ -24,7 +24,7 @@ export const checkUsernameShort = (username: string) => {
}
};
export const toChangeName = async (opts: { id: number; newName: string; admin?: boolean, ctx: any }) => {
export const toChangeName = async (opts: { id: string; newName: string; admin?: boolean, ctx: any }) => {
const { id, newName, admin = false, ctx } = opts;
if (!admin) {
checkUsernameShort(newName);
@@ -35,7 +35,7 @@ export const toChangeName = async (opts: { id: number; newName: string; admin?:
}
const oldName = user.username;
checkUsername(newName);
const findUserByUsername = await User.findOne({ where: { username: newName } });
const findUserByUsername = await User.findOne({ username: newName });
if (findUserByUsername) {
ctx.throw(400, 'Username already exists');
}