feat(新增): 用户修改密码,用户修改文件
This commit is contained in:
parent
f3b7846c5f
commit
0bbc0b5cd2
|
@ -20,7 +20,7 @@ public class AdminCodeGenerator {
|
||||||
public static final String entity = "Bunny";
|
public static final String entity = "Bunny";
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Generation("sys_dept", "sys_user_dept");
|
Generation("sys_files");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -2,6 +2,7 @@ package cn.bunny.dao.dto.i18n;
|
||||||
|
|
||||||
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;
|
||||||
|
@ -15,7 +16,7 @@ import lombok.NoArgsConstructor;
|
||||||
public class I18nUpdateDto {
|
public class I18nUpdateDto {
|
||||||
|
|
||||||
@Schema(name = "id", title = "主键")
|
@Schema(name = "id", title = "主键")
|
||||||
@NotBlank(message = "id不能为空")
|
@NotNull(message = "id不能为空")
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Schema(name = "keyName", title = "多语言key")
|
@Schema(name = "keyName", title = "多语言key")
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package cn.bunny.dao.dto.system.files;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Schema(name = "FileUploadDto对象", title = "文件上传", description = "文件上传管理")
|
||||||
|
public class FileUploadDto {
|
||||||
|
|
||||||
|
@Schema(name = "file", title = "文件")
|
||||||
|
MultipartFile file;
|
||||||
|
|
||||||
|
@Schema(name = "type", title = "文件类型")
|
||||||
|
String type;
|
||||||
|
|
||||||
|
}
|
|
@ -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;
|
||||||
|
@ -14,6 +15,10 @@ import lombok.NoArgsConstructor;
|
||||||
@Schema(name = "AdminUserUpdateDto对象", title = "用户", description = "用户管理")
|
@Schema(name = "AdminUserUpdateDto对象", title = "用户", description = "用户管理")
|
||||||
public class AdminUserUpdateDto {
|
public class AdminUserUpdateDto {
|
||||||
|
|
||||||
|
@Schema(name = "id", title = "主键")
|
||||||
|
@NotNull(message = "id不能为空")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
@Schema(name = "username", title = "用户名")
|
@Schema(name = "username", title = "用户名")
|
||||||
@NotBlank(message = "用户名不能为空")
|
@NotBlank(message = "用户名不能为空")
|
||||||
private String username;
|
private String username;
|
||||||
|
@ -29,20 +34,16 @@ public class AdminUserUpdateDto {
|
||||||
@Schema(name = "phone", title = "手机号")
|
@Schema(name = "phone", title = "手机号")
|
||||||
private String phone;
|
private String phone;
|
||||||
|
|
||||||
@Schema(name = "password", title = "密码")
|
|
||||||
@NotBlank(message = "密码不能为空")
|
|
||||||
private String password;
|
|
||||||
|
|
||||||
@Schema(name = "avatar", title = "头像")
|
@Schema(name = "avatar", title = "头像")
|
||||||
private String avatar;
|
private String avatar;
|
||||||
|
|
||||||
@Schema(name = "sex", title = "性别", description = "0:女 1:男")
|
@Schema(name = "sex", title = "性别", description = "0:女 1:男")
|
||||||
private Byte sex = 1;
|
private Byte sex;
|
||||||
|
|
||||||
@Schema(name = "summary", title = "个人描述")
|
@Schema(name = "summary", title = "个人描述")
|
||||||
private String summary;
|
private String summary;
|
||||||
|
|
||||||
@Schema(name = "status", title = "状态", description = "1:禁用 0:正常")
|
@Schema(name = "status", title = "状态", description = "1:禁用 0:正常")
|
||||||
private Boolean status = false;
|
private Boolean status;
|
||||||
|
|
||||||
}
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package cn.bunny.dao.dto.system.user;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
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 UserUpdateWithPasswordDto {
|
||||||
|
|
||||||
|
@Schema(name = "userId", title = "用户ID")
|
||||||
|
@NotNull(message = "用户ID不能为空")
|
||||||
|
private Long userId;
|
||||||
|
|
||||||
|
@Schema(name = "password", title = "用户密码")
|
||||||
|
@NotBlank(message = "密码不能为空")
|
||||||
|
@NotEmpty
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
}
|
|
@ -32,6 +32,9 @@ public enum ResultCodeEnum {
|
||||||
DATA_EXIST(201, "数据已存在"),
|
DATA_EXIST(201, "数据已存在"),
|
||||||
DATA_NOT_EXIST(201, "数据不存在"),
|
DATA_NOT_EXIST(201, "数据不存在"),
|
||||||
REQUEST_IS_EMPTY(201, "请求数据为空"),
|
REQUEST_IS_EMPTY(201, "请求数据为空"),
|
||||||
|
DATA_TOO_LARGE(201, "请求数据为空"),
|
||||||
|
USER_IS_EMPTY(201, "用户不存在"),
|
||||||
|
UPDATE_NEW_PASSWORD_SAME_AS_OLD_PASSWORD(201, "新密码与密码相同"),
|
||||||
|
|
||||||
// 数据相关 206
|
// 数据相关 206
|
||||||
ILLEGAL_REQUEST(206, "非法请求"),
|
ILLEGAL_REQUEST(206, "非法请求"),
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
package cn.bunny.dao.vo.system.files;
|
||||||
|
|
||||||
|
import cn.bunny.dao.vo.BaseVo;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回文件信息
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@AllArgsConstructor
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Builder
|
||||||
|
@Schema(name = "FileInfoVo对象", title = "管理端返回文件信息", description = "管理端返回文件信息")
|
||||||
|
public class FileInfoVo extends BaseVo {
|
||||||
|
|
||||||
|
@Schema(name = "url", title = "文件的路径")
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
@Schema(name = "filename", title = "文件的名称")
|
||||||
|
private String filename;
|
||||||
|
|
||||||
|
@Schema(name = "filepath", title = "文件在服务器上的存储路径")
|
||||||
|
private String filepath;
|
||||||
|
|
||||||
|
@Schema(name = "fileSize", title = "文件的大小,以字节为单位")
|
||||||
|
private Long fileSize;
|
||||||
|
|
||||||
|
@Schema(name = "size", title = "文件大小")
|
||||||
|
private String size;
|
||||||
|
|
||||||
|
@Schema(name = "fileType", title = "文件的MIME类型")
|
||||||
|
private String fileType;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,41 @@
|
||||||
|
package cn.bunny.services.Bunny;
|
||||||
|
|
||||||
|
import cn.bunny.dao.entity.BaseEntity;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 系统文件表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Bunny
|
||||||
|
* @since 2024-10-04
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("sys_files")
|
||||||
|
@ApiModel(value = "Files对象", description = "系统文件表")
|
||||||
|
public class Files extends BaseEntity {
|
||||||
|
|
||||||
|
@Schema(name = "filename", title = "文件的名称")
|
||||||
|
private String filename;
|
||||||
|
|
||||||
|
@Schema(name = "filepath", title = "文件在服务器上的存储路径")
|
||||||
|
private String filepath;
|
||||||
|
|
||||||
|
@Schema(name = "fileSize", title = "文件的大小,以字节为单位")
|
||||||
|
private Long fileSize;
|
||||||
|
|
||||||
|
@Schema(name = "fileType", title = "文件的MIME类型")
|
||||||
|
private String fileType;
|
||||||
|
|
||||||
|
@Schema(name = "downloadCount", title = "下载数量")
|
||||||
|
private Integer downloadCount;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,35 @@
|
||||||
|
package cn.bunny.services.controller;
|
||||||
|
|
||||||
|
import cn.bunny.dao.dto.system.files.FileUploadDto;
|
||||||
|
import cn.bunny.dao.pojo.result.Result;
|
||||||
|
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||||
|
import cn.bunny.dao.vo.system.files.FileInfoVo;
|
||||||
|
import cn.bunny.services.service.FilesService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 系统文件表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Bunny
|
||||||
|
* @since 2024-10-04
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("admin/files")
|
||||||
|
public class FilesController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FilesService filesService;
|
||||||
|
|
||||||
|
@Operation(summary = "上传文件", description = "上传文件")
|
||||||
|
@PostMapping("upload")
|
||||||
|
public Result<FileInfoVo> upload(FileUploadDto dto) {
|
||||||
|
FileInfoVo vo = filesService.upload(dto);
|
||||||
|
return Result.success(vo, ResultCodeEnum.SUCCESS_UPLOAD);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,6 @@
|
||||||
package cn.bunny.services.controller;
|
package cn.bunny.services.controller;
|
||||||
|
|
||||||
import cn.bunny.dao.dto.system.user.AdminUserAddDto;
|
import cn.bunny.dao.dto.system.user.*;
|
||||||
import cn.bunny.dao.dto.system.user.AdminUserDto;
|
|
||||||
import cn.bunny.dao.dto.system.user.AdminUserUpdateDto;
|
|
||||||
import cn.bunny.dao.dto.system.user.RefreshTokenDto;
|
|
||||||
import cn.bunny.dao.entity.system.AdminUser;
|
import cn.bunny.dao.entity.system.AdminUser;
|
||||||
import cn.bunny.dao.pojo.result.PageResult;
|
import cn.bunny.dao.pojo.result.PageResult;
|
||||||
import cn.bunny.dao.pojo.result.Result;
|
import cn.bunny.dao.pojo.result.Result;
|
||||||
|
@ -66,6 +63,13 @@ public class UserController {
|
||||||
return Mono.just(Result.success(ResultCodeEnum.DELETE_SUCCESS));
|
return Mono.just(Result.success(ResultCodeEnum.DELETE_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 = "登录发送邮件验证码")
|
@Operation(summary = "登录发送邮件验证码", description = "登录发送邮件验证码")
|
||||||
@PostMapping("noAuth/sendLoginEmail")
|
@PostMapping("noAuth/sendLoginEmail")
|
||||||
public Result<String> sendLoginEmail(String email) {
|
public Result<String> sendLoginEmail(String email) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.bunny.services.controller;
|
package cn.bunny.services.controller;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@ -11,6 +12,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||||
* @author Bunny
|
* @author Bunny
|
||||||
* @since 2024-10-04
|
* @since 2024-10-04
|
||||||
*/
|
*/
|
||||||
|
@Tag(name = "用户和部门", description = "用户和部门相关接口")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("admin/userDept")
|
@RequestMapping("admin/userDept")
|
||||||
public class UserDeptController {
|
public class UserDeptController {
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
package cn.bunny.services.mapper;
|
||||||
|
|
||||||
|
import cn.bunny.services.Bunny.Files;
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 系统文件表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Bunny
|
||||||
|
* @since 2024-10-04
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface FilesMapper extends BaseMapper<Files> {
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package cn.bunny.services.service;
|
||||||
|
|
||||||
|
import cn.bunny.dao.dto.system.files.FileUploadDto;
|
||||||
|
import cn.bunny.dao.vo.system.files.FileInfoVo;
|
||||||
|
import cn.bunny.services.Bunny.Files;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 系统文件表 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Bunny
|
||||||
|
* @since 2024-10-04
|
||||||
|
*/
|
||||||
|
public interface FilesService extends IService<Files> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 上传文件
|
||||||
|
*
|
||||||
|
* @param dto 文件上传
|
||||||
|
* @return 管理端返回文件信息
|
||||||
|
*/
|
||||||
|
FileInfoVo upload(FileUploadDto dto);
|
||||||
|
}
|
|
@ -1,9 +1,6 @@
|
||||||
package cn.bunny.services.service;
|
package cn.bunny.services.service;
|
||||||
|
|
||||||
import cn.bunny.dao.dto.system.user.AdminUserAddDto;
|
import cn.bunny.dao.dto.system.user.*;
|
||||||
import cn.bunny.dao.dto.system.user.AdminUserDto;
|
|
||||||
import cn.bunny.dao.dto.system.user.AdminUserUpdateDto;
|
|
||||||
import cn.bunny.dao.dto.system.user.RefreshTokenDto;
|
|
||||||
import cn.bunny.dao.entity.system.AdminUser;
|
import cn.bunny.dao.entity.system.AdminUser;
|
||||||
import cn.bunny.dao.pojo.result.PageResult;
|
import cn.bunny.dao.pojo.result.PageResult;
|
||||||
import cn.bunny.dao.vo.system.user.AdminUserVo;
|
import cn.bunny.dao.vo.system.user.AdminUserVo;
|
||||||
|
@ -82,4 +79,11 @@ public interface UserService extends IService<AdminUser> {
|
||||||
* @return 用户信息
|
* @return 用户信息
|
||||||
*/
|
*/
|
||||||
UserVo getUserinfoById(Long id);
|
UserVo getUserinfoById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 管理员修改管理员用户密码
|
||||||
|
*
|
||||||
|
* @param dto 管理员用户修改密码
|
||||||
|
*/
|
||||||
|
void updateUserPasswordByAdmin(UserUpdateWithPasswordDto dto);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,86 @@
|
||||||
|
package cn.bunny.services.service.impl;
|
||||||
|
|
||||||
|
import cn.bunny.common.service.context.BaseContext;
|
||||||
|
import cn.bunny.common.service.exception.BunnyException;
|
||||||
|
import cn.bunny.common.service.utils.FileUtil;
|
||||||
|
import cn.bunny.common.service.utils.minio.MinioUtil;
|
||||||
|
import cn.bunny.dao.dto.system.files.FileUploadDto;
|
||||||
|
import cn.bunny.dao.pojo.common.MinioFIlePath;
|
||||||
|
import cn.bunny.dao.pojo.result.ResultCodeEnum;
|
||||||
|
import cn.bunny.dao.vo.system.files.FileInfoVo;
|
||||||
|
import cn.bunny.services.Bunny.Files;
|
||||||
|
import cn.bunny.services.mapper.FilesMapper;
|
||||||
|
import cn.bunny.services.service.FilesService;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import lombok.SneakyThrows;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 系统文件表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author Bunny
|
||||||
|
* @since 2024-10-04
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class FilesServiceImpl extends ServiceImpl<FilesMapper, Files> implements FilesService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private MinioUtil minioUtil;
|
||||||
|
|
||||||
|
@Value("${spring.servlet.multipart.max-file-size}")
|
||||||
|
private String maxFileSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 上传文件
|
||||||
|
*
|
||||||
|
* @param dto 文件上传
|
||||||
|
* @return 管理端返回文件信息
|
||||||
|
*/
|
||||||
|
@SneakyThrows
|
||||||
|
@Override
|
||||||
|
public FileInfoVo upload(FileUploadDto dto) {
|
||||||
|
MultipartFile file = dto.getFile();
|
||||||
|
String type = dto.getType();
|
||||||
|
|
||||||
|
// 管理员Id
|
||||||
|
Long userId = BaseContext.getUserId();
|
||||||
|
// 文件大小
|
||||||
|
long fileSize = file.getSize();
|
||||||
|
// 文件类型
|
||||||
|
String contentType = file.getContentType();
|
||||||
|
// 文件名
|
||||||
|
String filename = file.getOriginalFilename();
|
||||||
|
|
||||||
|
// 上传文件
|
||||||
|
MinioFIlePath minioFIlePath = minioUtil.getUploadMinioObjectFilePath(file, type);
|
||||||
|
String bucketNameFilepath = minioFIlePath.getBucketNameFilepath();
|
||||||
|
|
||||||
|
// 盘读研数据是否过大
|
||||||
|
String mb = maxFileSize.replace("MB", "");
|
||||||
|
if (fileSize / 1024 / 1024 > Long.parseLong(mb)) throw new BunnyException(ResultCodeEnum.DATA_TOO_LARGE);
|
||||||
|
|
||||||
|
// 插入文件信息
|
||||||
|
Files adminFiles = new Files();
|
||||||
|
adminFiles.setFileSize(fileSize);
|
||||||
|
adminFiles.setFileType(contentType);
|
||||||
|
adminFiles.setFilename(filename);
|
||||||
|
adminFiles.setFilepath(bucketNameFilepath);
|
||||||
|
adminFiles.setCreateUser(userId);
|
||||||
|
save(adminFiles);
|
||||||
|
|
||||||
|
// 返回信息内容化
|
||||||
|
return FileInfoVo.builder()
|
||||||
|
.size(FileUtil.getSize(fileSize))
|
||||||
|
.filepath(bucketNameFilepath)
|
||||||
|
.fileSize(fileSize)
|
||||||
|
.fileType(contentType)
|
||||||
|
.filename(filename)
|
||||||
|
.url(minioUtil.getObjectNameFullPath(bucketNameFilepath))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -4,10 +4,7 @@ import cn.bunny.common.service.context.BaseContext;
|
||||||
import cn.bunny.common.service.exception.BunnyException;
|
import cn.bunny.common.service.exception.BunnyException;
|
||||||
import cn.bunny.common.service.utils.JwtHelper;
|
import cn.bunny.common.service.utils.JwtHelper;
|
||||||
import cn.bunny.common.service.utils.minio.MinioUtil;
|
import cn.bunny.common.service.utils.minio.MinioUtil;
|
||||||
import cn.bunny.dao.dto.system.user.AdminUserAddDto;
|
import cn.bunny.dao.dto.system.user.*;
|
||||||
import cn.bunny.dao.dto.system.user.AdminUserDto;
|
|
||||||
import cn.bunny.dao.dto.system.user.AdminUserUpdateDto;
|
|
||||||
import cn.bunny.dao.dto.system.user.RefreshTokenDto;
|
|
||||||
import cn.bunny.dao.entity.system.AdminUser;
|
import cn.bunny.dao.entity.system.AdminUser;
|
||||||
import cn.bunny.dao.entity.system.EmailUsers;
|
import cn.bunny.dao.entity.system.EmailUsers;
|
||||||
import cn.bunny.dao.pojo.common.EmailSendInit;
|
import cn.bunny.dao.pojo.common.EmailSendInit;
|
||||||
|
@ -34,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
import org.springframework.data.redis.core.RedisTemplate;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.DigestUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -60,6 +58,7 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private EmailFactory emailFactory;
|
private EmailFactory emailFactory;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private MinioUtil minioUtil;
|
private MinioUtil minioUtil;
|
||||||
|
|
||||||
|
@ -135,6 +134,37 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
|
||||||
return userVo;
|
return userVo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* * 管理员修改管理员用户密码
|
||||||
|
*
|
||||||
|
* @param dto 管理员用户修改密码
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateUserPasswordByAdmin(UserUpdateWithPasswordDto dto) {
|
||||||
|
Long userId = dto.getUserId();
|
||||||
|
String password = dto.getPassword();
|
||||||
|
|
||||||
|
// 对密码加密
|
||||||
|
String md5Password = DigestUtils.md5DigestAsHex(password.getBytes());
|
||||||
|
AdminUser adminUser = getOne(Wrappers.<AdminUser>lambdaQuery().eq(AdminUser::getId, userId));
|
||||||
|
|
||||||
|
// 判断是否存在这个用户
|
||||||
|
if (adminUser == null) {
|
||||||
|
throw new BunnyException(ResultCodeEnum.USER_IS_EMPTY);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断新密码是否与旧密码相同
|
||||||
|
if (adminUser.getPassword().equals(md5Password)) {
|
||||||
|
throw new BunnyException(ResultCodeEnum.UPDATE_NEW_PASSWORD_SAME_AS_OLD_PASSWORD);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新用户密码
|
||||||
|
adminUser = new AdminUser();
|
||||||
|
adminUser.setPassword(md5Password);
|
||||||
|
adminUser.setId(userId);
|
||||||
|
updateById(adminUser);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* * 用户信息 服务实现类
|
* * 用户信息 服务实现类
|
||||||
*
|
*
|
||||||
|
@ -148,9 +178,16 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
|
||||||
IPage<AdminUser> page = baseMapper.selectListByPage(pageParams, dto);
|
IPage<AdminUser> page = baseMapper.selectListByPage(pageParams, dto);
|
||||||
|
|
||||||
List<AdminUserVo> voList = page.getRecords().stream().map(AdminUser -> {
|
List<AdminUserVo> voList = page.getRecords().stream().map(AdminUser -> {
|
||||||
AdminUserVo AdminUserVo = new AdminUserVo();
|
// 如果存在用户头像,则设置用户头像
|
||||||
BeanUtils.copyProperties(AdminUser, AdminUserVo);
|
String avatar = AdminUser.getAvatar();
|
||||||
return AdminUserVo;
|
if (StringUtils.hasText(avatar)) {
|
||||||
|
avatar = minioUtil.getObjectNameFullPath(avatar);
|
||||||
|
}
|
||||||
|
|
||||||
|
AdminUserVo adminUserVo = new AdminUserVo();
|
||||||
|
BeanUtils.copyProperties(AdminUser, adminUserVo);
|
||||||
|
adminUserVo.setAvatar(avatar);
|
||||||
|
return adminUserVo;
|
||||||
}).toList();
|
}).toList();
|
||||||
|
|
||||||
return PageResult.<AdminUserVo>builder()
|
return PageResult.<AdminUserVo>builder()
|
||||||
|
@ -168,9 +205,19 @@ 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();
|
||||||
|
|
||||||
// 保存数据
|
// 保存数据
|
||||||
AdminUser adminUser = new AdminUser();
|
AdminUser adminUser = new AdminUser();
|
||||||
BeanUtils.copyProperties(dto, adminUser);
|
BeanUtils.copyProperties(dto, adminUser);
|
||||||
|
|
||||||
|
// 对密码加密
|
||||||
|
if (StringUtils.hasText(password)) {
|
||||||
|
password = DigestUtils.md5DigestAsHex(password.getBytes());
|
||||||
|
adminUser.setPassword(password);
|
||||||
|
}
|
||||||
|
|
||||||
save(adminUser);
|
save(adminUser);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +228,6 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, AdminUser> implemen
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void updateAdminUser(@Valid AdminUserUpdateDto dto) {
|
public void updateAdminUser(@Valid AdminUserUpdateDto dto) {
|
||||||
// 更新内容
|
|
||||||
AdminUser adminUser = new AdminUser();
|
AdminUser adminUser = new AdminUser();
|
||||||
BeanUtils.copyProperties(dto, adminUser);
|
BeanUtils.copyProperties(dto, adminUser);
|
||||||
updateById(adminUser);
|
updateById(adminUser);
|
||||||
|
|
|
@ -6,6 +6,9 @@ spring:
|
||||||
active: @profiles.active@
|
active: @profiles.active@
|
||||||
application:
|
application:
|
||||||
name: bunny-service
|
name: bunny-service
|
||||||
|
servlet:
|
||||||
|
multipart:
|
||||||
|
max-file-size: 6MB
|
||||||
|
|
||||||
datasource:
|
datasource:
|
||||||
# type: com.zaxxer.hikari.HikariDataSource
|
# type: com.zaxxer.hikari.HikariDataSource
|
||||||
|
|
|
@ -0,0 +1,25 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="cn.bunny.services.mapper.FilesMapper">
|
||||||
|
|
||||||
|
<!-- 通用查询映射结果 -->
|
||||||
|
<resultMap id="BaseResultMap" type="cn.bunny.services.Bunny.Files">
|
||||||
|
<id column="id" property="id"/>
|
||||||
|
<result column="filename" property="filename"/>
|
||||||
|
<result column="filepath" property="filepath"/>
|
||||||
|
<result column="file_size" property="fileSize"/>
|
||||||
|
<result column="file_type" property="fileType"/>
|
||||||
|
<result column="download_count" property="downloadCount"/>
|
||||||
|
<result column="create_user" property="createUser"/>
|
||||||
|
<result column="update_time" property="updateTime"/>
|
||||||
|
<result column="update_user" property="updateUser"/>
|
||||||
|
<result column="create_time" property="createTime"/>
|
||||||
|
<result column="is_deleted" property="isDeleted"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<!-- 通用查询结果列 -->
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id, filename, filepath, file_size, file_type, download_count, create_user, update_time, update_user, create_time, is_deleted
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
</mapper>
|
|
@ -56,7 +56,6 @@
|
||||||
status = #{dto.status}
|
status = #{dto.status}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
</where>
|
||||||
order by update_time
|
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<!-- 物理删除用户信息 -->
|
<!-- 物理删除用户信息 -->
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 29 KiB |
Loading…
Reference in New Issue