添加显示所有武将页面排序

This commit is contained in:
luying
2021-01-15 16:05:15 +08:00
parent a274d936d2
commit 9248286efd
2 changed files with 9 additions and 3 deletions

View File

@@ -144,8 +144,12 @@ export default class Hero extends BaseModel {
@prop({ required: true, type: EPlace, default: getInitialEplace(), _id: false })
ePlace: EPlace[]; // 武将装备引用数组
public static async findByRole(roleId: string, lean = true) {
const heros: HeroType[] = await HeroModel.find({ roleId }).lean(lean);
public static async findByRole(roleId: string, sort: { field: string, sortBy: number }[] = []) {
let sortParam = {};
for(let {field, sortBy} of sort) {
sortParam[field] = sortBy;
}
const heros: HeroType[] = await HeroModel.find({ roleId }).sort(sortParam).lean();
return heros;
}