fix: 数据权限调整后引发的问题修复
This commit is contained in:
@@ -27,12 +27,20 @@ public class CurrentUserDTO {
|
|||||||
@Schema(description="头像地址")
|
@Schema(description="头像地址")
|
||||||
private String avatar;
|
private String avatar;
|
||||||
|
|
||||||
|
@Schema(description = "性别(1-男 2-女 0-保密)")
|
||||||
|
private Integer gender;
|
||||||
|
|
||||||
|
@Schema(description = "部门名称")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
@Schema(description="用户角色编码集合")
|
@Schema(description="用户角色编码集合")
|
||||||
private Set<String> roles;
|
private Set<String> roles;
|
||||||
|
|
||||||
|
@Schema(description = "用户角色名称集合")
|
||||||
|
private Set<String> roleNames;
|
||||||
|
|
||||||
@Schema(description="用户权限标识集合")
|
@Schema(description="用户权限标识集合")
|
||||||
private Set<String> perms;
|
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.bo.UserBO;
|
||||||
import com.youlai.boot.system.model.dto.CurrentUserDTO;
|
import com.youlai.boot.system.model.dto.CurrentUserDTO;
|
||||||
import com.youlai.boot.system.model.dto.UserExportDTO;
|
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.DictItem;
|
||||||
|
import com.youlai.boot.system.model.entity.Role;
|
||||||
import com.youlai.boot.system.model.entity.User;
|
import com.youlai.boot.system.model.entity.User;
|
||||||
import com.youlai.boot.system.model.form.*;
|
import com.youlai.boot.system.model.form.*;
|
||||||
import com.youlai.boot.system.model.query.UserQuery;
|
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 UserRoleService userRoleService;
|
||||||
|
|
||||||
|
private final DeptService deptService;
|
||||||
|
|
||||||
private final RoleService roleService;
|
private final RoleService roleService;
|
||||||
|
|
||||||
private final RoleMenuService roleMenuService;
|
private final RoleMenuService roleMenuService;
|
||||||
@@ -297,16 +301,41 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|||||||
User::getId,
|
User::getId,
|
||||||
User::getUsername,
|
User::getUsername,
|
||||||
User::getNickname,
|
User::getNickname,
|
||||||
User::getAvatar
|
User::getAvatar,
|
||||||
|
User::getGender,
|
||||||
|
User::getDeptId
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
// entity->Vo
|
// entity->Vo
|
||||||
CurrentUserDTO userInfoVo = userConverter.toCurrentUserDto(user);
|
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();
|
Set<String> roles = SecurityUtils.getRoles();
|
||||||
userInfoVo.setRoles(roles);
|
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)) {
|
if (CollectionUtil.isNotEmpty(roles)) {
|
||||||
Set<String> perms = roleMenuService.getRolePermsByRoleCodes(roles);
|
Set<String> perms = roleMenuService.getRolePermsByRoleCodes(roles);
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ security:
|
|||||||
- /api/v1/auth/captcha # 验证码获取接口
|
- /api/v1/auth/captcha # 验证码获取接口
|
||||||
- /api/v1/auth/sms/code # 发送登录短信验证码
|
- /api/v1/auth/sms/code # 发送登录短信验证码
|
||||||
- /api/v1/auth/refresh-token # 刷新令牌接口
|
- /api/v1/auth/refresh-token # 刷新令牌接口
|
||||||
|
- /api/v1/wechat/miniapp/auth/** # 微信小程序认证接口(静默登录/手机号快捷登录/绑定手机号)
|
||||||
- /ws/** # WebSocket接口
|
- /ws/** # WebSocket接口
|
||||||
# 非安全端点路径,完全绕过 Spring Security 的过滤器
|
# 非安全端点路径,完全绕过 Spring Security 的过滤器
|
||||||
unsecured-urls:
|
unsecured-urls:
|
||||||
@@ -214,5 +215,5 @@ captcha:
|
|||||||
# 微信小程序配置
|
# 微信小程序配置
|
||||||
wx:
|
wx:
|
||||||
miniapp:
|
miniapp:
|
||||||
appid: xxxxxxx
|
appid: wx99a151dc43d2637b
|
||||||
secret: xxxxxxx
|
secret: fa2d74fd9f340ff1017c96fcbd19f5ad
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ security:
|
|||||||
- /api/v1/auth/login/** # 登录接口(账号密码登录、手机验证码登录和微信登录)
|
- /api/v1/auth/login/** # 登录接口(账号密码登录、手机验证码登录和微信登录)
|
||||||
- /api/v1/auth/captcha # 验证码获取接口
|
- /api/v1/auth/captcha # 验证码获取接口
|
||||||
- /api/v1/auth/refresh-token # 刷新令牌接口
|
- /api/v1/auth/refresh-token # 刷新令牌接口
|
||||||
|
- /api/v1/wechat/miniapp/auth/** # 微信小程序认证接口(静默登录/手机号快捷登录/绑定手机号)
|
||||||
- /ws/** # WebSocket接口
|
- /ws/** # WebSocket接口
|
||||||
# 非安全端点路径,完全绕过 Spring Security 的过滤器
|
# 非安全端点路径,完全绕过 Spring Security 的过滤器
|
||||||
unsecured-urls:
|
unsecured-urls:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
<!--suppress ALL -->
|
<!--suppress ALL -->
|
||||||
<mapper namespace="com.youlai.boot.platform.codegen.mapper.DatabaseMapper">
|
<mapper namespace="com.youlai.boot.tool.codegen.mapper.DatabaseMapper">
|
||||||
|
|
||||||
<!-- 查询数据库表分页 mysql版本-->
|
<!-- 查询数据库表分页 mysql版本-->
|
||||||
<select id="getTablePage" resultType="com.youlai.boot.tool.codegen.model.vo.TablePageVO" databaseId="mysql">
|
<select id="getTablePage" resultType="com.youlai.boot.tool.codegen.model.vo.TablePageVO" databaseId="mysql">
|
||||||
|
|||||||
Reference in New Issue
Block a user