|
@@ -3,6 +3,9 @@ package com.gis.admin.service.impl;
|
|
|
import cn.hutool.core.util.RandomUtil;
|
|
|
import com.gis.admin.entity.dto.ResetPasswordDto;
|
|
|
import com.gis.admin.entity.po.SysRoleEntity;
|
|
|
+import com.gis.admin.entity.vo.RankVo;
|
|
|
+import com.gis.admin.mapper.SysBaseMapper;
|
|
|
+import com.gis.admin.service.IntegralService;
|
|
|
import com.gis.common.base.entity.dto.UserPageDateDto;
|
|
|
import com.gis.common.base.entity.po.LogEntity;
|
|
|
import com.gis.common.base.exception.BaseRuntimeException;
|
|
@@ -10,6 +13,7 @@ import com.gis.common.base.mapper.IBaseMapper;
|
|
|
import com.gis.common.base.service.LogService;
|
|
|
import com.gis.common.base.service.impl.IBaseServiceImpl;
|
|
|
import com.gis.common.constant.MsgCode;
|
|
|
+import com.gis.common.constant.TypeCode;
|
|
|
import com.gis.common.util.Base64Converter;
|
|
|
import com.gis.common.util.JwtUtil;
|
|
|
import com.gis.common.util.PasswordUtils;
|
|
@@ -49,9 +53,18 @@ public class SysUserServiceImpl extends IBaseServiceImpl<SysUserEntity, Long> im
|
|
|
@Autowired
|
|
|
LogService logService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ IntegralService integralService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ SysBaseMapper sysBaseMapper;
|
|
|
+
|
|
|
/**重置密码redis key*/
|
|
|
final static String RESET_PASSWORD_KEY = "reset_password_";
|
|
|
|
|
|
+ // 目前是12h
|
|
|
+ private static Integer LEVEL_EXPIRE = 1000 * 60 * 60 * 12;
|
|
|
+
|
|
|
@Override
|
|
|
public IBaseMapper<SysUserEntity, Long> getBaseMapper() {
|
|
|
return this.entityMapper;
|
|
@@ -320,5 +333,28 @@ public class SysUserServiceImpl extends IBaseServiceImpl<SysUserEntity, Long> im
|
|
|
entityMapper.updateOnlineTime(userId, onlineTime);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void updateLevel() {
|
|
|
+ Long userId = getTokenUserId();
|
|
|
+ // 每天只检查一次
|
|
|
+ String redisKey = TypeCode.REDIS_LEVEL_KEY + userId;
|
|
|
+ String levelKey = (String)redisUtil.get(redisKey);
|
|
|
+ if (levelKey != null){
|
|
|
+ log.info("今天已更新过用户等级,不需要再更新");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Integer grade = integralService.totalGrade();
|
|
|
+ List<RankVo> rankList = sysBaseMapper.getRankList();
|
|
|
+ for (RankVo rankVo : rankList) {
|
|
|
+ if (grade >= rankVo.getExp()){
|
|
|
+ // 有效期12小时
|
|
|
+ redisUtil.set(redisKey, grade+"", LEVEL_EXPIRE);
|
|
|
+ entityMapper.updateLevel(userId, rankVo.getLevel());
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|