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

This commit is contained in:
liangtongchuan
2023-05-06 15:48:16 +08:00
parent 2ff9f8c5f1
commit e65efa4192
79 changed files with 423 additions and 423 deletions

View File

@@ -4,10 +4,10 @@ import { difference, pick } from 'underscore';
* @Author: 梁桐川
* @Date: 2020-11-30 15:05:48
* @Last Modified by: 梁桐川
* @Last Modified time: 2021-08-27 17:47:56
* @Last Modified time: 2023-05-06 15:26:55
*/
import { IT_TYPE, CURRENCY_BY_TYPE, CURRENCY_TYPE, COM_TEAM_STATUS, COM_BTL_CONST, CONSUME_TYPE, MSG_SOURCE, ROLE_SELECT, TASK_TYPE, KING_EXP_RATIO_TYPE, ITEM_CHANGE_REASON, getChannelType, CHANNEL_PREFIX, DEBUG_MAGIC_WORD, PUSH_ROUTE, POPULATE_TYPE } from '../../../consts';
import Role, { RoleModel } from '../../../db/Role';
import Role from '../../../db/Role';
import { STATUS } from '../../../consts/statusCode';
import { Application, BackendSession } from 'pinus';
import { resResult, getRandSingleEelm, cal } from '../../../pubUtils/util';
@@ -58,7 +58,7 @@ export class ComBattleHandler {
const enoughBlueprt = await hasEnoughBlueprt(roleId, sid, blueprtId);
if (!enoughBlueprt) return resResult(STATUS.COM_BATTLE_BLUEPRT_NOT_ENOUGH);
const roleInfo = await RoleModel.findByRoleId(roleId, null, true);
const roleInfo = await Role.findByRoleId(roleId, null, true);
const { lv, topLineupCe } = roleInfo;
if (lv < COM_BTL_CONST.ENABLE_LV) return resResult(STATUS.COM_BATTLE_LV_NOT_ENOUGH);
if(ceLimit && ceLimit > topLineupCe * (1 + COM_BTL_CONST.ROBOT_CE_RATIO)) {
@@ -101,7 +101,7 @@ export class ComBattleHandler {
let roleId = session.get('roleId');
let sid = session.get('sid');
const { lv: lvs = [], magicWord } = msg;
const roleInfo = await RoleModel.findByRoleId(roleId, null, true);
const roleInfo = await Role.findByRoleId(roleId, null, true);
const { lv: playerLv } = roleInfo;
let { topLineupCe = 1000 } = roleInfo;
@@ -710,7 +710,7 @@ export class ComBattleHandler {
let teamStatus = getComTeamByCode(teamCode);
if(!teamStatus) return resResult(STATUS.WRONG_PARMS);
let role = await RoleModel.findByRoleId(targetRoleId, 'lv');
let role = await Role.findByRoleId(targetRoleId, 'lv');
if(comBtlLvInvalid(role.lv, [teamStatus.lv])) {
return resResult(STATUS.COM_BATTLE_INVITE_LV_NOT_ENOUGH);
}
@@ -747,7 +747,7 @@ export class ComBattleHandler {
if(r != roleId) roleIdList.push(r);
}
}
const roles = await RoleModel.findByRoleIds(roleIdList, ROLE_SELECT.SHOW_SIMPLE, true);
const roles = await Role.findByRoleIds(roleIdList, ROLE_SELECT.SHOW_SIMPLE, true);
let result = new Array<FriendParams>();
for(let role of roles) {
if(role.quitTime == role.loginTime) {
@@ -762,14 +762,14 @@ export class ComBattleHandler {
async getTeamInvitation(msg: { }, session: BackendSession) {
let roleId = session.get('roleId');
let guildCode = session.get('guildCode');
let role = await RoleModel.findByRoleId(roleId, 'lv topLineupCe');
let role = await Role.findByRoleId(roleId, 'lv topLineupCe');
const assistCnt = await getAllAssistCnt(roleId);
let { minLv, maxLv } = getComBtlLvByPlayerLv(role.lv);
let refreshTime = nowSeconds() - INFO_WINDOW.TEAM_INFORMATION_TIME;
const invitations = await ComBattleTeamModel.findInvitations(roleId, guildCode, minLv, maxLv, role.topLineupCe, refreshTime, INFO_WINDOW.TEAM_VIEW);
let roleIds = invitations.map(cur => cur.capId);
let roles = await RoleModel.findByRoleIds(roleIds);
let roles = await Role.findByRoleIds(roleIds);
let myFriendRelation = await FriendRelationModel.findFriendByRole(roleId, POPULATE_TYPE.NOT);
const teams: ComBattleInvitation[] = [];
for(let invitation of invitations) {
@@ -803,7 +803,7 @@ export class ComBattleHandler {
if (magicWord !== DEBUG_MAGIC_WORD) {
return resResult(STATUS.TOKEN_ERR);
}
let role = await RoleModel.updateRoleInfo(roleId, { lv: targetLv });
let role = await Role.updateRoleInfo(roleId, { lv: targetLv });
return resResult(STATUS.SUCCESS, { lv: role.lv, roleId });
}