Compare commits
3 Commits
d22f2305e5
...
73f8f42dd7
Author | SHA1 | Date |
---|---|---|
|
73f8f42dd7 | |
|
25d01f0317 | |
|
4778891133 |
|
@ -2,6 +2,7 @@ package cn.bunny.dao.dto.system.user;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import jakarta.validation.constraints.NotBlank;
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Builder;
|
import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -31,7 +32,7 @@ public class AdminUserAddDto {
|
||||||
|
|
||||||
@Schema(name = "password", title = "密码")
|
@Schema(name = "password", title = "密码")
|
||||||
@NotBlank(message = "密码不能为空")
|
@NotBlank(message = "密码不能为空")
|
||||||
private String password;
|
private String password = "123456";
|
||||||
|
|
||||||
@Schema(name = "avatar", title = "头像")
|
@Schema(name = "avatar", title = "头像")
|
||||||
private String avatar;
|
private String avatar;
|
||||||
|
@ -40,7 +41,11 @@ public class AdminUserAddDto {
|
||||||
private Byte sex = 1;
|
private Byte sex = 1;
|
||||||
|
|
||||||
@Schema(name = "summary", title = "个人描述")
|
@Schema(name = "summary", title = "个人描述")
|
||||||
private String summary;
|
private String summary = "这个人很懒,没有介绍";
|
||||||
|
|
||||||
|
@Schema(name = "deptId", title = "部门")
|
||||||
|
@NotNull(message = "部门不能为空")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
@Schema(name = "status", title = "状态", description = "1:禁用 0:正常")
|
@Schema(name = "status", title = "状态", description = "1:禁用 0:正常")
|
||||||
private Boolean status = false;
|
private Boolean status = false;
|
||||||
|
|
|
@ -6,6 +6,8 @@ import lombok.Builder;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
@ -34,4 +36,7 @@ public class AdminUserDto {
|
||||||
@Schema(name = "status", title = "状态", description = "1:禁用 0:正常")
|
@Schema(name = "status", title = "状态", description = "1:禁用 0:正常")
|
||||||
private Boolean status;
|
private Boolean status;
|
||||||
|
|
||||||
|
@Schema(name = "deptId", title = "部门")
|
||||||
|
private List<Long> deptIds;
|
||||||
|
|
||||||
}
|
}
|
|
@ -40,6 +40,10 @@ public class AdminUserUpdateDto {
|
||||||
@Schema(name = "summary", title = "个人描述")
|
@Schema(name = "summary", title = "个人描述")
|
||||||
private String summary;
|
private String summary;
|
||||||
|
|
||||||
|
@Schema(name = "deptId", title = "部门")
|
||||||
|
@NotNull(message = "部门不能为空")
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
@Schema(name = "status", title = "状态", description = "1:禁用 0:正常")
|
@Schema(name = "status", title = "状态", description = "1:禁用 0:正常")
|
||||||
private Boolean status;
|
private Boolean status;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
package cn.bunny.dao.dto.system.user;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Schema(name = "UserUpdateWithPasswordDto对象", title = "管理员用户修改密码", description = "管理员用户修改密码")
|
||||||
|
public class AdminUserUpdateUserStatusDto {
|
||||||
|
|
||||||
|
@Schema(name = "userId", title = "用户ID")
|
||||||
|
@NotNull(message = "用户ID不能为空")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(name = "status", title = "用户状态")
|
||||||
|
@NotNull(message = "用户状态不能为空")
|
||||||
|
private Boolean status;
|
||||||
|
|
||||||
|
}
|
|
@ -14,7 +14,7 @@ import lombok.NoArgsConstructor;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Builder
|
@Builder
|
||||||
@Schema(name = "UserUpdateWithPasswordDto对象", title = "管理员用户修改密码", description = "管理员用户修改密码")
|
@Schema(name = "UserUpdateWithPasswordDto对象", title = "管理员用户修改密码", description = "管理员用户修改密码")
|
||||||
public class UserUpdateWithPasswordDto {
|
public class AdminUserUpdateWithPasswordDto {
|
||||||
|
|
||||||
@Schema(name = "userId", title = "用户ID")
|
@Schema(name = "userId", title = "用户ID")
|
||||||
@NotNull(message = "用户ID不能为空")
|
@NotNull(message = "用户ID不能为空")
|
|
@ -0,0 +1,60 @@
|
||||||
|
package cn.bunny.dao.entity.system;
|
||||||
|
|
||||||
|
import cn.bunny.dao.entity.BaseEntity;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 管理员用户信息
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Bunny
|
||||||
|
* @since 2024-06-26
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("sys_user")
|
||||||
|
@Schema(name = "AdminUserAndDept对象", title = "用户信息和部门Id", description = "用户信息和部门Id")
|
||||||
|
public class AdminUserAndDept extends BaseEntity {
|
||||||
|
|
||||||
|
@Schema(name = "username", title = "用户名")
|
||||||
|
private String username;
|
||||||
|
|
||||||
|
@Schema(name = "nickName", title = "昵称")
|
||||||
|
private String nickName;
|
||||||
|
|
||||||
|
@Schema(name = "email", title = "邮箱")
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
@Schema(name = "phone", title = "手机号")
|
||||||
|
private String phone;
|
||||||
|
|
||||||
|
@Schema(name = "password", title = "密码")
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
@Schema(name = "avatar", title = "头像")
|
||||||
|
private String avatar;
|
||||||
|
|
||||||
|
@Schema(name = "sex", title = "性别", description = "0:女 1:男")
|
||||||
|
private Byte sex;
|
||||||
|
|
||||||
|
@Schema(name = "summary", title = "个人描述")
|
||||||
|
private String summary;
|
||||||
|
|
||||||
|
@Schema(name = "lastLoginIp", title = "最后登录IP")
|
||||||
|
private String lastLoginIp;
|
||||||
|
|
||||||
|
@Schema(name = "lastLoginIpAddress", title = "最后登录ip归属地")
|
||||||
|
private String lastLoginIpAddress;
|
||||||
|
|
||||||
|
@Schema(name = "status", title = "状态", description = "1:禁用 0:正常")
|
||||||
|
private Boolean status;
|
||||||
|
|
||||||
|
@Schema(name = "deptId", title = "部门")
|
||||||
|
private Long deptId;
|
||||||
|
}
|
|
@ -23,9 +23,9 @@ import lombok.experimental.Accessors;
|
||||||
public class UserDept extends BaseEntity {
|
public class UserDept extends BaseEntity {
|
||||||
|
|
||||||
@Schema(name = "userId", title = "用户id")
|
@Schema(name = "userId", title = "用户id")
|
||||||
private String userId;
|
private Long userId;
|
||||||
|
|
||||||
@Schema(name = "deptId", title = "部门id")
|
@Schema(name = "deptId", title = "部门id")
|
||||||
private String deptId;
|
private Long deptId;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
package cn.bunny.dao.vo.system.user;
|
package cn.bunny.dao.vo.system.user;
|
||||||
|
|
||||||
import cn.bunny.dao.vo.BaseVo;
|
import cn.bunny.dao.vo.BaseVo;
|
||||||
|
import com.alibaba.fastjson2.annotation.JSONField;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.*;
|
import lombok.*;
|
||||||
|
|
||||||
|
@ -38,6 +41,11 @@ public class AdminUserVo extends BaseVo {
|
||||||
@Schema(name = "lastLoginIpAddress", title = "最后登录ip归属地")
|
@Schema(name = "lastLoginIpAddress", title = "最后登录ip归属地")
|
||||||
private String lastLoginIpAddress;
|
private String lastLoginIpAddress;
|
||||||
|
|
||||||
|
@Schema(name = "deptId", title = "部门")
|
||||||
|
@JsonFormat(shape = JsonFormat.Shape.STRING)
|
||||||
|
@JSONField(serializeUsing = ToStringSerializer.class)
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
@Schema(name = "status", title = "状态", description = "1:禁用 0:正常")
|
@Schema(name = "status", title = "状态", description = "1:禁用 0:正常")
|
||||||
private Boolean status;
|
private Boolean status;
|
||||||
}
|
}
|
|
@ -49,7 +49,7 @@ public class UserController {
|
||||||
return Mono.just(Result.success(vo));
|
return Mono.just(Result.success(vo));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "查询用户", description = "查询用户")
|
@Operation(summary = "多条件查询用户", description = "多条件查询用户")
|
||||||
@GetMapping("queryUser")
|
@GetMapping("queryUser")
|
||||||
public Mono<Result<List<AdminUserVo>>> queryUser(String keyword) {
|
public Mono<Result<List<AdminUserVo>>> queryUser(String keyword) {
|
||||||
List<AdminUserVo> voList = userService.queryUser(keyword);
|
List<AdminUserVo> voList = userService.queryUser(keyword);
|
||||||
|
@ -58,9 +58,37 @@ public class UserController {
|
||||||
|
|
||||||
@Operation(summary = "更新用户信息", description = "更新用户信息")
|
@Operation(summary = "更新用户信息", description = "更新用户信息")
|
||||||
@PutMapping("updateAdminUser")
|
@PutMapping("updateAdminUser")
|
||||||
public Mono<Result<String>> updateAdminUser(@Valid @RequestBody AdminUserUpdateDto dto) {
|
public Result<String> updateAdminUser(@Valid @RequestBody AdminUserUpdateDto dto) {
|
||||||
userService.updateAdminUser(dto);
|
userService.updateAdminUser(dto);
|
||||||
return Mono.just(Result.success(ResultCodeEnum.UPDATE_SUCCESS));
|
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "修改用户状态", description = "管理员修改用户状态")
|
||||||
|
@PutMapping("updateUserStatusByAdmin")
|
||||||
|
public Result<String> updateUserStatusByAdmin(@Valid @RequestBody AdminUserUpdateUserStatusDto dto) {
|
||||||
|
userService.updateUserStatusByAdmin(dto);
|
||||||
|
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "修改管理员用户密码", description = "管理员修改管理员用户密码")
|
||||||
|
@PutMapping("updateUserPasswordByAdmin")
|
||||||
|
public Result<String> updateUserPasswordByAdmin(@Valid @RequestBody AdminUserUpdateWithPasswordDto dto) {
|
||||||
|
userService.updateUserPasswordByAdmin(dto);
|
||||||
|
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "修改用户头像", description = "管理员修改用户头像")
|
||||||
|
@PutMapping("uploadAvatarByAdmin")
|
||||||
|
public Result<String> uploadAvatarByAdmin(@Valid UserUpdateWithAvatarDto dto) {
|
||||||
|
userService.uploadAvatarByAdmin(dto);
|
||||||
|
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "强制退出", description = "强制退出")
|
||||||
|
@PutMapping("forcedOffline")
|
||||||
|
public Result<String> forcedOffline(@RequestBody Long id) {
|
||||||
|
userService.forcedOffline(id);
|
||||||
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "登录发送邮件验证码", description = "登录发送邮件验证码")
|
@Operation(summary = "登录发送邮件验证码", description = "登录发送邮件验证码")
|
||||||
|
@ -79,9 +107,9 @@ public class UserController {
|
||||||
|
|
||||||
@Operation(summary = "添加用户信息", description = "添加用户信息")
|
@Operation(summary = "添加用户信息", description = "添加用户信息")
|
||||||
@PostMapping("addAdminUser")
|
@PostMapping("addAdminUser")
|
||||||
public Mono<Result<String>> addAdminUser(@Valid @RequestBody AdminUserAddDto dto) {
|
public Result<Object> addAdminUser(@Valid @RequestBody AdminUserAddDto dto) {
|
||||||
userService.addAdminUser(dto);
|
userService.addAdminUser(dto);
|
||||||
return Mono.just(Result.success(ResultCodeEnum.ADD_SUCCESS));
|
return Result.success(ResultCodeEnum.ADD_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "退出登录", description = "退出登录")
|
@Operation(summary = "退出登录", description = "退出登录")
|
||||||
|
@ -91,28 +119,6 @@ public class UserController {
|
||||||
return Result.success(ResultCodeEnum.LOGOUT_SUCCESS);
|
return Result.success(ResultCodeEnum.LOGOUT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "管理员修改管理员用户密码", description = "管理员修改管理员用户密码")
|
|
||||||
@PutMapping("updateUserPasswordByAdmin")
|
|
||||||
public Result<String> updateUserPasswordByAdmin(@Valid @RequestBody UserUpdateWithPasswordDto dto) {
|
|
||||||
userService.updateUserPasswordByAdmin(dto);
|
|
||||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "管理员上传用户头像", description = "管理员上传用户头像")
|
|
||||||
@PutMapping("uploadAvatarByAdmin")
|
|
||||||
public Result<String> uploadAvatarByAdmin(@Valid UserUpdateWithAvatarDto dto) {
|
|
||||||
userService.uploadAvatarByAdmin(dto);
|
|
||||||
return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "强制退出", description = "强制退出")
|
|
||||||
@PutMapping("forcedOffline")
|
|
||||||
public Result<String> forcedOffline(@RequestBody Long id) {
|
|
||||||
userService.forcedOffline(id);
|
|
||||||
return Result.success();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Operation(summary = "删除用户信息", description = "删除用户信息")
|
@Operation(summary = "删除用户信息", description = "删除用户信息")
|
||||||
@DeleteMapping("deleteAdminUser")
|
@DeleteMapping("deleteAdminUser")
|
||||||
public Mono<Result<String>> deleteAdminUser(@RequestBody List<Long> ids) {
|
public Mono<Result<String>> deleteAdminUser(@RequestBody List<Long> ids) {
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cn.bunny.services.mapper;
|
||||||
|
|
||||||
import cn.bunny.dao.dto.system.user.AdminUserDto;
|
import cn.bunny.dao.dto.system.user.AdminUserDto;
|
||||||
import cn.bunny.dao.entity.system.AdminUser;
|
import cn.bunny.dao.entity.system.AdminUser;
|
||||||
|
import cn.bunny.dao.entity.system.AdminUserAndDept;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
@ -28,7 +29,7 @@ public interface UserMapper extends BaseMapper<AdminUser> {
|
||||||
* @param dto 用户信息查询表单
|
* @param dto 用户信息查询表单
|
||||||
* @return 用户信息分页结果
|
* @return 用户信息分页结果
|
||||||
*/
|
*/
|
||||||
IPage<AdminUser> selectListByPage(@Param("page") Page<AdminUser> pageParams, @Param("dto") AdminUserDto dto);
|
IPage<AdminUserAndDept> selectListByPage(@Param("page") Page<AdminUser> pageParams, @Param("dto") AdminUserDto dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 物理删除用户信息
|
* 物理删除用户信息
|
||||||
|
|
|
@ -85,7 +85,7 @@ public interface UserService extends IService<AdminUser> {
|
||||||
*
|
*
|
||||||
* @param dto 管理员用户修改密码
|
* @param dto 管理员用户修改密码
|
||||||
*/
|
*/
|
||||||
void updateUserPasswordByAdmin(UserUpdateWithPasswordDto dto);
|
void updateUserPasswordByAdmin(AdminUserUpdateWithPasswordDto dto);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 管理员上传用户头像
|
* * 管理员上传用户头像
|
||||||
|
@ -108,4 +108,11 @@ public interface UserService extends IService<AdminUser> {
|
||||||
* @return 用户信息列表
|
* @return 用户信息列表
|
||||||
*/
|
*/
|
||||||
List<AdminUserVo> queryUser(String keyword);
|
List<AdminUserVo> queryUser(String keyword);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 修改用户状态
|
||||||
|
*
|
||||||
|
* @param dto 管理员用户修改密码
|
||||||
|
*/
|
||||||
|
void updateUserStatusByAdmin(AdminUserUpdateUserStatusDto dto);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,9 @@ import cn.bunny.common.service.utils.minio.MinioUtil;
|
||||||
import cn.bunny.dao.dto.system.files.FileUploadDto;
|
import cn.bunny.dao.dto.system.files.FileUploadDto;
|
||||||
import cn.bunny.dao.dto.system.user.*;
|
import cn.bunny.dao.dto.system.user.*;
|
||||||
import cn.bunny.dao.entity.system.AdminUser;
|
import cn.bunny.dao.entity.system.AdminUser;
|
||||||
|
import cn.bunny.dao.entity.system.AdminUserAndDept;
|
||||||
import cn.bunny.dao.entity.system.EmailUsers;
|
import cn.bunny.dao.entity.system.EmailUsers;
|
||||||
|
import cn.bunny.dao.entity.system.UserDept;
|
||||||
import cn.bunny.dao.pojo.common.EmailSendInit;
|
import cn.bunny.dao.pojo.common.EmailSendInit;
|
||||||
import cn.bunny.dao.pojo.constant.MinioConstant;
|
import cn.bunny.dao.pojo.constant.MinioConstant;
|
||||||
import cn.bunny.dao.pojo.constant.RedisUserConstant;
|
import cn.bunny.dao.pojo.constant.RedisUserConstant;
|
||||||
|
@ -158,7 +160,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
|
||||||
* @param dto 管理员用户修改密码
|
* @param dto 管理员用户修改密码
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void updateUserPasswordByAdmin(UserUpdateWithPasswordDto dto) {
|
public void updateUserPasswordByAdmin(AdminUserUpdateWithPasswordDto dto) {
|
||||||
Long userId = dto.getUserId();
|
Long userId = dto.getUserId();
|
||||||
String password = dto.getPassword();
|
String password = dto.getPassword();
|
||||||
|
|
||||||
|
@ -244,6 +246,20 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
|
||||||
}).toList();
|
}).toList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 修改用户状态
|
||||||
|
*
|
||||||
|
* @param dto 管理员用户修改密码
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateUserStatusByAdmin(AdminUserUpdateUserStatusDto dto) {
|
||||||
|
AdminUser adminUser = new AdminUser();
|
||||||
|
adminUser.setId(dto.getUserId());
|
||||||
|
adminUser.setStatus(dto.getStatus());
|
||||||
|
|
||||||
|
updateById(adminUser);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 用户信息 服务实现类
|
* * 用户信息 服务实现类
|
||||||
*
|
*
|
||||||
|
@ -254,7 +270,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
|
||||||
@Override
|
@Override
|
||||||
public PageResult<AdminUserVo> getAdminUserList(Page<AdminUser> pageParams, AdminUserDto dto) {
|
public PageResult<AdminUserVo> getAdminUserList(Page<AdminUser> pageParams, AdminUserDto dto) {
|
||||||
// 分页查询菜单图标
|
// 分页查询菜单图标
|
||||||
IPage<AdminUser> page = baseMapper.selectListByPage(pageParams, dto);
|
IPage<AdminUserAndDept> page = baseMapper.selectListByPage(pageParams, dto);
|
||||||
|
|
||||||
List<AdminUserVo> voList = page.getRecords().stream().map(AdminUser -> {
|
List<AdminUserVo> voList = page.getRecords().stream().map(AdminUser -> {
|
||||||
// 如果存在用户头像,则设置用户头像
|
// 如果存在用户头像,则设置用户头像
|
||||||
|
@ -285,19 +301,23 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
|
||||||
@Override
|
@Override
|
||||||
public void addAdminUser(@Valid AdminUserAddDto dto) {
|
public void addAdminUser(@Valid AdminUserAddDto dto) {
|
||||||
// 对密码加密
|
// 对密码加密
|
||||||
String password = dto.getPassword();
|
String md5Password = DigestUtils.md5DigestAsHex(dto.getPassword().getBytes());
|
||||||
|
|
||||||
// 保存数据
|
// 保存数据
|
||||||
AdminUser adminUser = new AdminUser();
|
AdminUser adminUser = new AdminUser();
|
||||||
BeanUtils.copyProperties(dto, adminUser);
|
BeanUtils.copyProperties(dto, adminUser);
|
||||||
|
adminUser.setPassword(md5Password);
|
||||||
// 对密码加密
|
|
||||||
if (StringUtils.hasText(password)) {
|
|
||||||
password = DigestUtils.md5DigestAsHex(password.getBytes());
|
|
||||||
adminUser.setPassword(password);
|
|
||||||
}
|
|
||||||
|
|
||||||
save(adminUser);
|
save(adminUser);
|
||||||
|
|
||||||
|
// 插入用户部门关系表
|
||||||
|
Long userId = adminUser.getId();
|
||||||
|
Long deptId = dto.getDeptId();
|
||||||
|
UserDept userDept = new UserDept();
|
||||||
|
userDept.setDeptId(deptId);
|
||||||
|
userDept.setUserId(userId);
|
||||||
|
|
||||||
|
// 插入分配后的用户内容
|
||||||
|
userDeptMapper.insert(userDept);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -307,13 +327,29 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void updateAdminUser(AdminUserUpdateDto dto) {
|
public void updateAdminUser(AdminUserUpdateDto dto) {
|
||||||
|
// 部门Id
|
||||||
|
Long deptId = dto.getDeptId();
|
||||||
|
Long userId = dto.getId();
|
||||||
|
|
||||||
// 判断更新内容是否存在
|
// 判断更新内容是否存在
|
||||||
List<AdminUser> adminUserList = list(Wrappers.<AdminUser>lambdaQuery().eq(AdminUser::getId, dto.getId()));
|
List<AdminUser> adminUserList = list(Wrappers.<AdminUser>lambdaQuery().eq(AdminUser::getId, userId));
|
||||||
if (adminUserList.isEmpty()) throw new BunnyException(ResultCodeEnum.DATA_NOT_EXIST);
|
if (adminUserList.isEmpty()) throw new BunnyException(ResultCodeEnum.DATA_NOT_EXIST);
|
||||||
|
|
||||||
|
// 更新用户
|
||||||
AdminUser adminUser = new AdminUser();
|
AdminUser adminUser = new AdminUser();
|
||||||
BeanUtils.copyProperties(dto, adminUser);
|
BeanUtils.copyProperties(dto, adminUser);
|
||||||
updateById(adminUser);
|
updateById(adminUser);
|
||||||
|
|
||||||
|
// 更新用户部门
|
||||||
|
UserDept userDept = new UserDept();
|
||||||
|
userDept.setDeptId(deptId);
|
||||||
|
userDept.setUserId(userId);
|
||||||
|
|
||||||
|
// 删除这个用户部门关系下所有
|
||||||
|
userDeptMapper.deleteBatchIdsByUserIdWithPhysics(List.of(userId));
|
||||||
|
|
||||||
|
// 插入分配后的用户内容
|
||||||
|
userDeptMapper.insert(userDept);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -77,8 +77,8 @@ mybatis-plus:
|
||||||
global-config:
|
global-config:
|
||||||
db-config:
|
db-config:
|
||||||
logic-delete-field: isDelete
|
logic-delete-field: isDelete
|
||||||
configuration:
|
# configuration:
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 查看日志
|
# log-impl: org.apache.ibatis.logging.stdout.StdOutImpl # 查看日志
|
||||||
|
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
|
|
|
@ -29,10 +29,10 @@
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
<!-- 分页查询用户信息内容 -->
|
<!-- 分页查询用户信息内容 -->
|
||||||
<select id="selectListByPage" resultType="cn.bunny.dao.entity.system.AdminUser">
|
<select id="selectListByPage" resultType="cn.bunny.dao.entity.system.AdminUserAndDept">
|
||||||
select
|
select
|
||||||
<include refid="Base_Column_List"/>
|
user.*,user_dept.dept_id
|
||||||
from sys_user
|
from sys_user user left join sys_user_dept user_dept on user.id = user_dept.user_id
|
||||||
<where>
|
<where>
|
||||||
<if test="dto.username != null and dto.username != ''">
|
<if test="dto.username != null and dto.username != ''">
|
||||||
username like CONCAT('%',#{dto.username},'%')
|
username like CONCAT('%',#{dto.username},'%')
|
||||||
|
@ -55,7 +55,14 @@
|
||||||
<if test="dto.status != null and dto.status != ''">
|
<if test="dto.status != null and dto.status != ''">
|
||||||
status = #{dto.status}
|
status = #{dto.status}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="dto.deptIds != null and dto.deptIds.size() > 0">
|
||||||
|
user_dept.dept_id in
|
||||||
|
<foreach collection="dto.deptIds" item="id" open="(" close=")" separator=",">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
</if>
|
||||||
</where>
|
</where>
|
||||||
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 查询用户 -->
|
<!-- 查询用户 -->
|
||||||
|
|
Loading…
Reference in New Issue