Spring Boot升级到V3.1.5、redisson升级到V3.23.5

This commit is contained in:
dataprince 2023-10-21 11:57:32 +08:00
parent a81387422f
commit f6d699ce2e
7 changed files with 29 additions and 29 deletions

View File

@ -17,7 +17,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>17</java.version>
<spring-boot.version>3.1.4</spring-boot.version>
<spring-boot.version>3.1.5</spring-boot.version>
<mybatis-flex.version>1.7.2</mybatis-flex.version>
<satoken.version>1.37.0</satoken.version>
<mysql.version>8.0.33</mysql.version>
@ -45,7 +45,7 @@
<mapstruct-plus.version>1.3.5</mapstruct-plus.version>
<mapstruct-plus.lombok.version>0.2.0</mapstruct-plus.lombok.version>
<hutool.version>5.8.22</hutool.version>
<redisson.version>3.23.3</redisson.version>
<redisson.version>3.23.5</redisson.version>
<lock4j.version>2.2.4</lock4j.version>
<alibaba-ttl.version>2.14.3</alibaba-ttl.version>
<spring-boot-admin.version>3.1.6</spring-boot-admin.version>

View File

@ -40,7 +40,6 @@ public class LoginBody
/**
* 租户ID
*/
//@NotBlank(message = "{tenant.number.not.blank}")
private Long tenantId;
/**

View File

@ -26,6 +26,7 @@ public class RedisUtils {
private static final RedissonClient CLIENT = SpringUtils.getBean(RedissonClient.class);
/**
* 限流
*

View File

@ -34,6 +34,7 @@ public class LoginHelper {
public static final String LOGIN_USER_KEY = "loginUser";
public static final String TENANT_KEY = "tenantId";
public static final String USER_KEY = "userId";
public static final String DEPT_KEY = "deptId";
public static final String CLIENT_KEY = "clientid";
/**
@ -48,11 +49,13 @@ public class LoginHelper {
storage.set(LOGIN_USER_KEY, loginUser);
storage.set(TENANT_KEY, loginUser.getTenantId());
storage.set(USER_KEY, loginUser.getUserId());
storage.set(DEPT_KEY, loginUser.getDeptId());
model = ObjectUtil.defaultIfNull(model, new SaLoginModel());
//登录生成token
StpUtil.login(loginUser.getLoginId(),
model.setExtra(TENANT_KEY, loginUser.getTenantId())
.setExtra(USER_KEY, loginUser.getUserId()));
.setExtra(USER_KEY, loginUser.getUserId())
.setExtra(DEPT_KEY, loginUser.getDeptId()));
StpUtil.getSession().set(LOGIN_USER_KEY, loginUser);
}
@ -89,41 +92,35 @@ public class LoginHelper {
* 获取用户id
*/
public static Long getUserId() {
Long userId;
try {
userId = Convert.toLong(SaHolder.getStorage().get(USER_KEY));
if (ObjectUtil.isNull(userId)) {
userId = Convert.toLong(StpUtil.getExtra(USER_KEY));
SaHolder.getStorage().set(USER_KEY, userId);
}
} catch (Exception e) {
return null;
}
return userId;
return Convert.toLong(getExtra(USER_KEY));
}
/**
* 获取租户ID
*/
public static String getTenantId() {
String tenantId;
try {
tenantId = (String) SaHolder.getStorage().get(TENANT_KEY);
if (ObjectUtil.isNull(tenantId)) {
tenantId = (String) StpUtil.getExtra(TENANT_KEY);
SaHolder.getStorage().set(TENANT_KEY, tenantId);
}
} catch (Exception e) {
return null;
}
return tenantId;
return Convert.toStr(getExtra(TENANT_KEY));
}
/**
* 获取部门ID
*/
public static Long getDeptId() {
return getLoginUser().getDeptId();
return Convert.toLong(getExtra(DEPT_KEY));
}
private static Object getExtra(String key) {
Object obj;
try {
obj = SaHolder.getStorage().get(key);
if (ObjectUtil.isNull(obj)) {
obj = StpUtil.getExtra(key);
SaHolder.getStorage().set(key, obj);
}
} catch (Exception e) {
return null;
}
return obj;
}
/**

View File

@ -72,8 +72,8 @@ public class SysConfigController extends BaseController {
*/
@SaCheckPermission("system:config:query")
@GetMapping(value = "/configKey/{configKey}")
public R<Void> getConfigKey(@PathVariable String configKey) {
return R.ok(configService.selectConfigByKey(configKey));
public R<String> getConfigKey(@PathVariable String configKey) {
return R.ok("操作成功", configService.selectConfigByKey(configKey));
}
/**

View File

@ -175,6 +175,7 @@ public class SysUserController extends BaseController {
@Log(title = "用户管理", businessType = BusinessType.INSERT)
@PostMapping
public R<Void> add(@Validated @RequestBody SysUserBo userBo) {
deptService.checkDeptDataScope(userBo.getDeptId());
if (!userService.checkUserNameUnique(userBo)) {
return R.fail("新增用户'" + userBo.getUserName() + "'失败,登录账号已存在");
} else if (StringUtils.isNotEmpty(userBo.getPhonenumber()) && !userService.checkPhoneUnique(userBo)) {
@ -199,6 +200,7 @@ public class SysUserController extends BaseController {
public R<Void> edit(@Validated @RequestBody SysUserBo userBo) {
userService.checkUserAllowed(userBo.getUserId());
userService.checkUserDataScope(userBo.getUserId());
deptService.checkDeptDataScope(userBo.getDeptId());
if (!userService.checkUserNameUnique(userBo)) {
return R.fail("修改用户'" + userBo.getUserName() + "'失败,登录账号已存在");
} else if (StringUtils.isNotEmpty(userBo.getPhonenumber()) && !userService.checkPhoneUnique(userBo)) {

View File

@ -21,6 +21,7 @@ import com.ruoyi.common.orm.core.service.impl.BaseServiceImpl;
import com.ruoyi.common.security.utils.LoginHelper;
import com.ruoyi.system.domain.*;
import com.ruoyi.system.domain.bo.SysUserBo;
import com.ruoyi.system.domain.vo.SysDeptVo;
import com.ruoyi.system.domain.vo.SysPostVo;
import com.ruoyi.system.domain.vo.SysRoleVo;
import com.ruoyi.system.domain.vo.SysUserVo;