Revert "✨ feat(db): 修改role表数据库操作方式"
This reverts commit e39af3649288cc5802739cfe862c818fe56e194e.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Application, BackendSession, ChannelService, HandlerService, } from "pinus";
|
||||
import { resResult, getRandEelm, getResStr, shouldRefresh, sortArrRandom, checkRoleIsRobot, getRobotSysType, makeRobotId, parseNumberList } from "../../../pubUtils/util";
|
||||
import { STATUS, ROLE_SELECT, FRIEND_DROP_TYPE, FRIEND_RELATION_TYPE, POPULATE_TYPE, BLOCK_OPEATE, CONSUME_TYPE, ITID, HERO_SELECT, REDIS_KEY, MSG_SOURCE, MSG_TYPE, TASK_TYPE, ROBOT_SYS_TYPE, ITEM_CHANGE_REASON, PUSH_ROUTE } from "../../../consts";
|
||||
import Role, { RoleModel, RoleType } from "../../../db/Role";
|
||||
import { RoleModel, RoleType } from "../../../db/Role";
|
||||
import { getTimeFun, getZeroPointD } from "../../../pubUtils/timeUtil";
|
||||
import { FriendApplyModel } from "../../../db/FriendApply";
|
||||
import { FriendListParam, FriendRecommendParams, BlackListParam, FriendValueListParam, HeroDetailParam } from "../../../domain/roleField/friend";
|
||||
@@ -50,7 +50,7 @@ export class FriendHandler {
|
||||
|
||||
const day = <number>getTimeFun().getBeforeHour(FRIEND.FRIEND_RECONMMEND_ACTIVETIME);
|
||||
|
||||
const { lv, serverId: myServerId } = await Role.findByRoleId(roleId, ROLE_SELECT.GET_MY_SERVER);
|
||||
const { lv, serverId: myServerId } = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_MY_SERVER);
|
||||
let nums = parseNumberList(FRIEND.FRIEND_RECONMMEND_LEVEL);
|
||||
// let max = Math.max(...nums);
|
||||
let recommendList = await RoleModel.find({ loginTime: { $gt: day }, hasInit: true }).limit(200).lean({ getters: true, virtuals: true })
|
||||
@@ -117,7 +117,7 @@ export class FriendHandler {
|
||||
let roleId: string = session.get('roleId');
|
||||
|
||||
let { value } = msg;
|
||||
let allList = await Role.searchByNameOrId(value);
|
||||
let allList = await RoleModel.searchByNameOrId(value);
|
||||
let myFriendRelation = await FriendRelationModel.findFriendByRole(roleId, POPULATE_TYPE.NOT);
|
||||
|
||||
let list = new Array<FriendRecommendParams>();
|
||||
@@ -141,7 +141,7 @@ export class FriendHandler {
|
||||
let roleId: string = session.get('roleId');
|
||||
let roleIds = msg.roleIds;
|
||||
|
||||
const role = await Role.findByRoleId(roleId, ROLE_SELECT.GET_ROLE_ID);
|
||||
const role = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_ROLE_ID);
|
||||
let myFriendRelation = await FriendRelationModel.findFriendByRole(roleId, POPULATE_TYPE.NOT);
|
||||
|
||||
let str = '', resultRoleIds = new Array<string>();
|
||||
@@ -157,7 +157,7 @@ export class FriendHandler {
|
||||
let hisRelation = await FriendRelationModel.findFriendByRole(hisRoleId, POPULATE_TYPE.NOT);
|
||||
let hisType = getRecommendType(hisRelation, hisRoleId, roleId);
|
||||
if(hisType == FRIEND_RELATION_TYPE.NORMAL) {
|
||||
let incResult = await Role.increaseFriendApplyCnt(hisRoleId, 1, FRIEND.FRIEND_MANAGE_APPLICATION);
|
||||
let incResult = await RoleModel.increaseFriendApplyCnt(hisRoleId, 1, FRIEND.FRIEND_MANAGE_APPLICATION);
|
||||
if (!incResult) {
|
||||
str = getResStr(STATUS.FRIEND_HIS_APPLY_MAX); continue;
|
||||
}
|
||||
@@ -198,7 +198,7 @@ export class FriendHandler {
|
||||
|
||||
let { applyCodeList, isPass } = msg;
|
||||
|
||||
let role = await Role.findByRoleId(roleId);
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let roles = new Array<RoleType>();
|
||||
let friendCnt = role.friendCnt;
|
||||
|
||||
@@ -259,7 +259,7 @@ export class FriendHandler {
|
||||
}
|
||||
|
||||
let deleteCount = await FriendApplyModel.deleteApply(resultApplyCodeList);
|
||||
role = await Role.increaseFriendApplyCnt(roleId, -1 * deleteCount, FRIEND.FRIEND_MANAGE_APPLICATION);
|
||||
role = await RoleModel.increaseFriendApplyCnt(roleId, -1 * deleteCount, FRIEND.FRIEND_MANAGE_APPLICATION);
|
||||
roles.push(role);
|
||||
// 任务
|
||||
await checkTaskWithRoles(roleId, sid, TASK_TYPE.FRIEND_NUM, roles);
|
||||
@@ -280,7 +280,7 @@ export class FriendHandler {
|
||||
public async getFriendList(msg: {}, session: BackendSession) {
|
||||
let roleId: string = session.get('roleId');
|
||||
|
||||
let role = await Role.findByRoleId(roleId);
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let res = await getFriendList(role);
|
||||
|
||||
return resResult(STATUS.SUCCESS, res);
|
||||
@@ -290,7 +290,7 @@ export class FriendHandler {
|
||||
public async getBlackList(msg: {}, session: BackendSession) {
|
||||
let roleId: string = session.get('roleId');
|
||||
|
||||
let role = await Role.findByRoleId(roleId);
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let list = new Array<BlackListParam>();
|
||||
let myRelation = await FriendRelationModel.findFriendByRole(roleId, POPULATE_TYPE.BLACKLIST);
|
||||
let blacklist = myRelation ? myRelation.blacklist : [];
|
||||
@@ -328,7 +328,7 @@ export class FriendHandler {
|
||||
const serverId = session.get('serverId');
|
||||
let { roleId: hisRoleId, type } = msg;
|
||||
|
||||
let role = await Role.findByRoleId(roleId);
|
||||
let role = await RoleModel.findByRoleId(roleId);
|
||||
let friend: RoleType;
|
||||
|
||||
let str = '', list = new Array<BlackListParam>(), frdRoleIds = new Array<string>(), blackRoleIds = new Array<string>();
|
||||
@@ -342,11 +342,11 @@ export class FriendHandler {
|
||||
return resResult(STATUS.FRIEND_BLACK_HAS_ADD);
|
||||
}
|
||||
|
||||
role = await Role.increaseBlockCnt(roleId, 1, curFriend ? -1 : 0, FRIEND.FRIEND_BLACKLIST_MAX); // 增加黑名单人数
|
||||
role = await RoleModel.increaseBlockCnt(roleId, 1, curFriend ? -1 : 0, FRIEND.FRIEND_BLACKLIST_MAX); // 增加黑名单人数
|
||||
if (!role) {
|
||||
return resResult(STATUS.FRIEND_BLACK_MAX)
|
||||
}
|
||||
friend = await Role.increaseFriendCnt(hisRoleId, curFriend ? -1 : 0); // 对方好友减少
|
||||
friend = await RoleModel.increaseFriendCnt(hisRoleId, curFriend ? -1 : 0); // 对方好友减少
|
||||
|
||||
let friendShip: FriendShipType;
|
||||
if (!!curFriend) {
|
||||
@@ -360,8 +360,8 @@ export class FriendHandler {
|
||||
await delPrivateMsg(roleId, hisRoleId);
|
||||
|
||||
let { myRecApplyCount, hisRecApplyCount } = await FriendApplyModel.deleteApplyByRoles(roleId, hisRoleId); // 删除双方的申请
|
||||
if(myRecApplyCount > 0) await Role.increaseFriendApplyCnt(roleId, -1 * myRecApplyCount, FRIEND.FRIEND_MANAGE_APPLICATION);
|
||||
if(hisRecApplyCount > 0) await Role.increaseFriendApplyCnt(roleId, -1 * hisRecApplyCount, FRIEND.FRIEND_MANAGE_APPLICATION);
|
||||
if(myRecApplyCount > 0) await RoleModel.increaseFriendApplyCnt(roleId, -1 * myRecApplyCount, FRIEND.FRIEND_MANAGE_APPLICATION);
|
||||
if(hisRecApplyCount > 0) await RoleModel.increaseFriendApplyCnt(roleId, -1 * hisRecApplyCount, FRIEND.FRIEND_MANAGE_APPLICATION);
|
||||
|
||||
let param = new BlackListParam(friend);
|
||||
let { isOnline, sid } = await getRoleOnlineInfo(friend.roleId);
|
||||
@@ -389,11 +389,11 @@ export class FriendHandler {
|
||||
return resResult(STATUS.FRIEND_NOT_FOUND);
|
||||
}
|
||||
|
||||
role = await Role.increaseFriendCnt(roleId, -1); // 减少好友
|
||||
role = await RoleModel.increaseFriendCnt(roleId, -1); // 减少好友
|
||||
if (!role) {
|
||||
return resResult(STATUS.FRIEND_NOT_FOUND)
|
||||
}
|
||||
friend = await Role.increaseFriendCnt(hisRoleId, -1); // 对方好友减少
|
||||
friend = await RoleModel.increaseFriendCnt(hisRoleId, -1); // 对方好友减少
|
||||
|
||||
let friendShip: FriendShipType;
|
||||
|
||||
@@ -414,7 +414,7 @@ export class FriendHandler {
|
||||
return resResult(STATUS.FRIEND_BLACK_NOT_FOUND);
|
||||
}
|
||||
|
||||
role = await Role.increaseBlockCnt(roleId, -1, 0, 100); // 黑名单人数减
|
||||
role = await RoleModel.increaseBlockCnt(roleId, -1, 0, 100); // 黑名单人数减
|
||||
if (!role) {
|
||||
return resResult(STATUS.FRIEND_BLACK_MAX)
|
||||
}
|
||||
@@ -422,14 +422,14 @@ export class FriendHandler {
|
||||
|
||||
if (type == BLOCK_OPEATE.REMOVE_AND_APPLY) {
|
||||
// 申请好友
|
||||
friend = await Role.increaseFriendApplyCnt(hisRoleId, 1, FRIEND.FRIEND_MANAGE_APPLICATION);
|
||||
friend = await RoleModel.increaseFriendApplyCnt(hisRoleId, 1, FRIEND.FRIEND_MANAGE_APPLICATION);
|
||||
if (!friend) {
|
||||
str = getResStr(STATUS.FRIEND_HIS_APPLY_MAX);
|
||||
} else {
|
||||
let hisRelation = await FriendRelationModel.findFriendByRole(hisRoleId, POPULATE_TYPE.NOT);
|
||||
let hisType = getRecommendType(hisRelation, hisRoleId, roleId);
|
||||
if(hisType == FRIEND_RELATION_TYPE.NORMAL) {
|
||||
let incResult = await Role.increaseFriendApplyCnt(hisRoleId, 1, FRIEND.FRIEND_MANAGE_APPLICATION);
|
||||
let incResult = await RoleModel.increaseFriendApplyCnt(hisRoleId, 1, FRIEND.FRIEND_MANAGE_APPLICATION);
|
||||
if (incResult) {
|
||||
let apply = await FriendApplyModel.createApply(hisRoleId, role);
|
||||
let hisOnlineInfo = await getRoleOnlineInfo(hisRoleId);
|
||||
@@ -483,7 +483,7 @@ export class FriendHandler {
|
||||
}
|
||||
let canSendList = await sortByBeSentHeart(roleId, arr);
|
||||
|
||||
let { lv } = await Role.findByRoleId(roleId, ROLE_SELECT.GET_LV);
|
||||
let { lv } = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_LV);
|
||||
let dicFriendLv = getDicFriendByLv(lv);
|
||||
if (!dicFriendLv) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
@@ -553,7 +553,7 @@ export class FriendHandler {
|
||||
}
|
||||
let canReceiveList = await sortByBeSentHeart(roleId, arr);
|
||||
|
||||
let { lv } = await Role.findByRoleId(roleId, ROLE_SELECT.GET_LV);
|
||||
let { lv } = await RoleModel.findByRoleId(roleId, ROLE_SELECT.GET_LV);
|
||||
let dicFriendLv = getDicFriendByLv(lv);
|
||||
if (!dicFriendLv) return resResult(STATUS.DIC_DATA_NOT_FOUND);
|
||||
|
||||
@@ -649,7 +649,7 @@ export class FriendHandler {
|
||||
let { roleId: targetRoleId } = msg;
|
||||
let isRobot = checkRoleIsRobot(targetRoleId);
|
||||
if(isRobot) {
|
||||
let role = await Role.findByRoleId(roleId, null, true);
|
||||
let role = await RoleModel.findByRoleId(roleId, null, true);
|
||||
let sysType = getRobotSysType(targetRoleId);
|
||||
let addObj: any = { roleId: makeRobotId(''), roleName: '', guildName: '' };
|
||||
if(sysType == ROBOT_SYS_TYPE.COM_BTL) {
|
||||
@@ -667,7 +667,7 @@ export class FriendHandler {
|
||||
return resResult(STATUS.SUCCESS, {...param, isRobot });
|
||||
} else {
|
||||
|
||||
let role = await Role.findByRoleId(targetRoleId, null, true);
|
||||
let role = await RoleModel.findByRoleId(targetRoleId, null, true);
|
||||
let myFriendRelation = await FriendRelationModel.findFriendByRole(roleId, POPULATE_TYPE.NOT);
|
||||
|
||||
let type = getRecommendType(myFriendRelation, roleId, role.roleId);
|
||||
@@ -690,7 +690,7 @@ export class FriendHandler {
|
||||
let result: PlayerDetail;
|
||||
|
||||
let dbHeroes = await HeroModel.findAndSortByCe(oppoRoleId);
|
||||
let role = await Role.findByRoleId(oppoRoleId, null, true);
|
||||
let role = await RoleModel.findByRoleId(oppoRoleId, null, true);
|
||||
if(!role) return resResult(STATUS.ROLE_NOT_FOUND);
|
||||
|
||||
let { topLineupCe, towerLv, showLineup } = role;
|
||||
@@ -732,7 +732,7 @@ export class FriendHandler {
|
||||
|
||||
let { roleId: hisRoleId, hids } = msg;
|
||||
|
||||
let role = await Role.findByRoleId(hisRoleId, 'title');
|
||||
let role = await RoleModel.findByRoleId(hisRoleId, 'title');
|
||||
if (!role) return resResult(STATUS.ROLE_NOT_FOUND);
|
||||
|
||||
let roleCe = await RoleCeModel.findByRoleId(hisRoleId);
|
||||
|
||||
Reference in New Issue
Block a user