feat(db): 修改对item表的数据库操作方式

This commit is contained in:
liangtongchuan
2023-05-06 17:44:56 +08:00
parent df35bee3b5
commit 76877348ba
7 changed files with 23 additions and 23 deletions

View File

@@ -4,7 +4,7 @@ import Hero from '@db/Hero';
import { Service } from 'egg';
import { STATUS, REDIS_KEY, WAR_TYPE } from '@consts';
import { ItemModel } from '@db/Item';
import Item from '@db/Item';
import { gameData } from '@pubUtils/data';
import { smsModel } from '@db/Sms';
import { isString } from 'underscore';
@@ -139,7 +139,7 @@ export default class GMUsers extends Service {
let list = [];
for (let role of roles) {
let heroCount = await Hero.countByCondition({ roleId: role.roleId });
let itemCount = await ItemModel.count({ roleId: role.roleId }).lean();
let itemCount = await Item.countByCondition({ roleId: role.roleId });
let { roleId, roleName, serverId, lv, gold, coin, ce, blockType = 0, blockReason = '', fixedIpLocation, ip, ipLocation, totalPay } = role;
let { uid, tel } = role.userInfo;
@@ -368,7 +368,7 @@ export default class GMUsers extends Service {
}
for (let [roleId, ids] of map) {
await ItemModel.deletebyRoleAndIds(roleId, ids);
await Item.deletebyRoleAndIds(roleId, ids);
}
return ctx.service.utils.resResult(STATUS.SUCCESS);
@@ -393,7 +393,7 @@ export default class GMUsers extends Service {
// }
// for (let [roleId, ids] of map) {
// await ItemModel.updateCountByRoleAndIds(roleId, ids, count);
// await Item.updateCountByRoleAndIds(roleId, ids, count);
// }
// return ctx.service.utils.resResult(STATUS.SUCCESS);
@@ -478,8 +478,8 @@ export default class GMUsers extends Service {
public async getItemList(page: number, pageSize: number, sortField: string, sortOrder: string, form: SearchItemParam) {
const { ctx } = this;
const items = await ItemModel.findByCondition(page, pageSize, sortField, sortOrder, form);
const total = await ItemModel.countByCondition( form )
const items = await Item.findByCondition(page, pageSize, sortField, sortOrder, form);
const total = await Item.countByCondition( form )
let list = items.map(cur => {
return {...cur, env: ctx.app.config.realEnv}