fix: 数据权限调整后引发的问题修复
This commit is contained in:
@@ -27,12 +27,20 @@ public class CurrentUserDTO {
|
||||
@Schema(description="头像地址")
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "性别(1-男 2-女 0-保密)")
|
||||
private Integer gender;
|
||||
|
||||
@Schema(description = "部门名称")
|
||||
private String deptName;
|
||||
|
||||
@Schema(description="用户角色编码集合")
|
||||
private Set<String> roles;
|
||||
|
||||
@Schema(description = "用户角色名称集合")
|
||||
private Set<String> roleNames;
|
||||
|
||||
@Schema(description="用户权限标识集合")
|
||||
private Set<String> perms;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,9 @@ import com.youlai.boot.system.mapper.UserMapper;
|
||||
import com.youlai.boot.system.model.bo.UserBO;
|
||||
import com.youlai.boot.system.model.dto.CurrentUserDTO;
|
||||
import com.youlai.boot.system.model.dto.UserExportDTO;
|
||||
import com.youlai.boot.system.model.entity.Dept;
|
||||
import com.youlai.boot.system.model.entity.DictItem;
|
||||
import com.youlai.boot.system.model.entity.Role;
|
||||
import com.youlai.boot.system.model.entity.User;
|
||||
import com.youlai.boot.system.model.form.*;
|
||||
import com.youlai.boot.system.model.query.UserQuery;
|
||||
@@ -58,6 +60,8 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
|
||||
private final UserRoleService userRoleService;
|
||||
|
||||
private final DeptService deptService;
|
||||
|
||||
private final RoleService roleService;
|
||||
|
||||
private final RoleMenuService roleMenuService;
|
||||
@@ -121,10 +125,10 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
public boolean saveUser(UserForm userForm) {
|
||||
|
||||
String username = userForm.getUsername();
|
||||
|
||||
|
||||
// 实体转换 form->entity
|
||||
User entity = userConverter.toEntity(userForm);
|
||||
|
||||
|
||||
// 检查用户名是否已存在
|
||||
long count = this.count(new LambdaQueryWrapper<User>()
|
||||
.eq(User::getUsername, username));
|
||||
@@ -157,7 +161,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
public boolean updateUser(Long userId, UserForm userForm) {
|
||||
|
||||
String username = userForm.getUsername();
|
||||
|
||||
|
||||
// 获取原用户信息
|
||||
User oldUser = this.getById(userId);
|
||||
Assert.notNull(oldUser, "用户不存在");
|
||||
@@ -197,7 +201,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
List<Long> ids = Arrays.stream(idsStr.split(","))
|
||||
.map(Long::parseLong)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
boolean result = this.removeByIds(ids);
|
||||
return result;
|
||||
}
|
||||
@@ -297,16 +301,41 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
||||
User::getId,
|
||||
User::getUsername,
|
||||
User::getNickname,
|
||||
User::getAvatar
|
||||
User::getAvatar,
|
||||
User::getGender,
|
||||
User::getDeptId
|
||||
)
|
||||
);
|
||||
// entity->Vo
|
||||
CurrentUserDTO userInfoVo = userConverter.toCurrentUserDto(user);
|
||||
|
||||
// 性别
|
||||
userInfoVo.setGender(user.getGender());
|
||||
|
||||
// 部门名称
|
||||
if (user.getDeptId() != null) {
|
||||
Dept dept = deptService.getById(user.getDeptId());
|
||||
if (dept != null) {
|
||||
userInfoVo.setDeptName(dept.getName());
|
||||
}
|
||||
}
|
||||
|
||||
// 用户角色集合
|
||||
Set<String> roles = SecurityUtils.getRoles();
|
||||
userInfoVo.setRoles(roles);
|
||||
|
||||
// 用户角色名称集合
|
||||
if (CollectionUtil.isNotEmpty(roles)) {
|
||||
Set<String> roleNames = roleService.list(new LambdaQueryWrapper<Role>()
|
||||
.in(Role::getCode, roles)
|
||||
.select(Role::getName)
|
||||
).stream()
|
||||
.map(Role::getName)
|
||||
.filter(StrUtil::isNotBlank)
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
userInfoVo.setRoleNames(roleNames);
|
||||
}
|
||||
|
||||
// 用户权限集合
|
||||
if (CollectionUtil.isNotEmpty(roles)) {
|
||||
Set<String> perms = roleMenuService.getRolePermsByRoleCodes(roles);
|
||||
|
||||
@@ -83,6 +83,7 @@ security:
|
||||
- /api/v1/auth/captcha # 验证码获取接口
|
||||
- /api/v1/auth/sms/code # 发送登录短信验证码
|
||||
- /api/v1/auth/refresh-token # 刷新令牌接口
|
||||
- /api/v1/wechat/miniapp/auth/** # 微信小程序认证接口(静默登录/手机号快捷登录/绑定手机号)
|
||||
- /ws/** # WebSocket接口
|
||||
# 非安全端点路径,完全绕过 Spring Security 的过滤器
|
||||
unsecured-urls:
|
||||
@@ -214,5 +215,5 @@ captcha:
|
||||
# 微信小程序配置
|
||||
wx:
|
||||
miniapp:
|
||||
appid: xxxxxxx
|
||||
secret: xxxxxxx
|
||||
appid: wx99a151dc43d2637b
|
||||
secret: fa2d74fd9f340ff1017c96fcbd19f5ad
|
||||
|
||||
@@ -82,6 +82,7 @@ security:
|
||||
- /api/v1/auth/login/** # 登录接口(账号密码登录、手机验证码登录和微信登录)
|
||||
- /api/v1/auth/captcha # 验证码获取接口
|
||||
- /api/v1/auth/refresh-token # 刷新令牌接口
|
||||
- /api/v1/wechat/miniapp/auth/** # 微信小程序认证接口(静默登录/手机号快捷登录/绑定手机号)
|
||||
- /ws/** # WebSocket接口
|
||||
# 非安全端点路径,完全绕过 Spring Security 的过滤器
|
||||
unsecured-urls:
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<!--suppress ALL -->
|
||||
<mapper namespace="com.youlai.boot.platform.codegen.mapper.DatabaseMapper">
|
||||
<mapper namespace="com.youlai.boot.tool.codegen.mapper.DatabaseMapper">
|
||||
|
||||
<!-- 查询数据库表分页 mysql版本-->
|
||||
<select id="getTablePage" resultType="com.youlai.boot.tool.codegen.model.vo.TablePageVO" databaseId="mysql">
|
||||
|
||||
Reference in New Issue
Block a user