diff --git a/src/main/java/com/youlai/boot/system/model/dto/CurrentUserDTO.java b/src/main/java/com/youlai/boot/system/model/dto/CurrentUserDTO.java index bfa5b8a9..09a4cdca 100644 --- a/src/main/java/com/youlai/boot/system/model/dto/CurrentUserDTO.java +++ b/src/main/java/com/youlai/boot/system/model/dto/CurrentUserDTO.java @@ -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 roles; + @Schema(description = "用户角色名称集合") + private Set roleNames; + @Schema(description="用户权限标识集合") private Set perms; } - \ No newline at end of file diff --git a/src/main/java/com/youlai/boot/system/service/impl/UserServiceImpl.java b/src/main/java/com/youlai/boot/system/service/impl/UserServiceImpl.java index 286d9fb2..963358d8 100644 --- a/src/main/java/com/youlai/boot/system/service/impl/UserServiceImpl.java +++ b/src/main/java/com/youlai/boot/system/service/impl/UserServiceImpl.java @@ -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 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 implements Us public boolean saveUser(UserForm userForm) { String username = userForm.getUsername(); - + // 实体转换 form->entity User entity = userConverter.toEntity(userForm); - + // 检查用户名是否已存在 long count = this.count(new LambdaQueryWrapper() .eq(User::getUsername, username)); @@ -157,7 +161,7 @@ public class UserServiceImpl extends ServiceImpl 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 implements Us List 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 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 roles = SecurityUtils.getRoles(); userInfoVo.setRoles(roles); + // 用户角色名称集合 + if (CollectionUtil.isNotEmpty(roles)) { + Set roleNames = roleService.list(new LambdaQueryWrapper() + .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 perms = roleMenuService.getRolePermsByRoleCodes(roles); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 8afaa7d1..cb2040e6 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -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 diff --git a/src/main/resources/application-prod.yml b/src/main/resources/application-prod.yml index 84c8bf31..de79b370 100644 --- a/src/main/resources/application-prod.yml +++ b/src/main/resources/application-prod.yml @@ -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: diff --git a/src/main/resources/mapper/codegen/DatabaseMapper.xml b/src/main/resources/mapper/codegen/DatabaseMapper.xml index 1f07400d..862fad53 100644 --- a/src/main/resources/mapper/codegen/DatabaseMapper.xml +++ b/src/main/resources/mapper/codegen/DatabaseMapper.xml @@ -3,7 +3,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - +