Commit b8857df7fe835115298916a1afe38d50f474c42f
1 parent
d6cc9e23
完成用户中心的对接
Showing
16 changed files
with
145 additions
and
103 deletions
ruoyi-ui/src/api/system/user.js
| ... | ... | @@ -104,9 +104,9 @@ export function updateUserPwd(oldPassword, newPassword) { |
| 104 | 104 | newPassword |
| 105 | 105 | } |
| 106 | 106 | return request({ |
| 107 | - url: '/system/user/profile/updatePwd', | |
| 107 | + url: '/system/user/profile/update-password', | |
| 108 | 108 | method: 'put', |
| 109 | - params: data | |
| 109 | + data: data | |
| 110 | 110 | }) |
| 111 | 111 | } |
| 112 | 112 | ... | ... |
ruoyi-ui/src/views/system/user/index.vue
| ... | ... | @@ -107,8 +107,7 @@ |
| 107 | 107 | <el-col :span="12"> |
| 108 | 108 | <el-form-item label="归属部门" prop="deptId"> |
| 109 | 109 | <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" |
| 110 | - placeholder="请选择归属部门" :normalizer="normalizer" | |
| 111 | - /> | |
| 110 | + placeholder="请选择归属部门" :normalizer="normalizer"/> | |
| 112 | 111 | </el-form-item> |
| 113 | 112 | </el-col> |
| 114 | 113 | </el-row> |
| ... | ... | @@ -140,12 +139,7 @@ |
| 140 | 139 | <el-col :span="12"> |
| 141 | 140 | <el-form-item label="用户性别"> |
| 142 | 141 | <el-select v-model="form.sex" placeholder="请选择"> |
| 143 | - <el-option | |
| 144 | - v-for="dict in sexDictDatas" | |
| 145 | - :key="parseInt(dict.value)" | |
| 146 | - :label="dict.label" | |
| 147 | - :value="parseInt(dict.value)" | |
| 148 | - ></el-option> | |
| 142 | + <el-option v-for="dict in sexDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/> | |
| 149 | 143 | </el-select> |
| 150 | 144 | </el-form-item> |
| 151 | 145 | </el-col> | ... | ... |
ruoyi-ui/src/views/system/user/profile/index.vue
| ... | ... | @@ -13,11 +13,11 @@ |
| 13 | 13 | <ul class="list-group list-group-striped"> |
| 14 | 14 | <li class="list-group-item"> |
| 15 | 15 | <svg-icon icon-class="user" />用户名称 |
| 16 | - <div class="pull-right">{{ user.userName }}</div> | |
| 16 | + <div class="pull-right">{{ user.username }}</div> | |
| 17 | 17 | </li> |
| 18 | 18 | <li class="list-group-item"> |
| 19 | 19 | <svg-icon icon-class="phone" />手机号码 |
| 20 | - <div class="pull-right">{{ user.phonenumber }}</div> | |
| 20 | + <div class="pull-right">{{ user.mobile }}</div> | |
| 21 | 21 | </li> |
| 22 | 22 | <li class="list-group-item"> |
| 23 | 23 | <svg-icon icon-class="email" />用户邮箱 |
| ... | ... | @@ -25,15 +25,19 @@ |
| 25 | 25 | </li> |
| 26 | 26 | <li class="list-group-item"> |
| 27 | 27 | <svg-icon icon-class="tree" />所属部门 |
| 28 | - <div class="pull-right" v-if="user.dept">{{ user.dept.deptName }} / {{ postGroup }}</div> | |
| 28 | + <div class="pull-right" v-if="user.dept">{{ user.dept.name }}</div> | |
| 29 | + </li> | |
| 30 | + <li class="list-group-item"> | |
| 31 | + <svg-icon icon-class="tree" />所属岗位 | |
| 32 | + <div class="pull-right" v-if="user.posts">{{ user.posts.map(post => post.name).join(',') }}</div> | |
| 29 | 33 | </li> |
| 30 | 34 | <li class="list-group-item"> |
| 31 | 35 | <svg-icon icon-class="peoples" />所属角色 |
| 32 | - <div class="pull-right">{{ roleGroup }}</div> | |
| 36 | + <div class="pull-right">{{ user.roles.map(post => post.name).join(',') }}</div> | |
| 33 | 37 | </li> |
| 34 | 38 | <li class="list-group-item"> |
| 35 | 39 | <svg-icon icon-class="date" />创建日期 |
| 36 | - <div class="pull-right">{{ user.createTime }}</div> | |
| 40 | + <div class="pull-right">{{ parseTime(user.createTime) }}</div> | |
| 37 | 41 | </li> |
| 38 | 42 | </ul> |
| 39 | 43 | </div> |
| ... | ... | @@ -82,8 +86,6 @@ export default { |
| 82 | 86 | getUser() { |
| 83 | 87 | getUserProfile().then(response => { |
| 84 | 88 | this.user = response.data; |
| 85 | - this.roleGroup = response.roleGroup; | |
| 86 | - this.postGroup = response.postGroup; | |
| 87 | 89 | }); |
| 88 | 90 | } |
| 89 | 91 | } | ... | ... |
ruoyi-ui/src/views/system/user/profile/userInfo.vue
| ... | ... | @@ -3,7 +3,7 @@ |
| 3 | 3 | <el-form-item label="用户昵称" prop="nickName"> |
| 4 | 4 | <el-input v-model="user.nickname" /> |
| 5 | 5 | </el-form-item> |
| 6 | - <el-form-item label="手机号码" prop="phonenumber"> | |
| 6 | + <el-form-item label="手机号码" prop="mobile"> | |
| 7 | 7 | <el-input v-model="user.mobile" maxlength="11" /> |
| 8 | 8 | </el-form-item> |
| 9 | 9 | <el-form-item label="邮箱" prop="email"> | ... | ... |
src/main/java/cn/iocoder/dashboard/framework/redis/config/RedisConfig.java
| ... | ... | @@ -83,8 +83,8 @@ public class RedisConfig { |
| 83 | 83 | redisTemplate.getRequiredConnectionFactory(), containerOptions); |
| 84 | 84 | |
| 85 | 85 | // 第二步,注册监听器,消费对应的 Stream 主题 |
| 86 | -// String consumerName = buildConsumerName(); | |
| 87 | - String consumerName = "110"; | |
| 86 | + String consumerName = buildConsumerName(); | |
| 87 | +// String consumerName = "110"; | |
| 88 | 88 | listeners.forEach(listener -> { |
| 89 | 89 | // 创建 listener 对应的消费者分组 |
| 90 | 90 | try { |
| ... | ... | @@ -106,6 +106,12 @@ public class RedisConfig { |
| 106 | 106 | return container; |
| 107 | 107 | } |
| 108 | 108 | |
| 109 | + /** | |
| 110 | + * 构建消费者名字,使用本地 IP + 进程编号的方式。 | |
| 111 | + * 参考自 RocketMQ clientId 的实现 | |
| 112 | + * | |
| 113 | + * @return 消费者名字 | |
| 114 | + */ | |
| 109 | 115 | private static String buildConsumerName() { |
| 110 | 116 | return String.format("%s@%d", SystemUtil.getHostInfo().getAddress(), SystemUtil.getCurrentPID()); |
| 111 | 117 | } | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/user/SysUserProfileController.java
| 1 | 1 | package cn.iocoder.dashboard.modules.system.controller.user; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 4 | import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; |
| 4 | 5 | import cn.iocoder.dashboard.common.pojo.CommonResult; |
| 5 | -import cn.iocoder.dashboard.framework.security.core.util.SecurityFrameworkUtils; | |
| 6 | 6 | import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileRespVO; |
| 7 | -import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVo; | |
| 7 | +import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; | |
| 8 | 8 | import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; |
| 9 | -import cn.iocoder.dashboard.modules.system.convert.auth.SysAuthConvert; | |
| 10 | 9 | import cn.iocoder.dashboard.modules.system.convert.user.SysUserConvert; |
| 10 | +import cn.iocoder.dashboard.modules.system.dal.dataobject.dept.SysDeptDO; | |
| 11 | +import cn.iocoder.dashboard.modules.system.dal.dataobject.dept.SysPostDO; | |
| 11 | 12 | import cn.iocoder.dashboard.modules.system.dal.dataobject.permission.SysRoleDO; |
| 12 | 13 | import cn.iocoder.dashboard.modules.system.dal.dataobject.user.SysUserDO; |
| 14 | +import cn.iocoder.dashboard.modules.system.service.dept.SysDeptService; | |
| 15 | +import cn.iocoder.dashboard.modules.system.service.dept.SysPostService; | |
| 13 | 16 | import cn.iocoder.dashboard.modules.system.service.permission.SysPermissionService; |
| 14 | 17 | import cn.iocoder.dashboard.modules.system.service.permission.SysRoleService; |
| 15 | 18 | import cn.iocoder.dashboard.modules.system.service.user.SysUserService; |
| 16 | -import cn.iocoder.dashboard.util.collection.CollectionUtils; | |
| 17 | 19 | import io.swagger.annotations.Api; |
| 18 | 20 | import io.swagger.annotations.ApiOperation; |
| 19 | 21 | import lombok.extern.slf4j.Slf4j; |
| 20 | -import org.springframework.web.bind.annotation.GetMapping; | |
| 21 | -import org.springframework.web.bind.annotation.PutMapping; | |
| 22 | -import org.springframework.web.bind.annotation.RequestBody; | |
| 23 | -import org.springframework.web.bind.annotation.RequestMapping; | |
| 24 | -import org.springframework.web.bind.annotation.RequestParam; | |
| 25 | -import org.springframework.web.bind.annotation.RestController; | |
| 22 | +import org.springframework.validation.annotation.Validated; | |
| 23 | +import org.springframework.web.bind.annotation.*; | |
| 26 | 24 | import org.springframework.web.multipart.MultipartFile; |
| 27 | 25 | |
| 28 | 26 | import javax.annotation.Resource; |
| 29 | -import javax.servlet.http.HttpServletRequest; | |
| 30 | 27 | import javax.validation.Valid; |
| 31 | 28 | import java.io.IOException; |
| 32 | 29 | import java.util.List; |
| 33 | 30 | |
| 34 | 31 | import static cn.iocoder.dashboard.common.pojo.CommonResult.success; |
| 32 | +import static cn.iocoder.dashboard.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | |
| 35 | 33 | import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.FILE_IS_EMPTY; |
| 36 | 34 | |
| 37 | 35 | /** |
| 38 | 36 | * @author niudehua |
| 39 | 37 | */ |
| 38 | +@Api(tags = "用户个人中心") | |
| 40 | 39 | @RestController |
| 41 | 40 | @RequestMapping("/system/user/profile") |
| 42 | -@Api(tags = "用户个人中心") | |
| 41 | +@Validated | |
| 43 | 42 | @Slf4j |
| 44 | 43 | public class SysUserProfileController { |
| 45 | 44 | |
| 46 | 45 | @Resource |
| 47 | 46 | private SysUserService userService; |
| 48 | 47 | @Resource |
| 48 | + private SysDeptService deptService; | |
| 49 | + @Resource | |
| 50 | + private SysPostService postService; | |
| 51 | + @Resource | |
| 49 | 52 | private SysPermissionService permissionService; |
| 50 | 53 | @Resource |
| 51 | 54 | private SysRoleService roleService; |
| ... | ... | @@ -53,28 +56,36 @@ public class SysUserProfileController { |
| 53 | 56 | @GetMapping("/get") |
| 54 | 57 | @ApiOperation("获得登录用户信息") |
| 55 | 58 | public CommonResult<SysUserProfileRespVO> profile() { |
| 56 | - // 获取用户信息 | |
| 57 | - Long userId = SecurityFrameworkUtils.getLoginUserId(); | |
| 58 | - SysUserDO user = userService.getUser(userId); | |
| 59 | - SysUserProfileRespVO userProfileRespVO = SysUserConvert.INSTANCE.convert03(user); | |
| 60 | - List<SysRoleDO> userRoles = roleService.getRolesFromCache(permissionService.listUserRoleIs(userId)); | |
| 61 | - userProfileRespVO.setRoles(CollectionUtils.convertSet(userRoles, SysUserConvert.INSTANCE::convert)); | |
| 62 | - return success(userProfileRespVO); | |
| 59 | + // 获得用户基本信息 | |
| 60 | + SysUserDO user = userService.getUser(getLoginUserId()); | |
| 61 | + SysUserProfileRespVO resp = SysUserConvert.INSTANCE.convert03(user); | |
| 62 | + // 获得用户角色 | |
| 63 | + List<SysRoleDO> userRoles = roleService.getRolesFromCache(permissionService.listUserRoleIs(user.getId())); | |
| 64 | + resp.setRoles(SysUserConvert.INSTANCE.convertList(userRoles)); | |
| 65 | + // 获得部门信息 | |
| 66 | + if (user.getDeptId() != null) { | |
| 67 | + SysDeptDO dept = deptService.getDept(user.getDeptId()); | |
| 68 | + resp.setDept(SysUserConvert.INSTANCE.convert02(dept)); | |
| 69 | + } | |
| 70 | + // 获得岗位信息 | |
| 71 | + if (CollUtil.isNotEmpty(user.getPostIds())) { | |
| 72 | + List<SysPostDO> posts = postService.getPosts(user.getPostIds()); | |
| 73 | + resp.setPosts(SysUserConvert.INSTANCE.convertList02(posts)); | |
| 74 | + } | |
| 75 | + return success(resp); | |
| 63 | 76 | } |
| 64 | 77 | |
| 65 | 78 | @PutMapping("/update") |
| 66 | 79 | @ApiOperation("修改用户个人信息") |
| 67 | - public CommonResult<Boolean> updateUserProfile(@Valid @RequestBody SysUserProfileUpdateReqVO reqVO, HttpServletRequest request) { | |
| 68 | - userService.updateUserProfile(reqVO); | |
| 69 | - SecurityFrameworkUtils.setLoginUser(SysAuthConvert.INSTANCE.convert(reqVO), request); | |
| 80 | + public CommonResult<Boolean> updateUserProfile(@Valid @RequestBody SysUserProfileUpdateReqVO reqVO) { | |
| 81 | + userService.updateUserProfile(getLoginUserId(), reqVO); | |
| 70 | 82 | return success(true); |
| 71 | 83 | } |
| 72 | 84 | |
| 73 | 85 | @PutMapping("/update-password") |
| 74 | 86 | @ApiOperation("修改用户个人密码") |
| 75 | - public CommonResult<Boolean> updateUserProfilePassword(@Valid @RequestBody SysUserProfileUpdatePasswordReqVo reqVO, HttpServletRequest request) { | |
| 76 | - userService.updateUserPassword(reqVO); | |
| 77 | - SecurityFrameworkUtils.setLoginUser(SysAuthConvert.INSTANCE.convert(reqVO), request); | |
| 87 | + public CommonResult<Boolean> updateUserProfilePassword(@Valid @RequestBody SysUserProfileUpdatePasswordReqVO reqVO) { | |
| 88 | + userService.updateUserPassword(getLoginUserId(), reqVO); | |
| 78 | 89 | return success(true); |
| 79 | 90 | } |
| 80 | 91 | |
| ... | ... | @@ -84,7 +95,7 @@ public class SysUserProfileController { |
| 84 | 95 | if (file.isEmpty()) { |
| 85 | 96 | throw ServiceExceptionUtil.exception(FILE_IS_EMPTY); |
| 86 | 97 | } |
| 87 | - userService.updateUserAvatar(SecurityFrameworkUtils.getLoginUserId(), file.getInputStream()); | |
| 98 | + userService.updateUserAvatar(getLoginUserId(), file.getInputStream()); | |
| 88 | 99 | return success(true); |
| 89 | 100 | } |
| 90 | 101 | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileRespVO.java
| ... | ... | @@ -9,7 +9,7 @@ import lombok.EqualsAndHashCode; |
| 9 | 9 | import lombok.NoArgsConstructor; |
| 10 | 10 | |
| 11 | 11 | import java.util.Date; |
| 12 | -import java.util.Set; | |
| 12 | +import java.util.List; | |
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | @Data |
| ... | ... | @@ -18,6 +18,7 @@ import java.util.Set; |
| 18 | 18 | @AllArgsConstructor |
| 19 | 19 | @ApiModel("用户个人中心信息 Response VO") |
| 20 | 20 | public class SysUserProfileRespVO extends SysUserBaseVO { |
| 21 | + | |
| 21 | 22 | @ApiModelProperty(value = "用户编号", required = true, example = "1") |
| 22 | 23 | private Long id; |
| 23 | 24 | |
| ... | ... | @@ -36,8 +37,17 @@ public class SysUserProfileRespVO extends SysUserBaseVO { |
| 36 | 37 | /** |
| 37 | 38 | * 所属角色 |
| 38 | 39 | */ |
| 39 | - @ApiModelProperty(value = "所属角色", required = true, example = "123456") | |
| 40 | - private Set<Role> roles; | |
| 40 | + private List<Role> roles; | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * 所在部门 | |
| 44 | + */ | |
| 45 | + private Dept dept; | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * 所属岗位数组 | |
| 49 | + */ | |
| 50 | + private List<Post> posts; | |
| 41 | 51 | |
| 42 | 52 | @ApiModel("角色") |
| 43 | 53 | @Data |
| ... | ... | @@ -50,4 +60,29 @@ public class SysUserProfileRespVO extends SysUserBaseVO { |
| 50 | 60 | private String name; |
| 51 | 61 | |
| 52 | 62 | } |
| 63 | + | |
| 64 | + @ApiModel("部门") | |
| 65 | + @Data | |
| 66 | + public static class Dept { | |
| 67 | + | |
| 68 | + @ApiModelProperty(value = "部门编号", required = true, example = "1") | |
| 69 | + private Long id; | |
| 70 | + | |
| 71 | + @ApiModelProperty(value = "部门名称", required = true, example = "研发部") | |
| 72 | + private String name; | |
| 73 | + | |
| 74 | + } | |
| 75 | + | |
| 76 | + @ApiModel("岗位") | |
| 77 | + @Data | |
| 78 | + public static class Post { | |
| 79 | + | |
| 80 | + @ApiModelProperty(value = "岗位编号", required = true, example = "1") | |
| 81 | + private Long id; | |
| 82 | + | |
| 83 | + @ApiModelProperty(value = "岗位名称", required = true, example = "开发") | |
| 84 | + private String name; | |
| 85 | + | |
| 86 | + } | |
| 87 | + | |
| 53 | 88 | } | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileUpdatePasswordReqVo.java renamed to src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileUpdatePasswordReqVO.java
| ... | ... | @@ -6,23 +6,10 @@ import lombok.Data; |
| 6 | 6 | import org.hibernate.validator.constraints.Length; |
| 7 | 7 | |
| 8 | 8 | import javax.validation.constraints.NotEmpty; |
| 9 | -import javax.validation.constraints.NotNull; | |
| 10 | 9 | |
| 11 | -/** | |
| 12 | - * 类名称:SysUserUpdatePersonalPasswordReqVo | |
| 13 | - * *********************** | |
| 14 | - * <p> | |
| 15 | - * 类描述:更新用户个人密码 | |
| 16 | - * | |
| 17 | - * @author deng on 2021/3/15 22:04 | |
| 18 | - */ | |
| 19 | -@ApiModel("用户个人中心更新密码 Response VO") | |
| 10 | +@ApiModel("用户个人中心更新密码 Request VO") | |
| 20 | 11 | @Data |
| 21 | -public class SysUserProfileUpdatePasswordReqVo { | |
| 22 | - | |
| 23 | - @ApiModelProperty(value = "用户编号", required = true, example = "1024") | |
| 24 | - @NotNull(message = "用户编号不能为空") | |
| 25 | - private Long id; | |
| 12 | +public class SysUserProfileUpdatePasswordReqVO { | |
| 26 | 13 | |
| 27 | 14 | @ApiModelProperty(value = "旧密码", required = true, example = "123456") |
| 28 | 15 | @NotEmpty(message = "旧密码不能为空") |
| ... | ... | @@ -33,4 +20,5 @@ public class SysUserProfileUpdatePasswordReqVo { |
| 33 | 20 | @NotEmpty(message = "新密码不能为空") |
| 34 | 21 | @Length(min = 4, max = 16, message = "密码长度为 4-16 位") |
| 35 | 22 | private String newPassword; |
| 36 | -} | |
| 37 | 23 | \ No newline at end of file |
| 24 | + | |
| 25 | +} | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileUpdateReqVO.java
| ... | ... | @@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModelProperty; |
| 5 | 5 | import lombok.Data; |
| 6 | 6 | |
| 7 | 7 | import javax.validation.constraints.Email; |
| 8 | -import javax.validation.constraints.NotNull; | |
| 9 | 8 | import javax.validation.constraints.Pattern; |
| 10 | 9 | import javax.validation.constraints.Size; |
| 11 | 10 | |
| ... | ... | @@ -13,17 +12,13 @@ import javax.validation.constraints.Size; |
| 13 | 12 | @Data |
| 14 | 13 | public class SysUserProfileUpdateReqVO { |
| 15 | 14 | |
| 16 | - @ApiModelProperty(value = "用户编号", required = true, example = "1024") | |
| 17 | - @NotNull(message = "用户编号不能为空") | |
| 18 | - private Long id; | |
| 19 | - | |
| 20 | 15 | @ApiModelProperty(value = "用户昵称", required = true, example = "芋艿") |
| 21 | 16 | @Size(max = 30, message = "用户昵称长度不能超过30个字符") |
| 22 | 17 | private String nickname; |
| 23 | 18 | |
| 24 | 19 | @ApiModelProperty(value = "用户邮箱", example = "yudao@iocoder.cn") |
| 25 | 20 | @Email(message = "邮箱格式不正确") |
| 26 | - @Size(max = 50, message = "邮箱长度不能超过50个字符") | |
| 21 | + @Size(max = 50, message = "邮箱长度不能超过 50 个字符") | |
| 27 | 22 | private String email; |
| 28 | 23 | |
| 29 | 24 | @ApiModelProperty(value = "手机号码", example = "15601691300") |
| ... | ... | @@ -33,7 +28,4 @@ public class SysUserProfileUpdateReqVO { |
| 33 | 28 | @ApiModelProperty(value = "用户性别", example = "1", notes = "参见 SysSexEnum 枚举类") |
| 34 | 29 | private Integer sex; |
| 35 | 30 | |
| 36 | - @ApiModelProperty(value = "用户头像", example = "http://www.iocoder.cn/xxx.png") | |
| 37 | - private String avatar; | |
| 38 | - | |
| 39 | 31 | } | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserBaseVO.java
| ... | ... | @@ -36,7 +36,7 @@ public class SysUserBaseVO { |
| 36 | 36 | |
| 37 | 37 | @ApiModelProperty(value = "用户邮箱", example = "yudao@iocoder.cn") |
| 38 | 38 | @Email(message = "邮箱格式不正确") |
| 39 | - @Size(max = 50, message = "邮箱长度不能超过50个字符") | |
| 39 | + @Size(max = 50, message = "邮箱长度不能超过 50 个字符") | |
| 40 | 40 | private String email; |
| 41 | 41 | |
| 42 | 42 | @ApiModelProperty(value = "手机号码", example = "15601691300") | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserPageItemRespVO.java
| 1 | 1 | package cn.iocoder.dashboard.modules.system.controller.user.vo.user; |
| 2 | 2 | |
| 3 | -import com.fasterxml.jackson.annotation.JsonIgnore; | |
| 4 | 3 | import io.swagger.annotations.ApiModel; |
| 5 | 4 | import io.swagger.annotations.ApiModelProperty; |
| 6 | 5 | import lombok.AllArgsConstructor; |
| ... | ... | @@ -18,7 +17,6 @@ public class SysUserPageItemRespVO extends SysUserRespVO { |
| 18 | 17 | /** |
| 19 | 18 | * 所在部门 |
| 20 | 19 | */ |
| 21 | - @JsonIgnore | |
| 22 | 20 | private Dept dept; |
| 23 | 21 | |
| 24 | 22 | @ApiModel("部门") | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/convert/auth/SysAuthConvert.java
| ... | ... | @@ -3,7 +3,7 @@ package cn.iocoder.dashboard.modules.system.convert.auth; |
| 3 | 3 | import cn.iocoder.dashboard.framework.security.core.LoginUser; |
| 4 | 4 | import cn.iocoder.dashboard.modules.system.controller.auth.vo.auth.SysAuthMenuRespVO; |
| 5 | 5 | import cn.iocoder.dashboard.modules.system.controller.auth.vo.auth.SysAuthPermissionInfoRespVO; |
| 6 | -import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVo; | |
| 6 | +import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; | |
| 7 | 7 | import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; |
| 8 | 8 | import cn.iocoder.dashboard.modules.system.dal.dataobject.permission.SysMenuDO; |
| 9 | 9 | import cn.iocoder.dashboard.modules.system.dal.dataobject.permission.SysRoleDO; |
| ... | ... | @@ -42,7 +42,7 @@ public interface SysAuthConvert { |
| 42 | 42 | |
| 43 | 43 | LoginUser convert(SysUserProfileUpdateReqVO reqVO); |
| 44 | 44 | |
| 45 | - LoginUser convert(SysUserProfileUpdatePasswordReqVo reqVO); | |
| 45 | + LoginUser convert(SysUserProfileUpdatePasswordReqVO reqVO); | |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | 48 | * 将菜单列表,构建成菜单树 | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/convert/user/SysUserConvert.java
| 1 | 1 | package cn.iocoder.dashboard.modules.system.convert.user; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileRespVO; |
| 4 | -import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVo; | |
| 4 | +import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; | |
| 5 | 5 | import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; |
| 6 | -import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserCreateReqVO; | |
| 7 | -import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserExcelVO; | |
| 8 | -import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserImportExcelVO; | |
| 9 | -import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserPageItemRespVO; | |
| 10 | -import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserUpdateReqVO; | |
| 6 | +import cn.iocoder.dashboard.modules.system.controller.user.vo.user.*; | |
| 11 | 7 | import cn.iocoder.dashboard.modules.system.dal.dataobject.dept.SysDeptDO; |
| 8 | +import cn.iocoder.dashboard.modules.system.dal.dataobject.dept.SysPostDO; | |
| 12 | 9 | import cn.iocoder.dashboard.modules.system.dal.dataobject.permission.SysRoleDO; |
| 13 | 10 | import cn.iocoder.dashboard.modules.system.dal.dataobject.user.SysUserDO; |
| 14 | 11 | import org.mapstruct.Mapper; |
| 15 | 12 | import org.mapstruct.factory.Mappers; |
| 16 | 13 | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 17 | 16 | @Mapper |
| 18 | 17 | public interface SysUserConvert { |
| 19 | 18 | |
| ... | ... | @@ -33,11 +32,14 @@ public interface SysUserConvert { |
| 33 | 32 | |
| 34 | 33 | SysUserProfileRespVO convert03(SysUserDO bean); |
| 35 | 34 | |
| 36 | - SysUserProfileRespVO.Role convert(SysRoleDO bean); | |
| 35 | + List<SysUserProfileRespVO.Role> convertList(List<SysRoleDO> list); | |
| 36 | + | |
| 37 | + SysUserProfileRespVO.Dept convert02(SysDeptDO bean); | |
| 37 | 38 | |
| 38 | 39 | SysUserDO convert(SysUserProfileUpdateReqVO bean); |
| 39 | 40 | |
| 40 | - SysUserDO convert(SysUserProfileUpdatePasswordReqVo bean); | |
| 41 | + SysUserDO convert(SysUserProfileUpdatePasswordReqVO bean); | |
| 41 | 42 | |
| 43 | + List<SysUserProfileRespVO.Post> convertList02(List<SysPostDO> list); | |
| 42 | 44 | |
| 43 | 45 | } | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysPostService.java
| 1 | 1 | package cn.iocoder.dashboard.modules.system.service.dept; |
| 2 | 2 | |
| 3 | +import cn.iocoder.dashboard.common.enums.CommonStatusEnum; | |
| 3 | 4 | import cn.iocoder.dashboard.common.pojo.PageResult; |
| 4 | 5 | import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostCreateReqVO; |
| 5 | 6 | import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostExportReqVO; |
| ... | ... | @@ -11,6 +12,8 @@ import org.springframework.lang.Nullable; |
| 11 | 12 | import java.util.Collection; |
| 12 | 13 | import java.util.List; |
| 13 | 14 | |
| 15 | +import static cn.iocoder.dashboard.util.collection.SetUtils.asSet; | |
| 16 | + | |
| 14 | 17 | /** |
| 15 | 18 | * 岗位 Service 接口 |
| 16 | 19 | * |
| ... | ... | @@ -41,6 +44,16 @@ public interface SysPostService { |
| 41 | 44 | void deletePost(Long id); |
| 42 | 45 | |
| 43 | 46 | /** |
| 47 | + * 获得岗位列表 | |
| 48 | + * | |
| 49 | + * @param ids 岗位编号数组。如果为空,不进行筛选 | |
| 50 | + * @return 部门列表 | |
| 51 | + */ | |
| 52 | + default List<SysPostDO> getPosts(@Nullable Collection<Long> ids) { | |
| 53 | + return getPosts(ids, asSet(CommonStatusEnum.ENABLE.getStatus(), CommonStatusEnum.DISABLE.getStatus())); | |
| 54 | + } | |
| 55 | + | |
| 56 | + /** | |
| 44 | 57 | * 获得符合条件的岗位列表 |
| 45 | 58 | * |
| 46 | 59 | * @param ids 岗位编号数组。如果为空,不进行筛选 | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/user/SysUserService.java
| ... | ... | @@ -2,7 +2,7 @@ package cn.iocoder.dashboard.modules.system.service.user; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.iocoder.dashboard.common.pojo.PageResult; |
| 5 | -import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVo; | |
| 5 | +import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; | |
| 6 | 6 | import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; |
| 7 | 7 | import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserCreateReqVO; |
| 8 | 8 | import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserExportReqVO; |
| ... | ... | @@ -44,17 +44,18 @@ public interface SysUserService { |
| 44 | 44 | /** |
| 45 | 45 | * 修改用户个人信息 |
| 46 | 46 | * |
| 47 | + * @param id 用户编号 | |
| 47 | 48 | * @param reqVO 用户个人信息 |
| 48 | 49 | */ |
| 49 | - void updateUserProfile(SysUserProfileUpdateReqVO reqVO); | |
| 50 | + void updateUserProfile(Long id, SysUserProfileUpdateReqVO reqVO); | |
| 50 | 51 | |
| 51 | 52 | /** |
| 52 | 53 | * 修改用户个人密码 |
| 53 | 54 | * |
| 55 | + * @param id 用户编号 | |
| 54 | 56 | * @param reqVO 更新用户个人密码 |
| 55 | 57 | */ |
| 56 | - void updateUserPassword(SysUserProfileUpdatePasswordReqVo reqVO); | |
| 57 | - | |
| 58 | + void updateUserPassword(Long id, SysUserProfileUpdatePasswordReqVO reqVO); | |
| 58 | 59 | |
| 59 | 60 | /** |
| 60 | 61 | * 更新用户头像 | ... | ... |
src/main/java/cn/iocoder/dashboard/modules/system/service/user/SysUserServiceImpl.java
| ... | ... | @@ -9,7 +9,7 @@ import cn.iocoder.dashboard.common.exception.ServiceException; |
| 9 | 9 | import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; |
| 10 | 10 | import cn.iocoder.dashboard.common.pojo.PageResult; |
| 11 | 11 | import cn.iocoder.dashboard.modules.infra.service.file.InfFileService; |
| 12 | -import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVo; | |
| 12 | +import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; | |
| 13 | 13 | import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; |
| 14 | 14 | import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserCreateReqVO; |
| 15 | 15 | import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserExportReqVO; |
| ... | ... | @@ -91,22 +91,22 @@ public class SysUserServiceImpl implements SysUserService { |
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | @Override |
| 94 | - public void updateUserProfile(SysUserProfileUpdateReqVO reqVO) { | |
| 94 | + public void updateUserProfile(Long id, SysUserProfileUpdateReqVO reqVO) { | |
| 95 | 95 | // 校验正确性 |
| 96 | - this.checkUserExists(reqVO.getId()); | |
| 97 | - this.checkEmailUnique(reqVO.getId(), reqVO.getEmail()); | |
| 98 | - this.checkMobileUnique(reqVO.getId(), reqVO.getMobile()); | |
| 99 | - userMapper.updateById(SysUserConvert.INSTANCE.convert(reqVO)); | |
| 96 | + this.checkUserExists(id); | |
| 97 | + this.checkEmailUnique(id, reqVO.getEmail()); | |
| 98 | + this.checkMobileUnique(id, reqVO.getMobile()); | |
| 99 | + // 执行更新 | |
| 100 | + userMapper.updateById(SysUserConvert.INSTANCE.convert(reqVO).setId(id)); | |
| 100 | 101 | } |
| 101 | 102 | |
| 102 | 103 | @Override |
| 103 | - public void updateUserPassword(SysUserProfileUpdatePasswordReqVo reqVO) { | |
| 104 | + public void updateUserPassword(Long id, SysUserProfileUpdatePasswordReqVO reqVO) { | |
| 104 | 105 | // 校验旧密码密码 |
| 105 | - this.checkOldPassword(reqVO.getId(), reqVO.getOldPassword()); | |
| 106 | - SysUserDO updateObj = new SysUserDO(); | |
| 107 | - updateObj.setId(reqVO.getId()); | |
| 108 | - // 加密密码 | |
| 109 | - updateObj.setPassword(passwordEncoder.encode(reqVO.getNewPassword())); | |
| 106 | + this.checkOldPassword(id, reqVO.getOldPassword()); | |
| 107 | + // 执行更新 | |
| 108 | + SysUserDO updateObj = new SysUserDO().setId(id); | |
| 109 | + updateObj.setPassword(passwordEncoder.encode(reqVO.getNewPassword())); // 加密密码 | |
| 110 | 110 | userMapper.updateById(updateObj); |
| 111 | 111 | } |
| 112 | 112 | ... | ... |