后台:属性显示

This commit is contained in:
luying
2021-08-19 19:55:28 +08:00
parent 0eb9751327
commit b4cfb6cb94
2 changed files with 15 additions and 3 deletions
+14 -2
View File
@@ -1,5 +1,5 @@
import { UserModel } from '@db/User'; import { UserModel } from '@db/User';
import { RoleModel } from '@db/Role'; import { CeAttrDataRole, RoleModel } from '@db/Role';
import { HeroModel } from '@db/Hero'; import { HeroModel } from '@db/Hero';
import { EquipModel } from '@db/Equip'; import { EquipModel } from '@db/Equip';
import { ActionPointModel } from '@db/ActionPoint'; import { ActionPointModel } from '@db/ActionPoint';
@@ -503,8 +503,20 @@ export default class GMUsers extends Service {
let heroes = await HeroModel.findByField(field, value); let heroes = await HeroModel.findByField(field, value);
if (heroes) { if (heroes) {
let roleMap = new Map<string, CeAttrDataRole[]>();
for(let { roleId } of heroes) {
if(!roleMap.has(roleId)) {
let role = await RoleModel.findByRoleId(roleId, 'attr');
roleMap.set(roleId, role.attr);
}
}
let list = heroes.map(cur => {
let cal = new AttributeCal();
cal.setByDbData(roleMap.get(cur.roleId), cur.attr);
return {...cur, calculatedAttr: cal.getReduceAttributesToArr()}
})
return ctx.service.utils.resResult(STATUS.SUCCESS, { list: heroes }); return ctx.service.utils.resResult(STATUS.SUCCESS, { list });
} else { } else {
console.error('role list not found'); console.error('role list not found');
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR); return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);
+1 -1
View File
@@ -277,7 +277,7 @@ export default class Hero extends BaseModel {
} }
} }
//.select('uid tel username') //.select('uid tel username')
const user: HeroType[] = await HeroModel.find(searchObj).lean(lean); const user: HeroType[] = await HeroModel.find(searchObj, {_id: 0}).lean(lean);
return user; return user;
} }