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

This reverts commit e39af3649288cc5802739cfe862c818fe56e194e.
This commit is contained in:
luying
2023-05-22 19:43:21 +08:00
parent 2d45b2c66c
commit 7bc9e1fe49
79 changed files with 423 additions and 423 deletions
@@ -3,7 +3,7 @@ import { BattleRecordModel } from '../../../db/BattleRecord';
import { ExpeditionRecordModel } from '../../../db/ExpeditionRecord';
import { ExpeditionWarRecordModel } from '../../../db/ExpeditionWarRecord';
import { ExpeditionPointModel } from '../../../db/ExpeditionPoint';
import Role from '../../../db/Role';
import { RoleModel } from '../../../db/Role';
import { genCode, getWarTypeName } from '../../../pubUtils/util';
import { getPointRewardStatus, getResetRemainCnt, findOrCreateEnemies, getExpeditionStatus } from '../../../services/expeditionService';
import { DEBUG_MAGIC_WORD, EXPEDITION_WAR_RECORD_STATUS, ITEM_CHANGE_REASON, KING_EXP_RATIO_TYPE, TASK_TYPE, TA_EVENT } from '../../../consts';
@@ -68,7 +68,7 @@ export class ExpeditionBattleHandler {
roleId, roleName, heroes: [], myCe
});
await findOrCreateEnemies(roleId, myCe, expeditionCode, 1, EXPEDITION_WAR_RECORD_STATUS.WAITING);
await Role.increaseExpeditionResetCnt(roleId, needRefresh, curTime);
await RoleModel.increaseExpeditionResetCnt(roleId, needRefresh, curTime);
let expeditionWarRecord = await ExpeditionWarRecordModel.getRecordByCode(expeditionCode);
let curLv = 0;
if (expeditionWarRecord.length > 0) {
@@ -134,7 +134,7 @@ export class ExpeditionBattleHandler {
return resResult(STATUS.BATTLE_MISS_INFO);
}
let role = await Role.findByRoleId(roleId, 'lv warStar');
let role = await RoleModel.findByRoleId(roleId, 'lv warStar');
let apJson = await getAp(roleId, ip, role.lv);
let { ap } = apJson;
if (ap < warInfo.cost) {
@@ -199,7 +199,7 @@ export class ExpeditionBattleHandler {
let dicWar = gameData.war.get(battleId);
if(!dicWar) return resResult(STATUS.DIC_DATA_NOT_FOUND);
// 前置关卡是否挑战过
let role = await Role.findByRoleId(roleId, 'warStar topLineupCe vipStartTime')
let role = await RoleModel.findByRoleId(roleId, 'warStar topLineupCe vipStartTime')
let { warStar, topLineupCe, vipStartTime } = role;
let previousGk = dicWar.previousGk;
if (previousGk) {
@@ -225,7 +225,7 @@ export class ExpeditionBattleHandler {
// 更新敌人剩余状态及战斗状态
expeditionWarRecord = await ExpeditionWarRecordModel.updateEnemiesStatus(expeditionCode, expeditionId, EXPEDITION_WAR_RECORD_STATUS.SUCCESS, []);
// 更新点数
role = await Role.increaseExpeditionPoint(roleId, dicParam.EXPEDITION_CONST.EXPEDITION_CONST_POINTS);
role = await RoleModel.increaseExpeditionPoint(roleId, dicParam.EXPEDITION_CONST.EXPEDITION_CONST_POINTS);
// 关卡奖励
let warReward = new WarReward(roleId, roleName, sid, battleId, true);
@@ -234,7 +234,7 @@ export class ExpeditionBattleHandler {
let curWarStar = warStar.find(cur => cur.id == battleId);
let { newWarStars, newStar } = calculateWarStar(warStar, battleId, []);
if (!curWarStar || newStar > curWarStar.star) {
role = await Role.updateRoleInfo(roleId, { warStar: newWarStars });
role = await RoleModel.updateRoleInfo(roleId, { warStar: newWarStars });
}
// 更新下一关状态
@@ -284,7 +284,7 @@ export class ExpeditionBattleHandler {
return resResult(STATUS.BATTLE_INFO_VALIDATE_ERR);
}
let role = await Role.findByRoleId(roleId, 'lv');
let role = await RoleModel.findByRoleId(roleId, 'lv');
let apJson = await setAp(serverId, roleId, ip, role.lv, isSuccess?-1 * warInfo.cost: 0, sid, ITEM_CHANGE_REASON.EXPEDITION_BATTLE_END); // 扣除体力
if (!apJson) {
return resResult(STATUS.BATTLE_ACTION_POINT_LACK);
@@ -306,7 +306,7 @@ export class ExpeditionBattleHandler {
$set: { status: isSuccess ? 1 : 2, star }
}, true);
// 更新点数
role = await Role.increaseExpeditionPoint(roleId, isSuccess ? dicParam.EXPEDITION_CONST.EXPEDITION_CONST_POINTS : 0);
role = await RoleModel.increaseExpeditionPoint(roleId, isSuccess ? dicParam.EXPEDITION_CONST.EXPEDITION_CONST_POINTS : 0);
let { expeditionPoint = 0, warStar = [] } = role;
// 关卡奖励
@@ -325,7 +325,7 @@ export class ExpeditionBattleHandler {
reportTAEvent(roleId, TA_EVENT.GK_FIRST_PASS, { war_id: battleId, war_type: getWarTypeName(warInfo.warType), pass_time: Date.now(), pass_duration: nowSeconds() - getSeconds(createdAt), hero_list: dbHeroes });
}
if (!curWarStar || newStar > curWarStar.star) {
await Role.updateRoleInfo(roleId, { warStar: newWarStars });
await RoleModel.updateRoleInfo(roleId, { warStar: newWarStars });
}
}
await checkTaskInBattleEnd(serverId, roleId, sid, battleId, dbHeroes, star, isSuccess);
@@ -354,7 +354,7 @@ export class ExpeditionBattleHandler {
const serverId = session.get('serverId');
let role = await Role.findByRoleId(roleId);
let role = await RoleModel.findByRoleId(roleId);
let { expeditionPoint } = role;
let dicExpeditionPoint = gameData.expeditionPoint;
let curDicExpeditionPoint = dicExpeditionPoint.get(point);
@@ -386,7 +386,7 @@ export class ExpeditionBattleHandler {
}
if (hasReceivedAll) { // 全部领取了,刷新
await ExpeditionPointModel.completeStatus(roleId);
await Role.increaseExpeditionPoint(roleId, maxPoint * -1);
await RoleModel.increaseExpeditionPoint(roleId, maxPoint * -1);
}
let pointRewards = await getPointRewardStatus(roleId);
@@ -408,7 +408,7 @@ export class ExpeditionBattleHandler {
return resResult(STATUS.TOKEN_ERR);
}
let roleId = session.get('roleId');
await Role.updateRoleInfo(roleId, { expeditionResetCnt: 0 });
await RoleModel.updateRoleInfo(roleId, { expeditionResetCnt: 0 });
return resResult(STATUS.SUCCESS);
}
}