refactor(core):更换jdk17新特性
This commit is contained in:
+1
-1
@@ -138,7 +138,7 @@ public class SystemAuthController {
|
||||
// 保存
|
||||
redisHelper.set(uuid, captchaValue, properties.getLogin().getCaptchaSetting().getExpiration(), TimeUnit.MINUTES);
|
||||
// 验证码信息
|
||||
Map<String, Object> imgResult = new HashMap<String, Object>(2) {{
|
||||
Map<String, Object> imgResult = new HashMap<>(2) {{
|
||||
put("img", captcha.toBase64());
|
||||
put("uuid", uuid);
|
||||
}};
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ public class SystemDeptController {
|
||||
}
|
||||
}
|
||||
// 编辑部门时不显示自己以及自己下级的数据, 避免出现PID数据环形问题
|
||||
depts = depts.stream().filter(i -> !ids.contains(i.getId())).collect(Collectors.toList());
|
||||
depts = depts.stream().filter(i -> !ids.contains(i.getId())).toList();
|
||||
}
|
||||
deptSet.addAll(depts);
|
||||
}
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ public class SystemRoleController {
|
||||
*/
|
||||
private int checkRoleLevels(Integer level) {
|
||||
List<Integer> levels =
|
||||
systemRoleService.queryRoleByUsersId(CsSecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList());
|
||||
systemRoleService.queryRoleByUsersId(CsSecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).toList();
|
||||
int min = Collections.min(levels);
|
||||
if (level != null) {
|
||||
if (level < min) {
|
||||
|
||||
+4
-4
@@ -143,8 +143,8 @@ public class SystemUserController {
|
||||
public ResponseEntity<Object> removeUserByIds(@RequestBody Set<Long> ids) {
|
||||
for (Long id : ids) {
|
||||
Integer currentLevel = Collections.min(
|
||||
systemRoleService.queryRoleByUsersId(CsSecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||
Integer optLevel = Collections.min(systemRoleService.queryRoleByUsersId(id).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||
systemRoleService.queryRoleByUsersId(CsSecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).toList());
|
||||
Integer optLevel = Collections.min(systemRoleService.queryRoleByUsersId(id).stream().map(SystemRoleTb::getLevel).toList());
|
||||
if (currentLevel > optLevel) {
|
||||
throw new BadRequestException("角色权限不足, 不能删除:" + systemUserService.getUserById(id).getUsername());
|
||||
}
|
||||
@@ -203,7 +203,7 @@ public class SystemUserController {
|
||||
*/
|
||||
private void checkLevel(SystemUserTb args) {
|
||||
Integer currentLevel = Collections.min(
|
||||
systemRoleService.queryRoleByUsersId(CsSecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||
systemRoleService.queryRoleByUsersId(CsSecurityHelper.getCurrentUserId()).stream().map(SystemRoleTb::getLevel).toList());
|
||||
Integer optLevel = systemRoleService.getDeptLevelByRoles(args.getRoles());
|
||||
if (currentLevel > optLevel) {
|
||||
throw new BadRequestException("角色权限不足");
|
||||
@@ -234,7 +234,7 @@ public class SystemUserController {
|
||||
ext.put("email", m.getEmail());
|
||||
ext.put("phone", m.getPhone());
|
||||
return CsSelectOptionVo.builder().label(m.getNickName()).value(String.valueOf(m.getId())).ext(ext).build();
|
||||
}).collect(Collectors.toList());
|
||||
}).toList();
|
||||
return ResponseEntity.ok(collect);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -75,7 +75,8 @@ public class BizLockAspect {
|
||||
Object[] args = joinPoint.getArgs();
|
||||
for (int i = 0; i < parameterNames.length; i++) {
|
||||
context.setVariable(parameterNames[i], args[i]);
|
||||
context.setVariable("p" + i, args[i]); // 支持#p0,#p1格式
|
||||
// 支持#p0,#p1格式
|
||||
context.setVariable("p" + i, args[i]);
|
||||
}
|
||||
|
||||
// 设置方法相关信息
|
||||
|
||||
+1
-1
@@ -35,7 +35,7 @@ public class AuthorityConfig {
|
||||
*/
|
||||
public Boolean check(String... permissions) {
|
||||
// 获取当前用户的所有权限
|
||||
List<String> roleList = CsSecurityHelper.getCurrentUser().getAuthorities().stream().map(GrantedAuthority::getAuthority).collect(Collectors.toList());
|
||||
List<String> roleList = CsSecurityHelper.getCurrentUser().getAuthorities().stream().map(GrantedAuthority::getAuthority).toList();
|
||||
// 判断当前用户的所有权限是否包含接口上定义的权限
|
||||
return roleList.contains("admin") || Arrays.stream(permissions).anyMatch(roleList::contains);
|
||||
}
|
||||
|
||||
+5
-8
@@ -55,17 +55,14 @@ public class SystemDataService {
|
||||
for (SystemRoleTb role : roleList) {
|
||||
SystemDataScopeEnum dataScopeEnum = SystemDataScopeEnum.find(role.getDataScope());
|
||||
switch (Objects.requireNonNull(dataScopeEnum)) {
|
||||
case THIS_LEVEL:
|
||||
deptIds.add(user.getDept().getId());
|
||||
break;
|
||||
case CUSTOMIZE:
|
||||
deptIds.addAll(queryCustomDataPermissionList(deptIds, role));
|
||||
break;
|
||||
default:
|
||||
case THIS_LEVEL -> deptIds.add(user.getDept().getId());
|
||||
case CUSTOMIZE -> deptIds.addAll(queryCustomDataPermissionList(deptIds, role));
|
||||
default -> {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
||||
return deptIds.stream().distinct().collect(Collectors.toList());
|
||||
return deptIds.stream().distinct().toList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+1
-1
@@ -294,7 +294,7 @@ public class SystemDeptService {
|
||||
public CsPageResult<SystemDeptTb> buildDeptTree(List<SystemDeptTb> deptList) {
|
||||
Set<SystemDeptTb> trees = new LinkedHashSet<>();
|
||||
Set<SystemDeptTb> deptSet = new LinkedHashSet<>();
|
||||
List<String> deptNames = deptList.stream().map(SystemDeptTb::getName).collect(Collectors.toList());
|
||||
List<String> deptNames = deptList.stream().map(SystemDeptTb::getName).toList();
|
||||
boolean isChild;
|
||||
for (SystemDeptTb dept : deptList) {
|
||||
isChild = false;
|
||||
|
||||
+2
-2
@@ -155,7 +155,7 @@ public class SystemMenuService {
|
||||
menuSet.add(systemMenuMapper.selectById(id));
|
||||
menuSet = this.queryChildMenu(menuList, menuSet);
|
||||
}
|
||||
List<Long> menuIds = menuSet.stream().map(SystemMenuTb::getId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
List<Long> menuIds = menuSet.stream().map(SystemMenuTb::getId).filter(Objects::nonNull).distinct().toList();
|
||||
if (CollUtil.isNotEmpty(menuIds)) {
|
||||
CsSpringBeanHolder.getBean(SystemMenuService.class).removeRoleMenuByMenuIds(menuIds);
|
||||
systemMenuMapper.deleteByIds(menuIds);
|
||||
@@ -323,7 +323,7 @@ public class SystemMenuService {
|
||||
}
|
||||
}
|
||||
if (CollUtil.isNotEmpty(trees)) {
|
||||
trees = menus.stream().filter(s -> !ids.contains(s.getId())).collect(Collectors.toList());
|
||||
trees = menus.stream().filter(s -> !ids.contains(s.getId())).toList();
|
||||
}
|
||||
return trees;
|
||||
}
|
||||
|
||||
+3
-3
@@ -213,7 +213,7 @@ public class SystemRoleService {
|
||||
for (SystemRoleTb role : roles) {
|
||||
roleSet.add(getRoleById(role.getId()));
|
||||
}
|
||||
return Collections.min(roleSet.stream().map(SystemRoleTb::getLevel).collect(Collectors.toList()));
|
||||
return Collections.min(roleSet.stream().map(SystemRoleTb::getLevel).toList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -228,7 +228,7 @@ public class SystemRoleService {
|
||||
// 如果是管理员直接返回
|
||||
if (user.getIsAdmin()) {
|
||||
permissions.add("admin");
|
||||
return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList());
|
||||
return permissions.stream().map(SystemRoleCodeVo::new).toList();
|
||||
}
|
||||
List<SystemRoleTb> roles = systemRoleMapper.selectRoleByUserId(user.getId());
|
||||
permissions = roles.stream()
|
||||
@@ -236,7 +236,7 @@ public class SystemRoleService {
|
||||
.map(SystemMenuTb::getPermission)
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.collect(Collectors.toSet());
|
||||
return permissions.stream().map(SystemRoleCodeVo::new).collect(Collectors.toList());
|
||||
return permissions.stream().map(SystemRoleCodeVo::new).toList();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-2
@@ -267,12 +267,12 @@ public class SystemUserService {
|
||||
public void exportUserExcel(List<SystemUserTb> users, HttpServletResponse response) throws IOException {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
for (SystemUserTb user : users) {
|
||||
List<String> roles = user.getRoles().stream().map(SystemRoleTb::getName).collect(Collectors.toList());
|
||||
List<String> roles = user.getRoles().stream().map(SystemRoleTb::getName).toList();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("用户名", user.getUsername());
|
||||
map.put("角色", roles);
|
||||
map.put("部门", user.getDept().getName());
|
||||
map.put("岗位", user.getJobs().stream().map(SystemJobTb::getName).collect(Collectors.toList()));
|
||||
map.put("岗位", user.getJobs().stream().map(SystemJobTb::getName).toList());
|
||||
map.put("邮箱", user.getEmail());
|
||||
map.put("状态", user.getEnabled() ? "启用" : "禁用");
|
||||
map.put("手机号码", user.getPhone());
|
||||
|
||||
-1
@@ -65,7 +65,6 @@
|
||||
后台管理系统 All Rights Reserved.
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user