账号:创建账号前的检查

This commit is contained in:
liangtongchuan
2021-09-10 20:54:45 +08:00
parent 14f7b3dd9c
commit 635d725932
2 changed files with 5 additions and 0 deletions

View File

@@ -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: '缺少关卡信息' },

View File

@@ -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;