后台:属性显示

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

View File

@@ -1,5 +1,5 @@
import { UserModel } from '@db/User';
import { RoleModel } from '@db/Role';
import { CeAttrDataRole, RoleModel } from '@db/Role';
import { HeroModel } from '@db/Hero';
import { EquipModel } from '@db/Equip';
import { ActionPointModel } from '@db/ActionPoint';
@@ -503,8 +503,20 @@ export default class GMUsers extends Service {
let heroes = await HeroModel.findByField(field, value);
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 {
console.error('role list not found');
return ctx.service.utils.resResult(STATUS.INTERNAL_ERR);