diff --git a/shared/consts/statusCode.ts b/shared/consts/statusCode.ts index 7785af7cd..81869b34d 100644 --- a/shared/consts/statusCode.ts +++ b/shared/consts/statusCode.ts @@ -29,6 +29,7 @@ export const STATUS = { TEL_LEN_ERR: { code: 10014, simStr: '手机长度错误' }, NAME_HAS_USED: { code: 10015, simStr: '该名字已使用' }, ROLE_HAS_INIT: { code: 10016, simStr: '该角色已初始过' }, + ROLE_EXIST: { code: 10017, simStr: '账号已存在' }, // 战斗相关状态 20000 - 29999 // 战斗通用 20000 - 20099 BATTLE_MISS_INFO: { code: 20001, simStr: '缺少关卡信息' }, diff --git a/web-server/app/service/Auth.ts b/web-server/app/service/Auth.ts index 16012a82e..b502a9b61 100644 --- a/web-server/app/service/Auth.ts +++ b/web-server/app/service/Auth.ts @@ -299,6 +299,10 @@ export default class Auth extends Service { console.log('enter Auth createRole'); const ctx = this.ctx; const { uid } = ctx; + const exist = await RoleModel.exists({ 'userInfo.uid': uid, serverId }); + if (exist === true) { + return ctx.service.utils.resResult(STATUS.ROLE_EXIST); + } const roleId = ctx.service.utils.genCode(10); const code = ctx.service.utils.genCode(6); const seqId = await Counter.getNewCounter(COUNTER.ROLE) || -1;