From b8857df7fe835115298916a1afe38d50f474c42f Mon Sep 17 00:00:00 2001 From: YunaiV Date: Sun, 21 Mar 2021 18:50:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E7=94=A8=E6=88=B7=E4=B8=AD?= =?UTF-8?q?=E5=BF=83=E7=9A=84=E5=AF=B9=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ruoyi-ui/src/api/system/user.js | 4 +- ruoyi-ui/src/views/system/user/index.vue | 10 +-- .../src/views/system/user/profile/index.vue | 16 ++--- .../views/system/user/profile/userInfo.vue | 2 +- .../framework/redis/config/RedisConfig.java | 10 ++- .../user/SysUserProfileController.java | 63 +++++++++++-------- .../user/vo/profile/SysUserProfileRespVO.java | 41 +++++++++++- ...=> SysUserProfileUpdatePasswordReqVO.java} | 20 ++---- .../vo/profile/SysUserProfileUpdateReqVO.java | 10 +-- .../user/vo/user/SysUserBaseVO.java | 2 +- .../user/vo/user/SysUserPageItemRespVO.java | 2 - .../system/convert/auth/SysAuthConvert.java | 4 +- .../system/convert/user/SysUserConvert.java | 18 +++--- .../system/service/dept/SysPostService.java | 13 ++++ .../system/service/user/SysUserService.java | 9 +-- .../service/user/SysUserServiceImpl.java | 24 +++---- 16 files changed, 145 insertions(+), 103 deletions(-) rename src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/{SysUserProfileUpdatePasswordReqVo.java => SysUserProfileUpdatePasswordReqVO.java} (61%) diff --git a/ruoyi-ui/src/api/system/user.js b/ruoyi-ui/src/api/system/user.js index b1322edd5..cf0f007d5 100644 --- a/ruoyi-ui/src/api/system/user.js +++ b/ruoyi-ui/src/api/system/user.js @@ -104,9 +104,9 @@ export function updateUserPwd(oldPassword, newPassword) { newPassword } return request({ - url: '/system/user/profile/updatePwd', + url: '/system/user/profile/update-password', method: 'put', - params: data + data: data }) } diff --git a/ruoyi-ui/src/views/system/user/index.vue b/ruoyi-ui/src/views/system/user/index.vue index fd0f99e23..8c836c28f 100644 --- a/ruoyi-ui/src/views/system/user/index.vue +++ b/ruoyi-ui/src/views/system/user/index.vue @@ -107,8 +107,7 @@ + placeholder="请选择归属部门" :normalizer="normalizer"/> @@ -140,12 +139,7 @@ - + diff --git a/ruoyi-ui/src/views/system/user/profile/index.vue b/ruoyi-ui/src/views/system/user/profile/index.vue index aa8d9e614..cae5e2e4b 100644 --- a/ruoyi-ui/src/views/system/user/profile/index.vue +++ b/ruoyi-ui/src/views/system/user/profile/index.vue @@ -13,11 +13,11 @@ @@ -82,8 +86,6 @@ export default { getUser() { getUserProfile().then(response => { this.user = response.data; - this.roleGroup = response.roleGroup; - this.postGroup = response.postGroup; }); } } diff --git a/ruoyi-ui/src/views/system/user/profile/userInfo.vue b/ruoyi-ui/src/views/system/user/profile/userInfo.vue index 47dea61de..3aea8bcd5 100644 --- a/ruoyi-ui/src/views/system/user/profile/userInfo.vue +++ b/ruoyi-ui/src/views/system/user/profile/userInfo.vue @@ -3,7 +3,7 @@ - + diff --git a/src/main/java/cn/iocoder/dashboard/framework/redis/config/RedisConfig.java b/src/main/java/cn/iocoder/dashboard/framework/redis/config/RedisConfig.java index f398625ea..432d5618c 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/redis/config/RedisConfig.java +++ b/src/main/java/cn/iocoder/dashboard/framework/redis/config/RedisConfig.java @@ -83,8 +83,8 @@ public class RedisConfig { redisTemplate.getRequiredConnectionFactory(), containerOptions); // 第二步,注册监听器,消费对应的 Stream 主题 -// String consumerName = buildConsumerName(); - String consumerName = "110"; + String consumerName = buildConsumerName(); +// String consumerName = "110"; listeners.forEach(listener -> { // 创建 listener 对应的消费者分组 try { @@ -106,6 +106,12 @@ public class RedisConfig { return container; } + /** + * 构建消费者名字,使用本地 IP + 进程编号的方式。 + * 参考自 RocketMQ clientId 的实现 + * + * @return 消费者名字 + */ private static String buildConsumerName() { return String.format("%s@%d", SystemUtil.getHostInfo().getAddress(), SystemUtil.getCurrentPID()); } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/SysUserProfileController.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/SysUserProfileController.java index 2bb6c8556..a1b8b0cb9 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/SysUserProfileController.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/SysUserProfileController.java @@ -1,51 +1,54 @@ package cn.iocoder.dashboard.modules.system.controller.user; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; import cn.iocoder.dashboard.common.pojo.CommonResult; -import cn.iocoder.dashboard.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileRespVO; -import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVo; +import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; -import cn.iocoder.dashboard.modules.system.convert.auth.SysAuthConvert; import cn.iocoder.dashboard.modules.system.convert.user.SysUserConvert; +import cn.iocoder.dashboard.modules.system.dal.dataobject.dept.SysDeptDO; +import cn.iocoder.dashboard.modules.system.dal.dataobject.dept.SysPostDO; import cn.iocoder.dashboard.modules.system.dal.dataobject.permission.SysRoleDO; import cn.iocoder.dashboard.modules.system.dal.dataobject.user.SysUserDO; +import cn.iocoder.dashboard.modules.system.service.dept.SysDeptService; +import cn.iocoder.dashboard.modules.system.service.dept.SysPostService; import cn.iocoder.dashboard.modules.system.service.permission.SysPermissionService; import cn.iocoder.dashboard.modules.system.service.permission.SysRoleService; import cn.iocoder.dashboard.modules.system.service.user.SysUserService; -import cn.iocoder.dashboard.util.collection.CollectionUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; import javax.validation.Valid; import java.io.IOException; import java.util.List; import static cn.iocoder.dashboard.common.pojo.CommonResult.success; +import static cn.iocoder.dashboard.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.FILE_IS_EMPTY; /** * @author niudehua */ +@Api(tags = "用户个人中心") @RestController @RequestMapping("/system/user/profile") -@Api(tags = "用户个人中心") +@Validated @Slf4j public class SysUserProfileController { @Resource private SysUserService userService; @Resource + private SysDeptService deptService; + @Resource + private SysPostService postService; + @Resource private SysPermissionService permissionService; @Resource private SysRoleService roleService; @@ -53,28 +56,36 @@ public class SysUserProfileController { @GetMapping("/get") @ApiOperation("获得登录用户信息") public CommonResult profile() { - // 获取用户信息 - Long userId = SecurityFrameworkUtils.getLoginUserId(); - SysUserDO user = userService.getUser(userId); - SysUserProfileRespVO userProfileRespVO = SysUserConvert.INSTANCE.convert03(user); - List userRoles = roleService.getRolesFromCache(permissionService.listUserRoleIs(userId)); - userProfileRespVO.setRoles(CollectionUtils.convertSet(userRoles, SysUserConvert.INSTANCE::convert)); - return success(userProfileRespVO); + // 获得用户基本信息 + SysUserDO user = userService.getUser(getLoginUserId()); + SysUserProfileRespVO resp = SysUserConvert.INSTANCE.convert03(user); + // 获得用户角色 + List userRoles = roleService.getRolesFromCache(permissionService.listUserRoleIs(user.getId())); + resp.setRoles(SysUserConvert.INSTANCE.convertList(userRoles)); + // 获得部门信息 + if (user.getDeptId() != null) { + SysDeptDO dept = deptService.getDept(user.getDeptId()); + resp.setDept(SysUserConvert.INSTANCE.convert02(dept)); + } + // 获得岗位信息 + if (CollUtil.isNotEmpty(user.getPostIds())) { + List posts = postService.getPosts(user.getPostIds()); + resp.setPosts(SysUserConvert.INSTANCE.convertList02(posts)); + } + return success(resp); } @PutMapping("/update") @ApiOperation("修改用户个人信息") - public CommonResult updateUserProfile(@Valid @RequestBody SysUserProfileUpdateReqVO reqVO, HttpServletRequest request) { - userService.updateUserProfile(reqVO); - SecurityFrameworkUtils.setLoginUser(SysAuthConvert.INSTANCE.convert(reqVO), request); + public CommonResult updateUserProfile(@Valid @RequestBody SysUserProfileUpdateReqVO reqVO) { + userService.updateUserProfile(getLoginUserId(), reqVO); return success(true); } @PutMapping("/update-password") @ApiOperation("修改用户个人密码") - public CommonResult updateUserProfilePassword(@Valid @RequestBody SysUserProfileUpdatePasswordReqVo reqVO, HttpServletRequest request) { - userService.updateUserPassword(reqVO); - SecurityFrameworkUtils.setLoginUser(SysAuthConvert.INSTANCE.convert(reqVO), request); + public CommonResult updateUserProfilePassword(@Valid @RequestBody SysUserProfileUpdatePasswordReqVO reqVO) { + userService.updateUserPassword(getLoginUserId(), reqVO); return success(true); } @@ -84,7 +95,7 @@ public class SysUserProfileController { if (file.isEmpty()) { throw ServiceExceptionUtil.exception(FILE_IS_EMPTY); } - userService.updateUserAvatar(SecurityFrameworkUtils.getLoginUserId(), file.getInputStream()); + userService.updateUserAvatar(getLoginUserId(), file.getInputStream()); return success(true); } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileRespVO.java index 954f14e3c..de264b105 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileRespVO.java @@ -9,7 +9,7 @@ import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import java.util.Date; -import java.util.Set; +import java.util.List; @Data @@ -18,6 +18,7 @@ import java.util.Set; @AllArgsConstructor @ApiModel("用户个人中心信息 Response VO") public class SysUserProfileRespVO extends SysUserBaseVO { + @ApiModelProperty(value = "用户编号", required = true, example = "1") private Long id; @@ -36,8 +37,17 @@ public class SysUserProfileRespVO extends SysUserBaseVO { /** * 所属角色 */ - @ApiModelProperty(value = "所属角色", required = true, example = "123456") - private Set roles; + private List roles; + + /** + * 所在部门 + */ + private Dept dept; + + /** + * 所属岗位数组 + */ + private List posts; @ApiModel("角色") @Data @@ -50,4 +60,29 @@ public class SysUserProfileRespVO extends SysUserBaseVO { private String name; } + + @ApiModel("部门") + @Data + public static class Dept { + + @ApiModelProperty(value = "部门编号", required = true, example = "1") + private Long id; + + @ApiModelProperty(value = "部门名称", required = true, example = "研发部") + private String name; + + } + + @ApiModel("岗位") + @Data + public static class Post { + + @ApiModelProperty(value = "岗位编号", required = true, example = "1") + private Long id; + + @ApiModelProperty(value = "岗位名称", required = true, example = "开发") + private String name; + + } + } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileUpdatePasswordReqVo.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileUpdatePasswordReqVO.java similarity index 61% rename from src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileUpdatePasswordReqVo.java rename to src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileUpdatePasswordReqVO.java index a98d4641b..6ff56487a 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileUpdatePasswordReqVo.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileUpdatePasswordReqVO.java @@ -6,23 +6,10 @@ import lombok.Data; import org.hibernate.validator.constraints.Length; import javax.validation.constraints.NotEmpty; -import javax.validation.constraints.NotNull; -/** - * 类名称:SysUserUpdatePersonalPasswordReqVo - * *********************** - *

- * 类描述:更新用户个人密码 - * - * @author deng on 2021/3/15 22:04 - */ -@ApiModel("用户个人中心更新密码 Response VO") +@ApiModel("用户个人中心更新密码 Request VO") @Data -public class SysUserProfileUpdatePasswordReqVo { - - @ApiModelProperty(value = "用户编号", required = true, example = "1024") - @NotNull(message = "用户编号不能为空") - private Long id; +public class SysUserProfileUpdatePasswordReqVO { @ApiModelProperty(value = "旧密码", required = true, example = "123456") @NotEmpty(message = "旧密码不能为空") @@ -33,4 +20,5 @@ public class SysUserProfileUpdatePasswordReqVo { @NotEmpty(message = "新密码不能为空") @Length(min = 4, max = 16, message = "密码长度为 4-16 位") private String newPassword; -} \ No newline at end of file + +} diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileUpdateReqVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileUpdateReqVO.java index bb8b5c4bf..1f02e553f 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileUpdateReqVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/profile/SysUserProfileUpdateReqVO.java @@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModelProperty; import lombok.Data; import javax.validation.constraints.Email; -import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import javax.validation.constraints.Size; @@ -13,17 +12,13 @@ import javax.validation.constraints.Size; @Data public class SysUserProfileUpdateReqVO { - @ApiModelProperty(value = "用户编号", required = true, example = "1024") - @NotNull(message = "用户编号不能为空") - private Long id; - @ApiModelProperty(value = "用户昵称", required = true, example = "芋艿") @Size(max = 30, message = "用户昵称长度不能超过30个字符") private String nickname; @ApiModelProperty(value = "用户邮箱", example = "yudao@iocoder.cn") @Email(message = "邮箱格式不正确") - @Size(max = 50, message = "邮箱长度不能超过50个字符") + @Size(max = 50, message = "邮箱长度不能超过 50 个字符") private String email; @ApiModelProperty(value = "手机号码", example = "15601691300") @@ -33,7 +28,4 @@ public class SysUserProfileUpdateReqVO { @ApiModelProperty(value = "用户性别", example = "1", notes = "参见 SysSexEnum 枚举类") private Integer sex; - @ApiModelProperty(value = "用户头像", example = "http://www.iocoder.cn/xxx.png") - private String avatar; - } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserBaseVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserBaseVO.java index 619f11f31..7361bb342 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserBaseVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserBaseVO.java @@ -36,7 +36,7 @@ public class SysUserBaseVO { @ApiModelProperty(value = "用户邮箱", example = "yudao@iocoder.cn") @Email(message = "邮箱格式不正确") - @Size(max = 50, message = "邮箱长度不能超过50个字符") + @Size(max = 50, message = "邮箱长度不能超过 50 个字符") private String email; @ApiModelProperty(value = "手机号码", example = "15601691300") diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserPageItemRespVO.java b/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserPageItemRespVO.java index 9fdcf033c..dc6963c58 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserPageItemRespVO.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/controller/user/vo/user/SysUserPageItemRespVO.java @@ -1,6 +1,5 @@ package cn.iocoder.dashboard.modules.system.controller.user.vo.user; -import com.fasterxml.jackson.annotation.JsonIgnore; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.AllArgsConstructor; @@ -18,7 +17,6 @@ public class SysUserPageItemRespVO extends SysUserRespVO { /** * 所在部门 */ - @JsonIgnore private Dept dept; @ApiModel("部门") diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/convert/auth/SysAuthConvert.java b/src/main/java/cn/iocoder/dashboard/modules/system/convert/auth/SysAuthConvert.java index 12f406604..48c909534 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/convert/auth/SysAuthConvert.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/convert/auth/SysAuthConvert.java @@ -3,7 +3,7 @@ package cn.iocoder.dashboard.modules.system.convert.auth; import cn.iocoder.dashboard.framework.security.core.LoginUser; import cn.iocoder.dashboard.modules.system.controller.auth.vo.auth.SysAuthMenuRespVO; import cn.iocoder.dashboard.modules.system.controller.auth.vo.auth.SysAuthPermissionInfoRespVO; -import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVo; +import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; import cn.iocoder.dashboard.modules.system.dal.dataobject.permission.SysMenuDO; import cn.iocoder.dashboard.modules.system.dal.dataobject.permission.SysRoleDO; @@ -42,7 +42,7 @@ public interface SysAuthConvert { LoginUser convert(SysUserProfileUpdateReqVO reqVO); - LoginUser convert(SysUserProfileUpdatePasswordReqVo reqVO); + LoginUser convert(SysUserProfileUpdatePasswordReqVO reqVO); /** * 将菜单列表,构建成菜单树 diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/convert/user/SysUserConvert.java b/src/main/java/cn/iocoder/dashboard/modules/system/convert/user/SysUserConvert.java index aeaec2be8..fd4a8b9d3 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/convert/user/SysUserConvert.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/convert/user/SysUserConvert.java @@ -1,19 +1,18 @@ package cn.iocoder.dashboard.modules.system.convert.user; import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileRespVO; -import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVo; +import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; -import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserCreateReqVO; -import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserExcelVO; -import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserImportExcelVO; -import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserPageItemRespVO; -import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserUpdateReqVO; +import cn.iocoder.dashboard.modules.system.controller.user.vo.user.*; import cn.iocoder.dashboard.modules.system.dal.dataobject.dept.SysDeptDO; +import cn.iocoder.dashboard.modules.system.dal.dataobject.dept.SysPostDO; import cn.iocoder.dashboard.modules.system.dal.dataobject.permission.SysRoleDO; import cn.iocoder.dashboard.modules.system.dal.dataobject.user.SysUserDO; import org.mapstruct.Mapper; import org.mapstruct.factory.Mappers; +import java.util.List; + @Mapper public interface SysUserConvert { @@ -33,11 +32,14 @@ public interface SysUserConvert { SysUserProfileRespVO convert03(SysUserDO bean); - SysUserProfileRespVO.Role convert(SysRoleDO bean); + List convertList(List list); + + SysUserProfileRespVO.Dept convert02(SysDeptDO bean); SysUserDO convert(SysUserProfileUpdateReqVO bean); - SysUserDO convert(SysUserProfileUpdatePasswordReqVo bean); + SysUserDO convert(SysUserProfileUpdatePasswordReqVO bean); + List convertList02(List list); } diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysPostService.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysPostService.java index b4cca1ab1..78a96ce29 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysPostService.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/dept/SysPostService.java @@ -1,5 +1,6 @@ package cn.iocoder.dashboard.modules.system.service.dept; +import cn.iocoder.dashboard.common.enums.CommonStatusEnum; import cn.iocoder.dashboard.common.pojo.PageResult; import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostCreateReqVO; import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostExportReqVO; @@ -11,6 +12,8 @@ import org.springframework.lang.Nullable; import java.util.Collection; import java.util.List; +import static cn.iocoder.dashboard.util.collection.SetUtils.asSet; + /** * 岗位 Service 接口 * @@ -40,6 +43,16 @@ public interface SysPostService { */ void deletePost(Long id); + /** + * 获得岗位列表 + * + * @param ids 岗位编号数组。如果为空,不进行筛选 + * @return 部门列表 + */ + default List getPosts(@Nullable Collection ids) { + return getPosts(ids, asSet(CommonStatusEnum.ENABLE.getStatus(), CommonStatusEnum.DISABLE.getStatus())); + } + /** * 获得符合条件的岗位列表 * diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/user/SysUserService.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/user/SysUserService.java index 752da68d8..5ef26ebc5 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/user/SysUserService.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/user/SysUserService.java @@ -2,7 +2,7 @@ package cn.iocoder.dashboard.modules.system.service.user; import cn.hutool.core.collection.CollUtil; import cn.iocoder.dashboard.common.pojo.PageResult; -import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVo; +import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserCreateReqVO; import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserExportReqVO; @@ -44,17 +44,18 @@ public interface SysUserService { /** * 修改用户个人信息 * + * @param id 用户编号 * @param reqVO 用户个人信息 */ - void updateUserProfile(SysUserProfileUpdateReqVO reqVO); + void updateUserProfile(Long id, SysUserProfileUpdateReqVO reqVO); /** * 修改用户个人密码 * + * @param id 用户编号 * @param reqVO 更新用户个人密码 */ - void updateUserPassword(SysUserProfileUpdatePasswordReqVo reqVO); - + void updateUserPassword(Long id, SysUserProfileUpdatePasswordReqVO reqVO); /** * 更新用户头像 diff --git a/src/main/java/cn/iocoder/dashboard/modules/system/service/user/SysUserServiceImpl.java b/src/main/java/cn/iocoder/dashboard/modules/system/service/user/SysUserServiceImpl.java index f3b79274c..88997dfa0 100644 --- a/src/main/java/cn/iocoder/dashboard/modules/system/service/user/SysUserServiceImpl.java +++ b/src/main/java/cn/iocoder/dashboard/modules/system/service/user/SysUserServiceImpl.java @@ -9,7 +9,7 @@ import cn.iocoder.dashboard.common.exception.ServiceException; import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; import cn.iocoder.dashboard.common.pojo.PageResult; import cn.iocoder.dashboard.modules.infra.service.file.InfFileService; -import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVo; +import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdatePasswordReqVO; import cn.iocoder.dashboard.modules.system.controller.user.vo.profile.SysUserProfileUpdateReqVO; import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserCreateReqVO; import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserExportReqVO; @@ -91,22 +91,22 @@ public class SysUserServiceImpl implements SysUserService { } @Override - public void updateUserProfile(SysUserProfileUpdateReqVO reqVO) { + public void updateUserProfile(Long id, SysUserProfileUpdateReqVO reqVO) { // 校验正确性 - this.checkUserExists(reqVO.getId()); - this.checkEmailUnique(reqVO.getId(), reqVO.getEmail()); - this.checkMobileUnique(reqVO.getId(), reqVO.getMobile()); - userMapper.updateById(SysUserConvert.INSTANCE.convert(reqVO)); + this.checkUserExists(id); + this.checkEmailUnique(id, reqVO.getEmail()); + this.checkMobileUnique(id, reqVO.getMobile()); + // 执行更新 + userMapper.updateById(SysUserConvert.INSTANCE.convert(reqVO).setId(id)); } @Override - public void updateUserPassword(SysUserProfileUpdatePasswordReqVo reqVO) { + public void updateUserPassword(Long id, SysUserProfileUpdatePasswordReqVO reqVO) { // 校验旧密码密码 - this.checkOldPassword(reqVO.getId(), reqVO.getOldPassword()); - SysUserDO updateObj = new SysUserDO(); - updateObj.setId(reqVO.getId()); - // 加密密码 - updateObj.setPassword(passwordEncoder.encode(reqVO.getNewPassword())); + this.checkOldPassword(id, reqVO.getOldPassword()); + // 执行更新 + SysUserDO updateObj = new SysUserDO().setId(id); + updateObj.setPassword(passwordEncoder.encode(reqVO.getNewPassword())); // 加密密码 userMapper.updateById(updateObj); }