change - 缓存用户数据源

master
wenjy 4 months ago
parent 27726ecb29
commit 7983b99959

@ -18,6 +18,8 @@ import com.mesnac.system.api.RemoteUserService;
import com.mesnac.system.api.domain.SysUser; import com.mesnac.system.api.domain.SysUser;
import com.mesnac.system.api.model.LoginUser; import com.mesnac.system.api.model.LoginUser;
import java.util.concurrent.TimeUnit;
/** /**
* *
* *
@ -96,6 +98,10 @@ public class SysLoginService
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员"); recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "用户已停用,请联系管理员");
throw new ServiceException("对不起,您的账号:" + username + " 已停用"); throw new ServiceException("对不起,您的账号:" + username + " 已停用");
} }
redisService.setCacheObject(CacheConstants.USER_POOL_NAME_CURRENT + username, userInfo.getPoolName(),
CacheConstants.REFRESH_TIME, TimeUnit.MINUTES);
passwordService.validate(user, password); passwordService.validate(user, password);
recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功"); recordLogService.recordLogininfor(username, Constants.LOGIN_SUCCESS, "登录成功");
return userInfo; return userInfo;

@ -56,4 +56,6 @@ public class CacheConstants
* IP cache key * IP cache key
*/ */
public static final String SYS_LOGIN_BLACKIPLIST = SYS_CONFIG_KEY + "sys.login.blackIPList"; 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.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import com.mesnac.common.core.constant.CacheConstants;
import com.mesnac.common.core.text.Convert; import com.mesnac.common.core.text.Convert;
import com.mesnac.common.redis.service.RedisService; import com.mesnac.common.redis.service.RedisService;
import com.mesnac.system.domain.SysUserDatasource; import com.mesnac.system.domain.SysUserDatasource;
@ -179,7 +180,7 @@ public class SysUserController extends BaseController
// 园区集合 // 园区集合
List<Map<String, String>> poolNameList = userService.getPoolNameList(user); 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); user.setPoolName(poolName);
AjaxResult ajax = AjaxResult.success(); AjaxResult ajax = AjaxResult.success();
@ -374,6 +375,15 @@ public class SysUserController extends BaseController
return success(deptService.selectDeptTreeList(dept)); 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 * IDID
* @param sysUser * @param sysUser

Loading…
Cancel
Save