军团:限制重名
This commit is contained in:
@@ -121,9 +121,16 @@ export class GuildHandler {
|
||||
|
||||
const roleId = session.get('roleId');
|
||||
const roleName = session.get('roleName');
|
||||
const serverId = session.get('serverId');
|
||||
const { code, name, notice, introduce, ceLimit, isAuto, icon } = msg;
|
||||
if (!code) return resResult(STATUS.WRONG_PARMS);
|
||||
|
||||
// 检查名字是否重
|
||||
if(name != undefined) {
|
||||
const checkNameResult = await GuildModel.checkName(name, serverId);
|
||||
if (checkNameResult) return resResult(STATUS.GUILD_NAME_DUP);
|
||||
}
|
||||
|
||||
const select = ['code', 'name', 'notice', 'introduce', 'ceLimit', 'isAuto', 'icon'];
|
||||
let updateInfo: GuildUpdateParam = {};
|
||||
if(name != undefined) updateInfo.name = name;
|
||||
|
||||
@@ -116,8 +116,8 @@ export default class Guild extends BaseModel {
|
||||
}
|
||||
|
||||
public static async checkName(name: string, serverId: number) {
|
||||
const result: GuildType = await GuildModel.findOne({ name, status: GUILD_STATUS.RUNNING, serverId }).lean();
|
||||
return !!result;
|
||||
const result = await GuildModel.exists({ name, status: GUILD_STATUS.RUNNING, serverId });
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async findByCondition(page: number, showPeopleMax: boolean, name: string, serverId: number) {
|
||||
|
||||
Reference in New Issue
Block a user