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