后台:添加武将,装备,道具

This commit is contained in:
luying
2021-01-28 12:01:26 +08:00
parent 72a089b179
commit b880962f02
12 changed files with 428 additions and 58 deletions
+24 -1
View File
@@ -82,11 +82,34 @@ export default class Item extends BaseModel {
}
}
public static async deleteAccount(roleId: string) {
let result = await ItemModel.deleteMany({ roleId });
return result;
}
public static async deletebyRoleAndIds(roleId: string, ids: Array<number>) {
const result = await ItemModel.deleteMany({ roleId, id: { $in: ids } });
return result;
}
public static async updateCountByRoleAndIds(roleId: string, ids: Array<number>, count: number) {
const result: ItemType = await ItemModel.findOneAndUpdate({ roleId, id: { $in: ids } }, {$set: {count}}, {new: true, upsert: true}).lean();
return result;
}
public static async findByField(field: string, value?: number|string, lean = true) {
let searchObj = {};
if(field != 'all') {
if(field == 'roleName') {
searchObj['roleName'] = { $regex: new RegExp(value.toString(), 'i') }
} else {
searchObj[field] = value;
}
}
//.select('uid tel username')
const user: ItemType[] = await ItemModel.find(searchObj).lean(lean);
return user;
}
}