fix,修复后台批量添加武将bug
This commit is contained in:
@@ -186,22 +186,16 @@ export default class GMUsers extends Service {
|
||||
if(isNaN(hid)) return ctx.service.utils.resResult(STATUS.WRONG_PARMS);
|
||||
}
|
||||
|
||||
let flag = 0, msg = '创建失败',heroInfos = new Array();
|
||||
let heroInfos = new Array();
|
||||
for(let roleId of uids) {
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
if(role) {
|
||||
for(let hid of hids) {
|
||||
let hero = await HeroModel.findByHidAndRole(hid, roleId);
|
||||
if(hero) {
|
||||
flag = 1, msg = "角色" + roleId + "已拥有武将" + hid;
|
||||
break;
|
||||
}
|
||||
if(hero) continue;
|
||||
const seqId = await CounterModel.getNewCounter('hid')||-1;
|
||||
let dicHero = ctx.service.utils.getHeroById(hid);
|
||||
if(!dicHero) {
|
||||
flag = 1, msg = "未找到武将" + hid;
|
||||
break;
|
||||
}
|
||||
if(!dicHero) continue;
|
||||
let ce = ctx.service.utils.calculateCE({hid: hid, lv: hlv});
|
||||
|
||||
const heroInfo = {
|
||||
@@ -216,17 +210,18 @@ export default class GMUsers extends Service {
|
||||
heroInfos.push(heroInfo);
|
||||
}
|
||||
} else {
|
||||
flag = 1, msg = '未找到角色' + roleId;
|
||||
return ctx.service.utils.resResult(STATUS.GM_CREATE_ERROR, null, '未找到角色' + roleId)
|
||||
}
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
return ctx.service.utils.resResult(STATUS.GM_CREATE_ERROR, null, msg);
|
||||
} else {
|
||||
try {
|
||||
console.log
|
||||
for(let heroInfo of heroInfos) {
|
||||
await HeroModel.createHero(heroInfo);
|
||||
}
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS, { uids });
|
||||
} catch(e) {
|
||||
console.error(e.stack)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user