change - 缓存用户数据源

master
wenjy 4 months ago
parent 27726ecb29
commit 7983b99959

@ -18,9 +18,11 @@ import com.mesnac.system.api.RemoteUserService;
import com.mesnac.system.api.domain.SysUser;
import com.mesnac.system.api.model.LoginUser;
import java.util.concurrent.TimeUnit;
/**
*
*
*
* @author ruoyi
*/
@Component
@ -83,7 +85,7 @@ public class SysLoginService
{
throw new ServiceException(userResult.getMsg());
}
LoginUser userInfo = userResult.getData();
SysUser user = userResult.getData().getSysUser();
if (UserStatus.DELETED.getCode().equals(user.getDelFlag()))
@ -96,6 +98,10 @@ public class SysLoginService
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
throw new ServiceException("对不起,您的账号:" + username + " 已停用");
}
redisService.setCacheObject(CacheConstants.USER_POOL_NAME_CURRENT + username, userInfo.getPoolName(),
CacheConstants.REFRESH_TIME, TimeUnit.MINUTES);
passwordService.validate(user, password);
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
return userInfo;

@ -2,7 +2,7 @@ package com.mesnac.common.core.constant;
/**
*
*
*
* @author ruoyi
*/
public class CacheConstants
@ -56,4 +56,6 @@ public class CacheConstants
* IP cache key
*/
public static final String SYS_LOGIN_BLACKIPLIST = SYS_CONFIG_KEY + "sys.login.blackIPList";
public static final String USER_POOL_NAME_CURRENT = "user_pool_name_current:";
}

@ -4,9 +4,10 @@ import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse;
import com.mesnac.common.core.constant.CacheConstants;
import com.mesnac.common.core.text.Convert;
import com.mesnac.common.redis.service.RedisService;
import com.mesnac.system.domain.SysUserDatasource;
@ -179,7 +180,7 @@ public class SysUserController extends BaseController
// 园区集合
List<Map<String, String>> poolNameList = userService.getPoolNameList(user);
// 缓存用户园区
String poolName = redisService.getCacheObject("user_pool_name_current:"+ user.getUserName());
String poolName = redisService.getCacheObject(CacheConstants.USER_POOL_NAME_CURRENT + user.getUserName());
user.setPoolName(poolName);
AjaxResult ajax = AjaxResult.success();
@ -374,6 +375,15 @@ public class SysUserController extends BaseController
return success(deptService.selectDeptTreeList(dept));
}
@PutMapping("/changePoolName")
public AjaxResult changePoolName(@RequestBody SysUser user) {
String username = SecurityUtils.getUsername();
// 缓存用户数据源
redisService.setCacheObject(CacheConstants.USER_POOL_NAME_CURRENT + username, user.getPoolName(),
CacheConstants.REFRESH_TIME, TimeUnit.MINUTES);
return success();
}
/**
* IDID
* @param sysUser

Loading…
Cancel
Save