mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-31 10:18:42 +08:00 
			
		
		
		
	完成用户中心的对接
This commit is contained in:
		| @@ -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 | ||||
|   }) | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -107,8 +107,7 @@ | ||||
|           <el-col :span="12"> | ||||
|             <el-form-item label="归属部门" prop="deptId"> | ||||
|               <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" | ||||
|                           placeholder="请选择归属部门" :normalizer="normalizer" | ||||
|               /> | ||||
|                           placeholder="请选择归属部门" :normalizer="normalizer"/> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|         </el-row> | ||||
| @@ -140,12 +139,7 @@ | ||||
|           <el-col :span="12"> | ||||
|             <el-form-item label="用户性别"> | ||||
|               <el-select v-model="form.sex" placeholder="请选择"> | ||||
|                 <el-option | ||||
|                   v-for="dict in sexDictDatas" | ||||
|                   :key="parseInt(dict.value)" | ||||
|                   :label="dict.label" | ||||
|                   :value="parseInt(dict.value)" | ||||
|                 ></el-option> | ||||
|                 <el-option v-for="dict in sexDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/> | ||||
|               </el-select> | ||||
|             </el-form-item> | ||||
|           </el-col> | ||||
|   | ||||
| @@ -13,11 +13,11 @@ | ||||
|             <ul class="list-group list-group-striped"> | ||||
|               <li class="list-group-item"> | ||||
|                 <svg-icon icon-class="user" />用户名称 | ||||
|                 <div class="pull-right">{{ user.userName }}</div> | ||||
|                 <div class="pull-right">{{ user.username }}</div> | ||||
|               </li> | ||||
|               <li class="list-group-item"> | ||||
|                 <svg-icon icon-class="phone" />手机号码 | ||||
|                 <div class="pull-right">{{ user.phonenumber }}</div> | ||||
|                 <div class="pull-right">{{ user.mobile }}</div> | ||||
|               </li> | ||||
|               <li class="list-group-item"> | ||||
|                 <svg-icon icon-class="email" />用户邮箱 | ||||
| @@ -25,15 +25,19 @@ | ||||
|               </li> | ||||
|               <li class="list-group-item"> | ||||
|                 <svg-icon icon-class="tree" />所属部门 | ||||
|                 <div class="pull-right" v-if="user.dept">{{ user.dept.deptName }} / {{ postGroup }}</div> | ||||
|                 <div class="pull-right" v-if="user.dept">{{ user.dept.name }}</div> | ||||
|               </li> | ||||
|               <li class="list-group-item"> | ||||
|                 <svg-icon icon-class="tree" />所属岗位 | ||||
|                 <div class="pull-right" v-if="user.posts">{{ user.posts.map(post => post.name).join(',') }}</div> | ||||
|               </li> | ||||
|               <li class="list-group-item"> | ||||
|                 <svg-icon icon-class="peoples" />所属角色 | ||||
|                 <div class="pull-right">{{ roleGroup }}</div> | ||||
|                 <div class="pull-right">{{ user.roles.map(post => post.name).join(',') }}</div> | ||||
|               </li> | ||||
|               <li class="list-group-item"> | ||||
|                 <svg-icon icon-class="date" />创建日期 | ||||
|                 <div class="pull-right">{{ user.createTime }}</div> | ||||
|                 <div class="pull-right">{{ parseTime(user.createTime) }}</div> | ||||
|               </li> | ||||
|             </ul> | ||||
|           </div> | ||||
| @@ -82,8 +86,6 @@ export default { | ||||
|     getUser() { | ||||
|       getUserProfile().then(response => { | ||||
|         this.user = response.data; | ||||
|         this.roleGroup = response.roleGroup; | ||||
|         this.postGroup = response.postGroup; | ||||
|       }); | ||||
|     } | ||||
|   } | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
|     <el-form-item label="用户昵称" prop="nickName"> | ||||
|       <el-input v-model="user.nickname" /> | ||||
|     </el-form-item> | ||||
|     <el-form-item label="手机号码" prop="phonenumber"> | ||||
|     <el-form-item label="手机号码" prop="mobile"> | ||||
|       <el-input v-model="user.mobile" maxlength="11" /> | ||||
|     </el-form-item> | ||||
|     <el-form-item label="邮箱" prop="email"> | ||||
|   | ||||
| @@ -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()); | ||||
|     } | ||||
|   | ||||
| @@ -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<SysUserProfileRespVO> profile() { | ||||
|         // 获取用户信息 | ||||
|         Long userId = SecurityFrameworkUtils.getLoginUserId(); | ||||
|         SysUserDO user = userService.getUser(userId); | ||||
|         SysUserProfileRespVO userProfileRespVO = SysUserConvert.INSTANCE.convert03(user); | ||||
|         List<SysRoleDO> 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<SysRoleDO> 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<SysPostDO> posts = postService.getPosts(user.getPostIds()); | ||||
|             resp.setPosts(SysUserConvert.INSTANCE.convertList02(posts)); | ||||
|         } | ||||
|         return success(resp); | ||||
|     } | ||||
|  | ||||
|     @PutMapping("/update") | ||||
|     @ApiOperation("修改用户个人信息") | ||||
|     public CommonResult<Boolean> updateUserProfile(@Valid @RequestBody SysUserProfileUpdateReqVO reqVO, HttpServletRequest request) { | ||||
|         userService.updateUserProfile(reqVO); | ||||
|         SecurityFrameworkUtils.setLoginUser(SysAuthConvert.INSTANCE.convert(reqVO), request); | ||||
|     public CommonResult<Boolean> updateUserProfile(@Valid @RequestBody SysUserProfileUpdateReqVO reqVO) { | ||||
|         userService.updateUserProfile(getLoginUserId(), reqVO); | ||||
|         return success(true); | ||||
|     } | ||||
|  | ||||
|     @PutMapping("/update-password") | ||||
|     @ApiOperation("修改用户个人密码") | ||||
|     public CommonResult<Boolean> updateUserProfilePassword(@Valid @RequestBody SysUserProfileUpdatePasswordReqVo reqVO, HttpServletRequest request) { | ||||
|         userService.updateUserPassword(reqVO); | ||||
|         SecurityFrameworkUtils.setLoginUser(SysAuthConvert.INSTANCE.convert(reqVO), request); | ||||
|     public CommonResult<Boolean> 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); | ||||
|     } | ||||
|  | ||||
|   | ||||
| @@ -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<Role> roles; | ||||
|     private List<Role> roles; | ||||
|  | ||||
|     /** | ||||
|      * 所在部门 | ||||
|      */ | ||||
|     private Dept dept; | ||||
|  | ||||
|     /** | ||||
|      * 所属岗位数组 | ||||
|      */ | ||||
|     private List<Post> 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; | ||||
|  | ||||
|     } | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -6,23 +6,10 @@ import lombok.Data; | ||||
| import org.hibernate.validator.constraints.Length; | ||||
| 
 | ||||
| import javax.validation.constraints.NotEmpty; | ||||
| import javax.validation.constraints.NotNull; | ||||
| 
 | ||||
| /** | ||||
|  * 类名称:SysUserUpdatePersonalPasswordReqVo | ||||
|  * *********************** | ||||
|  * <p> | ||||
|  * 类描述:更新用户个人密码 | ||||
|  * | ||||
|  * @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; | ||||
| 
 | ||||
| } | ||||
| @@ -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; | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -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") | ||||
|   | ||||
| @@ -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("部门") | ||||
|   | ||||
| @@ -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); | ||||
|  | ||||
|     /** | ||||
|      * 将菜单列表,构建成菜单树 | ||||
|   | ||||
| @@ -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<SysUserProfileRespVO.Role> convertList(List<SysRoleDO> list); | ||||
|  | ||||
|     SysUserProfileRespVO.Dept convert02(SysDeptDO bean); | ||||
|  | ||||
|     SysUserDO convert(SysUserProfileUpdateReqVO bean); | ||||
|  | ||||
|     SysUserDO convert(SysUserProfileUpdatePasswordReqVo bean); | ||||
|     SysUserDO convert(SysUserProfileUpdatePasswordReqVO bean); | ||||
|  | ||||
|     List<SysUserProfileRespVO.Post> convertList02(List<SysPostDO> list); | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -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<SysPostDO> getPosts(@Nullable Collection<Long> ids) { | ||||
|         return getPosts(ids, asSet(CommonStatusEnum.ENABLE.getStatus(), CommonStatusEnum.DISABLE.getStatus())); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 获得符合条件的岗位列表 | ||||
|      * | ||||
|   | ||||
| @@ -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); | ||||
|  | ||||
|     /** | ||||
|      * 更新用户头像 | ||||
|   | ||||
| @@ -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); | ||||
|     } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV