好友:拉黑

This commit is contained in:
luying
2021-02-03 11:49:46 +08:00
parent 585a741be5
commit 2d2c9907ab
7 changed files with 194 additions and 14 deletions
+13 -2
View File
@@ -353,6 +353,7 @@ export default class Role extends BaseModel {
const role: RoleType = await RoleModel.findOneAndUpdate({roleId}, {$inc: {towerTaskCnt: num}}, {new: true}).lean(lean);
return role;
}
// 派遣任务增加刷新次数
public static async increaseTowerRefCnt(roleId: string, num: number, lean = true) {
const role: RoleType = await RoleModel.findOneAndUpdate({roleId}, {$inc: {towerTaskReCnt: num}}, {new: true}).lean(lean);
@@ -482,8 +483,12 @@ export default class Role extends BaseModel {
}
// 增加好友数量
public static async increaseFriendCnt(roleId: string, inc: number, max: number) {
const result = await RoleModel.findOneAndUpdate({ roleId, friendCnt: {$lte: max - inc}}, {$inc: { friendCnt: inc }}, {new: true}).lean();
public static async increaseFriendCnt(roleId: string, inc: number, max?: number) {
let condition = { roleId };
if(max) {
condition['friendCnt'] = {$lte: max - inc};
}
const result = await RoleModel.findOneAndUpdate(condition, {$inc: { friendCnt: inc }}, {new: true}).lean();
return result;
}
@@ -492,6 +497,12 @@ export default class Role extends BaseModel {
const result = await RoleModel.findOneAndUpdate({ roleId, recFrdApplyCnt: {$lte: max - inc}}, {$inc: { recFrdApplyCnt: inc }}, {new: true}).lean();
return result;
}
// 增加黑名单数量
public static async increaseBlockCnt(roleId: string, blockCnt: number, friendCnt: number, maxBlockCnt: number) {
const result = await RoleModel.findOneAndUpdate({ roleId, blockCnt: {$lte: maxBlockCnt - blockCnt}}, {$inc: { blockCnt, friendCnt }}, {new: true}).lean();
return result;
}
}
export const RoleModel = getModelForClass(Role);