feat(db): 修改hero表数据库操作方式

This commit is contained in:
liangtongchuan
2023-05-06 17:07:48 +08:00
parent 3f3c1af549
commit 297e1af7ee
27 changed files with 133 additions and 137 deletions

View File

@@ -4,7 +4,7 @@ import { ItemInter, RewardInter } from "../../../pubUtils/interface";
import { resResult, parseGoodStr } from "../../../pubUtils/util";
import { addItems, getJewelRandSe, handleCost } from "../../../services/role/rewardService";
import { HeroModel, EPlace } from "../../../db/Hero";
import Hero, { EPlace } from "../../../db/Hero";
import { gameData, getEquipByJobClassAndEPlace, getNextEquipQuality, getEquipStarIdByEquipId, getNextEquipStar } from "../../../pubUtils/data";
import { BAG, EQUIP } from "../../../pubUtils/dicParam";
import { getRandSeResult, updateEplace, updateEplaces, checkJewelCanPutOnEquip, updateStone, checkStoneCanPutOnEquip, isLocked } from "../../../services/equipService";
@@ -36,7 +36,7 @@ export class EquipHandler {
let { hid, ePlaceId } = msg;
if(!isNumber(ePlaceId) || ePlaceId > 4 || ePlaceId < 1) return resResult(STATUS.WRONG_PARMS);
let hero = await HeroModel.findByHidAndRole(hid, roleId);
let hero = await Hero.findByHidAndRole(hid, roleId);
if(!hero) return resResult(STATUS.HERO_NOT_FIND);
let oldEplace = hero.ePlace||[];
@@ -77,7 +77,7 @@ export class EquipHandler {
let { hid, ePlaceId, isOneClick } = msg;
let hero = await HeroModel.findByHidAndRole(hid, roleId);
let hero = await Hero.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
let oldEplace = hero.ePlace||[];
let curEquip = oldEplace.find(cur => cur.id == ePlaceId);
@@ -123,7 +123,7 @@ export class EquipHandler {
let sid: string = session.get('sid');
let { hid, lv } = msg; // lv: 升到哪一级
let hero = await HeroModel.findByHidAndRole(hid, roleId);
let hero = await Hero.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
let { ePlace, lv: playerLv } = hero; // 装备栏
@@ -176,7 +176,7 @@ export class EquipHandler {
let sid: string = session.get('sid');
let { hid, ePlaceId, isOneClick } = msg;
let hero = await HeroModel.findByHidAndRole(hid, roleId);
let hero = await Hero.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
let oldEplace = hero.ePlace||[];
@@ -247,7 +247,7 @@ export class EquipHandler {
let sid: string = session.get('sid');
let { hid, ePlaceId, isOneClick } = msg;
let hero = await HeroModel.findByHidAndRole(hid, roleId);
let hero = await Hero.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
let oldEplace = hero.ePlace||[];
@@ -329,7 +329,7 @@ export class EquipHandler {
let sid: string = session.get('sid');
let serverId: number = session.get('serverId');
let hero = await HeroModel.findByHidAndRole(hid, roleId);
let hero = await Hero.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
let oldEplace = hero.ePlace||[];
@@ -346,7 +346,7 @@ export class EquipHandler {
let originJewel = curEquip.jewel? await JewelModel.findbySeqId(curEquip.jewel): null; // 原本自己的天晶石
let canSentMineToOrigin = false; // 自己的能不能塞到对方身上
if(jewel.hid != 0) { // 如果天晶石原本镶嵌在其他武将身上,把自己的给他
let originHero = await HeroModel.findByHidAndRole(jewel.hid, roleId);
let originHero = await Hero.findByHidAndRole(jewel.hid, roleId);
let originEplace = originHero?.ePlace||[];
let originEquip = originEplace.find(cur => cur.jewel == seqId);
if(originEquip) {
@@ -384,7 +384,7 @@ export class EquipHandler {
let sid: string = session.get('sid');
let serverId: number = session.get('serverId');
let hero = await HeroModel.findByHidAndRole(hid, roleId);
let hero = await Hero.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
let oldEplace = hero.ePlace||[];
@@ -413,7 +413,7 @@ export class EquipHandler {
let sid: string = session.get('sid');
let serverId: number = session.get('serverId');
let hero = await HeroModel.findByHidAndRole(hid, roleId);
let hero = await Hero.findByHidAndRole(hid, roleId);
if (!hero) return resResult(STATUS.HERO_NOT_FIND);
let oldEplace = hero.ePlace||[];
@@ -566,7 +566,7 @@ export class EquipHandler {
let newJewel = await JewelModel.updateInfo(seqId, { previewRandSe: [], randSe: previewRandSe });
// 更新战力
if(hid > 0) {
const hero = await HeroModel.findByHidAndRole(hid, roleId);
const hero = await Hero.findByHidAndRole(hid, roleId);
await calculateCeWithHero(HERO_SYSTEM_TYPE.JEWEL_RESET_RANDSE, roleId, serverId, sid, hid, { ePlace: hero.ePlace }, { ePlaceId, jewel: newJewel, skinId: hero.skinId });
}
@@ -648,7 +648,7 @@ export class EquipHandler {
let newJewel = await JewelModel.quench(seqId, isSuccess, newRandSe.rand);
// 更新战力
if(isSuccess && hid > 0) {
const hero = await HeroModel.findByHidAndRole(hid, roleId);
const hero = await Hero.findByHidAndRole(hid, roleId);
await calculateCeWithHero(HERO_SYSTEM_TYPE.JEWEL_QUENCH, roleId, serverId, sid, hid, { ePlace: hero.ePlace }, { ePlaceId, jewel: newJewel, skinId: hero.skinId });
}
@@ -769,7 +769,7 @@ export class EquipHandler {
let newJewel = await JewelModel.updateInfo(targetJewel.seqId, { previewRandSe: [], randSe: newRandSe });
// 更新战力
if(targetJewel.hid > 0) {
const hero = await HeroModel.findByHidAndRole(targetJewel.hid, roleId);
const hero = await Hero.findByHidAndRole(targetJewel.hid, roleId);
await calculateCeWithHero(HERO_SYSTEM_TYPE.JEWEL_RESET_RANDSE, roleId, serverId, sid, targetJewel.hid, { ePlace: hero.ePlace }, { ePlaceId: targetJewel.ePlaceId, jewel: newJewel, skinId: hero.skinId });
}