修改util为公共地址

This commit is contained in:
luying
2020-10-16 14:54:28 +08:00
parent 73a30b6eb0
commit bd6646c6fe
21 changed files with 56 additions and 51 deletions

View File

@@ -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);