mirror of
http://git.pig4cloud.com/pig/pigx.git
synced 2026-11-08 20:49:00 +08:00
♻️ Refactoring code. 【用户管理】状态栏修改为 有效
【用户管理】增加修改悬浮输入框密码功能
This commit is contained in:
1 parent
786648d1ca
commit
932c4ec1f4
2 files changed
+50
-41
No files matched your search
+27
-27
@@ -38,6 +38,7 @@ import com.pig4cloud.pigx.common.security.util.SecurityUtils;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.validation.Valid;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -45,7 +46,6 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -136,18 +136,6 @@ public class SysUserController {
|
||||
return R.ok(userService.saveUser(userDto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户信息
|
||||
* @param userDto 用户信息
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("更新用户信息")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_user_edit')")
|
||||
public R updateUser(@Valid @RequestBody UserDTO userDto) {
|
||||
return R.ok(userService.updateUser(userDto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询用户
|
||||
* @param page 参数集
|
||||
@@ -160,16 +148,40 @@ public class SysUserController {
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改个人信息
|
||||
* 管理员更新用户信息
|
||||
* @param userDto 用户信息
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("更新用户信息")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('sys_user_edit')")
|
||||
public R updateUser(@Valid @RequestBody UserDTO userDto) {
|
||||
return R.ok(userService.updateUser(userDto));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改个人信息 (当前用户)
|
||||
* @param userDto userDto
|
||||
* @return success/false
|
||||
*/
|
||||
@SysLog("修改个人信息")
|
||||
@PutMapping("/edit")
|
||||
@PutMapping("/personal/edit")
|
||||
public R updateUserInfo(@Valid @RequestBody UserDTO userDto) {
|
||||
return userService.updateUserInfo(userDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改个人密码 (当前用户)
|
||||
* @param userDto 用户DTO对象,包含需要修改密码的用户信息
|
||||
* @return R 返回结果对象,包含修改密码操作的结果信息
|
||||
*/
|
||||
@PutMapping("/personal/password")
|
||||
public R updatePassword(@RequestBody UserDTO userDto) {
|
||||
String username = SecurityUtils.getUser().getUsername();
|
||||
userDto.setUsername(username);
|
||||
return userService.changePassword(userDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param username 用户名称
|
||||
* @return 上级部门用户列表
|
||||
@@ -214,18 +226,6 @@ public class SysUserController {
|
||||
return userService.lockUser(username);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改密码接口
|
||||
* @param userDto 用户DTO对象,包含需要修改密码的用户信息
|
||||
* @return R 返回结果对象,包含修改密码操作的结果信息
|
||||
*/
|
||||
@PutMapping("/password")
|
||||
public R password(@RequestBody UserDTO userDto) {
|
||||
String username = SecurityUtils.getUser().getUsername();
|
||||
userDto.setUsername(username);
|
||||
return userService.changePassword(userDto);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解绑定接口
|
||||
* @param type 需要解绑定的类型
|
||||
|
||||
+23
-14
@@ -227,28 +227,37 @@ public class SysUserServiceImpl extends ServiceImpl<SysUserMapper, SysUser> impl
|
||||
SysUser sysUser = new SysUser();
|
||||
BeanUtils.copyProperties(userDto, sysUser);
|
||||
sysUser.setUpdateTime(LocalDateTime.now());
|
||||
|
||||
if (StrUtil.isNotBlank(userDto.getPassword())) {
|
||||
sysUser.setPassword(ENCODER.encode(userDto.getPassword()));
|
||||
}
|
||||
|
||||
this.updateById(sysUser);
|
||||
|
||||
// 更新用户角色表
|
||||
sysUserRoleMapper.delete(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, userDto.getUserId()));
|
||||
userDto.getRole().stream().map(roleId -> {
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setUserId(sysUser.getUserId());
|
||||
userRole.setRoleId(roleId);
|
||||
return userRole;
|
||||
}).forEach(SysUserRole::insert);
|
||||
if (userDto.getRole() != null) {
|
||||
sysUserRoleMapper
|
||||
.delete(Wrappers.<SysUserRole>lambdaQuery().eq(SysUserRole::getUserId, userDto.getUserId()));
|
||||
userDto.getRole().stream().map(roleId -> {
|
||||
SysUserRole userRole = new SysUserRole();
|
||||
userRole.setUserId(sysUser.getUserId());
|
||||
userRole.setRoleId(roleId);
|
||||
return userRole;
|
||||
}).forEach(SysUserRole::insert);
|
||||
}
|
||||
|
||||
// 更新用户岗位表
|
||||
sysUserPostMapper.delete(Wrappers.<SysUserPost>lambdaQuery().eq(SysUserPost::getUserId, userDto.getUserId()));
|
||||
userDto.getPost().stream().map(postId -> {
|
||||
SysUserPost userPost = new SysUserPost();
|
||||
userPost.setUserId(sysUser.getUserId());
|
||||
userPost.setPostId(postId);
|
||||
return userPost;
|
||||
}).forEach(SysUserPost::insert);
|
||||
if (userDto.getPost() != null) {
|
||||
sysUserPostMapper
|
||||
.delete(Wrappers.<SysUserPost>lambdaQuery().eq(SysUserPost::getUserId, userDto.getUserId()));
|
||||
userDto.getPost().stream().map(postId -> {
|
||||
SysUserPost userPost = new SysUserPost();
|
||||
userPost.setUserId(sysUser.getUserId());
|
||||
userPost.setPostId(postId);
|
||||
return userPost;
|
||||
}).forEach(SysUserPost::insert);
|
||||
}
|
||||
|
||||
return Boolean.TRUE;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user