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

This reverts commit 97a36fda70fc1ccbb7f310b04d149f46f997a614.
This commit is contained in:
luying
2023-05-22 19:41:04 +08:00
parent 7700ed438a
commit 024f1e2776
7 changed files with 23 additions and 23 deletions
@@ -1,5 +1,5 @@
import { MemComBtlTeam } from '../../domain/battleField/ComBattleTeamField';
import Item from '../../db/Item';
import { ItemModel } from '../../db/Item';
import { BATTLE_REWARD_TYPE, ITEM_CHANGE_REASON, IT_TYPE, PUSH_ROUTE } from '../../consts';
import { FriendRelationModel } from '../../db/FriendRelation';
import Role, { RoleType } from '../../db/Role';
@@ -505,7 +505,7 @@ export function blueprtIdValid(id: number) {
* @returns
*/
export async function hasEnoughBlueprt(roleId: string, sid: string, blueprtId: number) {
let blueprt = await Item.findbyRoleAndGidAndCount(roleId, blueprtId, 1);
let blueprt = await ItemModel.findbyRoleAndGidAndCount(roleId, blueprtId, 1);
if (!blueprt || blueprt.count <= 0) return false;
// 检查是否有已创建未结束的寻宝,预先占用一张藏宝图
// // 背包中占用的藏宝图不显示,所以这里就扣掉,结束再加回去
+2 -2
View File
@@ -31,7 +31,7 @@ import { GuildModel, GuildType } from '../db/Guild';
import UserGuild, { UserGuildType } from '../db/UserGuild';
import { getAllGuildActivityStatus } from './guildActivity/guildActivityService';
import { getAllOnlineRoles, getAllServers, incConnectorNum, redisClient } from './redisService';
import Item from '../db/Item';
import Item, { ItemModel } from '../db/Item';
import { PvpDefenseModel } from '../db/PvpDefense';
import { getDonation } from './donateService';
import { refChallengeCnt, sendLastSeasonRewardIfNotSent } from './pvpService';
@@ -123,7 +123,7 @@ export async function getModuleData(type: string, data: { role: RoleType, sessio
case 'role':
let heros = await Hero.findByRole(role.roleId, [], HERO_SELECT.ENTRY, true);
let jewels = await JewelModel.findbyRole(role.roleId, JEWEL_SELECT.ENTRY);
let items = await Item.findbyRole(role.roleId, ITEM_SELECT.ENTRY);
let items = await ItemModel.findbyRole(role.roleId, ITEM_SELECT.ENTRY);
let skins = await SkinModel.findbyRole(role.roleId, SKIN_SELECT.ENTRY);
let artifacts = await ArtifactModel.findbyRole(role.roleId, ARTIFACT_SELECT.ENTRY);
let activityItems = await ActivityItemModel.findbyRole(role.roleId, ACTIVITYITEM_SELECT.ENTRY);
@@ -1,6 +1,6 @@
import { CURRENCY_TYPE, HANDLE_REWARD_TYPE, CURRENCY_BY_TYPE } from '../../consts';
import Role, { RoleType } from '../../db/Role';
import Item, { ItemType } from '../../db/Item';
import { ItemModel, ItemType } from '../../db/Item';
import { ItemInter, RewardInter, } from '../../pubUtils/interface';
import { gameData } from '../../pubUtils/data';
import { sortItems } from './util';
@@ -81,7 +81,7 @@ export class CheckMeterial {
private async decreaseItem(id: number, count: number) {
console.log('#### decreaseItem 1', id, count);
if(!this.itemsIndb.has(id)) {
let item = await Item.findbyRoleAndGid(this.roleId, id);
let item = await ItemModel.findbyRoleAndGid(this.roleId, id);
console.log('#### decreaseItem', item);
if(!item) {
this.pushToNotEnoughItems(id, count);
@@ -2,7 +2,7 @@ import { ITID, CONSUME_TYPE, ITEM_TABLE, CURRENCY_TYPE, MAIL_TYPE, HANDLE_REWARD
import { getDecimalCnt, getRandEelm, getRandEelmWithWeight, getRandValueByMinMax, } from '../../pubUtils/util';
import Role, { RoleType } from '../../db/Role';
import { setAp } from '../actionPointService';
import Item from '../../db/Item';
import { ItemModel, } from '../../db/Item';
import { ItemInter, } from '../../pubUtils/interface';
import { gameData, getDefArtifactByGid } from '../../pubUtils/data';
import { uniq } from 'underscore';
@@ -59,7 +59,7 @@ export async function handleCost(roleId: string, sid: string, goods: Array<ItemI
}
//检查并修改道具
if (items.length > 0) {
let { hasError, result } = await Item.decreaseItems(roleId, items);
let { hasError, result } = await ItemModel.decreaseItems(roleId, items);
if (hasError) return false;
sendMessageToUserWithSuc(roleId, PUSH_ROUTE.ITEM_UPDATE, { goods: result.map(cur => ({...cur, reason })) }, sid);
saveItemChangeLog(roleId, result, reason);
@@ -340,7 +340,7 @@ export async function checkGoods(roleId: string, goodIds: Array<number>) {
}
//检查并修改道具
if (itemIds.length > 0) {
let items = await Item.findbyRoleAndIds(roleId, itemIds);
let items = await ItemModel.findbyRoleAndIds(roleId, itemIds);
if (items.length < itemIds.length)
return false;
}
@@ -460,7 +460,7 @@ export async function addBag(roleId: string, roleName: string, data: { id: numbe
let { name: itemName, itid, hid } = gameData.goods.get(id);
let { type } = ITID.get(itid);
let item = await Item.increaseItem(roleId, id, count, { roleId, roleName, itemName, id, type, hid });
let item = await ItemModel.increaseItem(roleId, id, count, { roleId, roleName, itemName, id, type, hid });
return { id: item.id, count: item.count, inc: count, reason };
}