完成用户中心的对接

pull/2/head
YunaiV 2021-03-21 18:50:36 +08:00
parent d6cc9e23a3
commit b8857df7fe
16 changed files with 145 additions and 103 deletions

View File

@ -104,9 +104,9 @@ export function updateUserPwd(oldPassword, newPassword) {
newPassword newPassword
} }
return request({ return request({
url: '/system/user/profile/updatePwd', url: '/system/user/profile/update-password',
method: 'put', method: 'put',
params: data data: data
}) })
} }

View File

@ -107,8 +107,7 @@
<el-col :span="12"> <el-col :span="12">
<el-form-item label="归属部门" prop="deptId"> <el-form-item label="归属部门" prop="deptId">
<treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" <treeselect v-model="form.deptId" :options="deptOptions" :show-count="true"
placeholder="请选择归属部门" :normalizer="normalizer" placeholder="请选择归属部门" :normalizer="normalizer"/>
/>
</el-form-item> </el-form-item>
</el-col> </el-col>
</el-row> </el-row>
@ -140,12 +139,7 @@
<el-col :span="12"> <el-col :span="12">
<el-form-item label="用户性别"> <el-form-item label="用户性别">
<el-select v-model="form.sex" placeholder="请选择"> <el-select v-model="form.sex" placeholder="请选择">
<el-option <el-option v-for="dict in sexDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
v-for="dict in sexDictDatas"
:key="parseInt(dict.value)"
:label="dict.label"
:value="parseInt(dict.value)"
></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
</el-col> </el-col>

View File

@ -13,11 +13,11 @@
<ul class="list-group list-group-striped"> <ul class="list-group list-group-striped">
<li class="list-group-item"> <li class="list-group-item">
<svg-icon icon-class="user" />用户名称 <svg-icon icon-class="user" />用户名称
<div class="pull-right">{{ user.userName }}</div> <div class="pull-right">{{ user.username }}</div>
</li> </li>
<li class="list-group-item"> <li class="list-group-item">
<svg-icon icon-class="phone" />手机号码 <svg-icon icon-class="phone" />手机号码
<div class="pull-right">{{ user.phonenumber }}</div> <div class="pull-right">{{ user.mobile }}</div>
</li> </li>
<li class="list-group-item"> <li class="list-group-item">
<svg-icon icon-class="email" />用户邮箱 <svg-icon icon-class="email" />用户邮箱
@ -25,15 +25,19 @@
</li> </li>
<li class="list-group-item"> <li class="list-group-item">
<svg-icon icon-class="tree" />所属部门 <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>
<li class="list-group-item"> <li class="list-group-item">
<svg-icon icon-class="peoples" />所属角色 <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>
<li class="list-group-item"> <li class="list-group-item">
<svg-icon icon-class="date" />创建日期 <svg-icon icon-class="date" />创建日期
<div class="pull-right">{{ user.createTime }}</div> <div class="pull-right">{{ parseTime(user.createTime) }}</div>
</li> </li>
</ul> </ul>
</div> </div>
@ -82,8 +86,6 @@ export default {
getUser() { getUser() {
getUserProfile().then(response => { getUserProfile().then(response => {
this.user = response.data; this.user = response.data;
this.roleGroup = response.roleGroup;
this.postGroup = response.postGroup;
}); });
} }
} }

View File

@ -3,7 +3,7 @@
<el-form-item label="用户昵称" prop="nickName"> <el-form-item label="用户昵称" prop="nickName">
<el-input v-model="user.nickname" /> <el-input v-model="user.nickname" />
</el-form-item> </el-form-item>
<el-form-item label="手机号码" prop="phonenumber"> <el-form-item label="手机号码" prop="mobile">
<el-input v-model="user.mobile" maxlength="11" /> <el-input v-model="user.mobile" maxlength="11" />
</el-form-item> </el-form-item>
<el-form-item label="邮箱" prop="email"> <el-form-item label="邮箱" prop="email">

View File

@ -83,8 +83,8 @@ public class RedisConfig {
redisTemplate.getRequiredConnectionFactory(), containerOptions); redisTemplate.getRequiredConnectionFactory(), containerOptions);
// 第二步,注册监听器,消费对应的 Stream 主题 // 第二步,注册监听器,消费对应的 Stream 主题
// String consumerName = buildConsumerName(); String consumerName = buildConsumerName();
String consumerName = "110"; // String consumerName = "110";
listeners.forEach(listener -> { listeners.forEach(listener -> {
// 创建 listener 对应的消费者分组 // 创建 listener 对应的消费者分组
try { try {
@ -106,6 +106,12 @@ public class RedisConfig {
return container; return container;
} }
/**
* 使 IP +
* RocketMQ clientId
*
* @return
*/
private static String buildConsumerName() { private static String buildConsumerName() {
return String.format("%s@%d", SystemUtil.getHostInfo().getAddress(), SystemUtil.getCurrentPID()); return String.format("%s@%d", SystemUtil.getHostInfo().getAddress(), SystemUtil.getCurrentPID());
} }

View File

@ -1,51 +1,54 @@
package cn.iocoder.dashboard.modules.system.controller.user; 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.exception.util.ServiceExceptionUtil;
import cn.iocoder.dashboard.common.pojo.CommonResult; 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.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.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.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.permission.SysRoleDO;
import cn.iocoder.dashboard.modules.system.dal.dataobject.user.SysUserDO; 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.SysPermissionService;
import cn.iocoder.dashboard.modules.system.service.permission.SysRoleService; import cn.iocoder.dashboard.modules.system.service.permission.SysRoleService;
import cn.iocoder.dashboard.modules.system.service.user.SysUserService; 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.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.*;
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.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid; import javax.validation.Valid;
import java.io.IOException; import java.io.IOException;
import java.util.List; import java.util.List;
import static cn.iocoder.dashboard.common.pojo.CommonResult.success; 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; import static cn.iocoder.dashboard.modules.system.enums.SysErrorCodeConstants.FILE_IS_EMPTY;
/** /**
* @author niudehua * @author niudehua
*/ */
@Api(tags = "用户个人中心")
@RestController @RestController
@RequestMapping("/system/user/profile") @RequestMapping("/system/user/profile")
@Api(tags = "用户个人中心") @Validated
@Slf4j @Slf4j
public class SysUserProfileController { public class SysUserProfileController {
@Resource @Resource
private SysUserService userService; private SysUserService userService;
@Resource @Resource
private SysDeptService deptService;
@Resource
private SysPostService postService;
@Resource
private SysPermissionService permissionService; private SysPermissionService permissionService;
@Resource @Resource
private SysRoleService roleService; private SysRoleService roleService;
@ -53,28 +56,36 @@ public class SysUserProfileController {
@GetMapping("/get") @GetMapping("/get")
@ApiOperation("获得登录用户信息") @ApiOperation("获得登录用户信息")
public CommonResult<SysUserProfileRespVO> profile() { public CommonResult<SysUserProfileRespVO> profile() {
// 获取用户信息 // 获得用户基本信息
Long userId = SecurityFrameworkUtils.getLoginUserId(); SysUserDO user = userService.getUser(getLoginUserId());
SysUserDO user = userService.getUser(userId); SysUserProfileRespVO resp = SysUserConvert.INSTANCE.convert03(user);
SysUserProfileRespVO userProfileRespVO = SysUserConvert.INSTANCE.convert03(user); // 获得用户角色
List<SysRoleDO> userRoles = roleService.getRolesFromCache(permissionService.listUserRoleIs(userId)); List<SysRoleDO> userRoles = roleService.getRolesFromCache(permissionService.listUserRoleIs(user.getId()));
userProfileRespVO.setRoles(CollectionUtils.convertSet(userRoles, SysUserConvert.INSTANCE::convert)); resp.setRoles(SysUserConvert.INSTANCE.convertList(userRoles));
return success(userProfileRespVO); // 获得部门信息
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") @PutMapping("/update")
@ApiOperation("修改用户个人信息") @ApiOperation("修改用户个人信息")
public CommonResult<Boolean> updateUserProfile(@Valid @RequestBody SysUserProfileUpdateReqVO reqVO, HttpServletRequest request) { public CommonResult<Boolean> updateUserProfile(@Valid @RequestBody SysUserProfileUpdateReqVO reqVO) {
userService.updateUserProfile(reqVO); userService.updateUserProfile(getLoginUserId(), reqVO);
SecurityFrameworkUtils.setLoginUser(SysAuthConvert.INSTANCE.convert(reqVO), request);
return success(true); return success(true);
} }
@PutMapping("/update-password") @PutMapping("/update-password")
@ApiOperation("修改用户个人密码") @ApiOperation("修改用户个人密码")
public CommonResult<Boolean> updateUserProfilePassword(@Valid @RequestBody SysUserProfileUpdatePasswordReqVo reqVO, HttpServletRequest request) { public CommonResult<Boolean> updateUserProfilePassword(@Valid @RequestBody SysUserProfileUpdatePasswordReqVO reqVO) {
userService.updateUserPassword(reqVO); userService.updateUserPassword(getLoginUserId(), reqVO);
SecurityFrameworkUtils.setLoginUser(SysAuthConvert.INSTANCE.convert(reqVO), request);
return success(true); return success(true);
} }
@ -84,7 +95,7 @@ public class SysUserProfileController {
if (file.isEmpty()) { if (file.isEmpty()) {
throw ServiceExceptionUtil.exception(FILE_IS_EMPTY); throw ServiceExceptionUtil.exception(FILE_IS_EMPTY);
} }
userService.updateUserAvatar(SecurityFrameworkUtils.getLoginUserId(), file.getInputStream()); userService.updateUserAvatar(getLoginUserId(), file.getInputStream());
return success(true); return success(true);
} }

View File

@ -9,7 +9,7 @@ import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import java.util.Date; import java.util.Date;
import java.util.Set; import java.util.List;
@Data @Data
@ -18,6 +18,7 @@ import java.util.Set;
@AllArgsConstructor @AllArgsConstructor
@ApiModel("用户个人中心信息 Response VO") @ApiModel("用户个人中心信息 Response VO")
public class SysUserProfileRespVO extends SysUserBaseVO { public class SysUserProfileRespVO extends SysUserBaseVO {
@ApiModelProperty(value = "用户编号", required = true, example = "1") @ApiModelProperty(value = "用户编号", required = true, example = "1")
private Long id; private Long id;
@ -36,8 +37,17 @@ public class SysUserProfileRespVO extends SysUserBaseVO {
/** /**
* *
*/ */
@ApiModelProperty(value = "所属角色", required = true, example = "123456") private List<Role> roles;
private Set<Role> roles;
/**
*
*/
private Dept dept;
/**
*
*/
private List<Post> posts;
@ApiModel("角色") @ApiModel("角色")
@Data @Data
@ -50,4 +60,29 @@ public class SysUserProfileRespVO extends SysUserBaseVO {
private String name; 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;
}
} }

View File

@ -6,23 +6,10 @@ import lombok.Data;
import org.hibernate.validator.constraints.Length; import org.hibernate.validator.constraints.Length;
import javax.validation.constraints.NotEmpty; import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
/** @ApiModel("用户个人中心更新密码 Request VO")
* SysUserUpdatePersonalPasswordReqVo
* ***********************
* <p>
*
*
* @author deng on 2021/3/15 22:04
*/
@ApiModel("用户个人中心更新密码 Response VO")
@Data @Data
public class SysUserProfileUpdatePasswordReqVo { public class SysUserProfileUpdatePasswordReqVO {
@ApiModelProperty(value = "用户编号", required = true, example = "1024")
@NotNull(message = "用户编号不能为空")
private Long id;
@ApiModelProperty(value = "旧密码", required = true, example = "123456") @ApiModelProperty(value = "旧密码", required = true, example = "123456")
@NotEmpty(message = "旧密码不能为空") @NotEmpty(message = "旧密码不能为空")
@ -33,4 +20,5 @@ public class SysUserProfileUpdatePasswordReqVo {
@NotEmpty(message = "新密码不能为空") @NotEmpty(message = "新密码不能为空")
@Length(min = 4, max = 16, message = "密码长度为 4-16 位") @Length(min = 4, max = 16, message = "密码长度为 4-16 位")
private String newPassword; private String newPassword;
} }

View File

@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.Email; import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size; import javax.validation.constraints.Size;
@ -13,17 +12,13 @@ import javax.validation.constraints.Size;
@Data @Data
public class SysUserProfileUpdateReqVO { public class SysUserProfileUpdateReqVO {
@ApiModelProperty(value = "用户编号", required = true, example = "1024")
@NotNull(message = "用户编号不能为空")
private Long id;
@ApiModelProperty(value = "用户昵称", required = true, example = "芋艿") @ApiModelProperty(value = "用户昵称", required = true, example = "芋艿")
@Size(max = 30, message = "用户昵称长度不能超过30个字符") @Size(max = 30, message = "用户昵称长度不能超过30个字符")
private String nickname; private String nickname;
@ApiModelProperty(value = "用户邮箱", example = "yudao@iocoder.cn") @ApiModelProperty(value = "用户邮箱", example = "yudao@iocoder.cn")
@Email(message = "邮箱格式不正确") @Email(message = "邮箱格式不正确")
@Size(max = 50, message = "邮箱长度不能超过50个字符") @Size(max = 50, message = "邮箱长度不能超过 50 个字符")
private String email; private String email;
@ApiModelProperty(value = "手机号码", example = "15601691300") @ApiModelProperty(value = "手机号码", example = "15601691300")
@ -33,7 +28,4 @@ public class SysUserProfileUpdateReqVO {
@ApiModelProperty(value = "用户性别", example = "1", notes = "参见 SysSexEnum 枚举类") @ApiModelProperty(value = "用户性别", example = "1", notes = "参见 SysSexEnum 枚举类")
private Integer sex; private Integer sex;
@ApiModelProperty(value = "用户头像", example = "http://www.iocoder.cn/xxx.png")
private String avatar;
} }

View File

@ -36,7 +36,7 @@ public class SysUserBaseVO {
@ApiModelProperty(value = "用户邮箱", example = "yudao@iocoder.cn") @ApiModelProperty(value = "用户邮箱", example = "yudao@iocoder.cn")
@Email(message = "邮箱格式不正确") @Email(message = "邮箱格式不正确")
@Size(max = 50, message = "邮箱长度不能超过50个字符") @Size(max = 50, message = "邮箱长度不能超过 50 个字符")
private String email; private String email;
@ApiModelProperty(value = "手机号码", example = "15601691300") @ApiModelProperty(value = "手机号码", example = "15601691300")

View File

@ -1,6 +1,5 @@
package cn.iocoder.dashboard.modules.system.controller.user.vo.user; 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.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -18,7 +17,6 @@ public class SysUserPageItemRespVO extends SysUserRespVO {
/** /**
* *
*/ */
@JsonIgnore
private Dept dept; private Dept dept;
@ApiModel("部门") @ApiModel("部门")

View File

@ -3,7 +3,7 @@ package cn.iocoder.dashboard.modules.system.convert.auth;
import cn.iocoder.dashboard.framework.security.core.LoginUser; 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.SysAuthMenuRespVO;
import cn.iocoder.dashboard.modules.system.controller.auth.vo.auth.SysAuthPermissionInfoRespVO; 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.controller.user.vo.profile.SysUserProfileUpdateReqVO;
import cn.iocoder.dashboard.modules.system.dal.dataobject.permission.SysMenuDO; import cn.iocoder.dashboard.modules.system.dal.dataobject.permission.SysMenuDO;
import cn.iocoder.dashboard.modules.system.dal.dataobject.permission.SysRoleDO; import cn.iocoder.dashboard.modules.system.dal.dataobject.permission.SysRoleDO;
@ -42,7 +42,7 @@ public interface SysAuthConvert {
LoginUser convert(SysUserProfileUpdateReqVO reqVO); LoginUser convert(SysUserProfileUpdateReqVO reqVO);
LoginUser convert(SysUserProfileUpdatePasswordReqVo reqVO); LoginUser convert(SysUserProfileUpdatePasswordReqVO reqVO);
/** /**
* *

View File

@ -1,19 +1,18 @@
package cn.iocoder.dashboard.modules.system.convert.user; 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.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.profile.SysUserProfileUpdateReqVO;
import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserCreateReqVO; import cn.iocoder.dashboard.modules.system.controller.user.vo.user.*;
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.dal.dataobject.dept.SysDeptDO; 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.permission.SysRoleDO;
import cn.iocoder.dashboard.modules.system.dal.dataobject.user.SysUserDO; import cn.iocoder.dashboard.modules.system.dal.dataobject.user.SysUserDO;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import java.util.List;
@Mapper @Mapper
public interface SysUserConvert { public interface SysUserConvert {
@ -33,11 +32,14 @@ public interface SysUserConvert {
SysUserProfileRespVO convert03(SysUserDO bean); 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(SysUserProfileUpdateReqVO bean);
SysUserDO convert(SysUserProfileUpdatePasswordReqVo bean); SysUserDO convert(SysUserProfileUpdatePasswordReqVO bean);
List<SysUserProfileRespVO.Post> convertList02(List<SysPostDO> list);
} }

View File

@ -1,5 +1,6 @@
package cn.iocoder.dashboard.modules.system.service.dept; 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.common.pojo.PageResult;
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostCreateReqVO; import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostCreateReqVO;
import cn.iocoder.dashboard.modules.system.controller.dept.vo.post.SysPostExportReqVO; 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.Collection;
import java.util.List; import java.util.List;
import static cn.iocoder.dashboard.util.collection.SetUtils.asSet;
/** /**
* Service * Service
* *
@ -40,6 +43,16 @@ public interface SysPostService {
*/ */
void deletePost(Long id); 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()));
}
/** /**
* *
* *

View File

@ -2,7 +2,7 @@ package cn.iocoder.dashboard.modules.system.service.user;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.iocoder.dashboard.common.pojo.PageResult; 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.profile.SysUserProfileUpdateReqVO;
import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserCreateReqVO; import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserCreateReqVO;
import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserExportReqVO; import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserExportReqVO;
@ -44,17 +44,18 @@ public interface SysUserService {
/** /**
* *
* *
* @param id
* @param reqVO * @param reqVO
*/ */
void updateUserProfile(SysUserProfileUpdateReqVO reqVO); void updateUserProfile(Long id, SysUserProfileUpdateReqVO reqVO);
/** /**
* *
* *
* @param id
* @param reqVO * @param reqVO
*/ */
void updateUserPassword(SysUserProfileUpdatePasswordReqVo reqVO); void updateUserPassword(Long id, SysUserProfileUpdatePasswordReqVO reqVO);
/** /**
* *

View File

@ -9,7 +9,7 @@ import cn.iocoder.dashboard.common.exception.ServiceException;
import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil; import cn.iocoder.dashboard.common.exception.util.ServiceExceptionUtil;
import cn.iocoder.dashboard.common.pojo.PageResult; import cn.iocoder.dashboard.common.pojo.PageResult;
import cn.iocoder.dashboard.modules.infra.service.file.InfFileService; 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.profile.SysUserProfileUpdateReqVO;
import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserCreateReqVO; import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserCreateReqVO;
import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserExportReqVO; import cn.iocoder.dashboard.modules.system.controller.user.vo.user.SysUserExportReqVO;
@ -91,22 +91,22 @@ public class SysUserServiceImpl implements SysUserService {
} }
@Override @Override
public void updateUserProfile(SysUserProfileUpdateReqVO reqVO) { public void updateUserProfile(Long id, SysUserProfileUpdateReqVO reqVO) {
// 校验正确性 // 校验正确性
this.checkUserExists(reqVO.getId()); this.checkUserExists(id);
this.checkEmailUnique(reqVO.getId(), reqVO.getEmail()); this.checkEmailUnique(id, reqVO.getEmail());
this.checkMobileUnique(reqVO.getId(), reqVO.getMobile()); this.checkMobileUnique(id, reqVO.getMobile());
userMapper.updateById(SysUserConvert.INSTANCE.convert(reqVO)); // 执行更新
userMapper.updateById(SysUserConvert.INSTANCE.convert(reqVO).setId(id));
} }
@Override @Override
public void updateUserPassword(SysUserProfileUpdatePasswordReqVo reqVO) { public void updateUserPassword(Long id, SysUserProfileUpdatePasswordReqVO reqVO) {
// 校验旧密码密码 // 校验旧密码密码
this.checkOldPassword(reqVO.getId(), reqVO.getOldPassword()); this.checkOldPassword(id, reqVO.getOldPassword());
SysUserDO updateObj = new SysUserDO(); // 执行更新
updateObj.setId(reqVO.getId()); SysUserDO updateObj = new SysUserDO().setId(id);
// 加密密码 updateObj.setPassword(passwordEncoder.encode(reqVO.getNewPassword())); // 加密密码
updateObj.setPassword(passwordEncoder.encode(reqVO.getNewPassword()));
userMapper.updateById(updateObj); userMapper.updateById(updateObj);
} }