修改util为公共地址
This commit is contained in:
@@ -2,7 +2,7 @@ import { HANG_UP_CONSTS } from './../consts/consts';
|
||||
import BaseModel from './BaseModel';
|
||||
import { index, getModelForClass, prop } from '@typegoose/typegoose';
|
||||
import User from './User';
|
||||
import { shouldRefresh } from '../util/util';
|
||||
import { shouldRefresh } from '../pubUtils/util';
|
||||
|
||||
/**
|
||||
* 角色字段接口
|
||||
@@ -155,7 +155,8 @@ export default class Role extends BaseModel {
|
||||
public static async hangUpSpdUp(roleId: string, cnt: number, curTime: Date, lean = true) {
|
||||
if (cnt < 0) return null;
|
||||
|
||||
const {lastSpdUpTime} = await RoleModel.findOneAndUpdate({roleId}, {$inc: {hangUpSpdUpCnt: -cnt}, lastSpdUpTime: curTime}, {new: true}).lean(lean);
|
||||
const result = await RoleModel.findOneAndUpdate({roleId}, {$inc: {hangUpSpdUpCnt: -cnt}, lastSpdUpTime: curTime}, {new: true}).lean(lean);
|
||||
const lastSpdUpTime = result?result.lastSpdUpTime: curTime;
|
||||
let role = null;
|
||||
if (shouldRefresh(lastSpdUpTime, curTime, HANG_UP_CONSTS.REFRESH_TIME, 1) && cnt <= HANG_UP_CONSTS.MAX_SPD_UP_CNT) {
|
||||
role = await RoleModel.findOneAndUpdate({roleId}, {hangUpSpdUpCnt: HANG_UP_CONSTS.MAX_SPD_UP_CNT - cnt, lastSpdUpTime: curTime}, {new: true}).lean(lean);
|
||||
|
||||
Reference in New Issue
Block a user