refactor: 完善部分校验、注释,优化部分后端代码格式
This commit is contained in:
parent
89e4326290
commit
06887604fd
continew-admin-system/src/main/java/top/charles7c/continew/admin/system
model
service/impl
continew-admin-webapi/src/main
java/top/charles7c/continew/admin/webapi
resources/db/changelog/v2.2.0
@ -68,24 +68,24 @@ public class StorageReq extends BaseReq {
|
||||
private StorageTypeEnum type;
|
||||
|
||||
/**
|
||||
* Access Key
|
||||
* 访问密钥
|
||||
*/
|
||||
@Schema(description = "Access Key", example = "")
|
||||
@Length(max = 255, message = "Access Key长度不能超过 {max} 个字符")
|
||||
@Schema(description = "访问密钥", example = "")
|
||||
@Length(max = 255, message = "访问密钥长度不能超过 {max} 个字符")
|
||||
private String accessKey;
|
||||
|
||||
/**
|
||||
* Secret Key
|
||||
* 私有密钥
|
||||
*/
|
||||
@Schema(description = "Secret Key", example = "")
|
||||
@Length(max = 255, message = "Secret Key长度不能超过 {max} 个字符")
|
||||
@Schema(description = "私有密钥", example = "")
|
||||
@Length(max = 255, message = "私有密钥长度不能超过 {max} 个字符")
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
* Endpoint
|
||||
* 终端节点
|
||||
*/
|
||||
@Schema(description = "Endpoint", example = "")
|
||||
@Length(max = 255, message = "Endpoint长度不能超过 {max} 个字符")
|
||||
@Schema(description = "终端节点", example = "")
|
||||
@Length(max = 255, message = "终端节点长度不能超过 {max} 个字符")
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
|
@ -68,7 +68,8 @@ public class FileResp extends BaseDetailResp {
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@Schema(description = "类型", type = "Integer", allowableValues = {"1", "2", "3", "4", "5"}, example = "2")
|
||||
@Schema(description = "类型(1:其他;2:图片;3:文档;4:视频;5:音频)", type = "Integer", allowableValues = {"1", "2", "3", "4", "5"},
|
||||
example = "2")
|
||||
private FileTypeEnum type;
|
||||
|
||||
/**
|
||||
|
@ -61,29 +61,29 @@ public class StorageDetailResp extends BaseDetailResp {
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@Schema(description = "类型", type = "Integer", allowableValues = {"1", "2"}, example = "2")
|
||||
@Schema(description = "类型(1:兼容S3协议存储;2:本地存储)", type = "Integer", allowableValues = {"1", "2"}, example = "2")
|
||||
@ExcelProperty(value = "类型", converter = ExcelBaseEnumConverter.class)
|
||||
private StorageTypeEnum type;
|
||||
|
||||
/**
|
||||
* Access Key
|
||||
* 访问密钥
|
||||
*/
|
||||
@Schema(description = "Access Key", example = "")
|
||||
@ExcelProperty(value = "Access Key")
|
||||
@Schema(description = "访问密钥", example = "")
|
||||
@ExcelProperty(value = "访问密钥")
|
||||
private String accessKey;
|
||||
|
||||
/**
|
||||
* Secret Key
|
||||
* 私有密钥
|
||||
*/
|
||||
@Schema(description = "Secret Key", example = "")
|
||||
@ExcelProperty(value = "Secret Key")
|
||||
@Schema(description = "私有密钥", example = "")
|
||||
@ExcelProperty(value = "私有密钥")
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
* Endpoint
|
||||
* 终端节点
|
||||
*/
|
||||
@Schema(description = "Endpoint", example = "")
|
||||
@ExcelProperty(value = "Endpoint")
|
||||
@Schema(description = "终端节点", example = "")
|
||||
@ExcelProperty(value = "终端节点")
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
|
@ -56,26 +56,26 @@ public class StorageResp extends BaseResp {
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
@Schema(description = "类型", type = "Integer", allowableValues = {"1", "2"}, example = "2")
|
||||
@Schema(description = "类型(1:兼容S3协议存储;2:本地存储)", type = "Integer", allowableValues = {"1", "2"}, example = "2")
|
||||
private StorageTypeEnum type;
|
||||
|
||||
/**
|
||||
* Access Key
|
||||
* 访问密钥
|
||||
*/
|
||||
@Schema(description = "Access Key", example = "")
|
||||
@Schema(description = "访问密钥", example = "")
|
||||
private String accessKey;
|
||||
|
||||
/**
|
||||
* Secret Key
|
||||
* 私有密钥
|
||||
*/
|
||||
@Schema(description = "Secret Key", example = "")
|
||||
@Schema(description = "私有密钥", example = "")
|
||||
@JsonIgnore
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
* Endpoint
|
||||
* 终端节点
|
||||
*/
|
||||
@Schema(description = "Endpoint", example = "")
|
||||
@Schema(description = "终端节点", example = "")
|
||||
private String endpoint;
|
||||
|
||||
/**
|
||||
|
@ -57,9 +57,9 @@ import top.charles7c.continew.starter.extension.crud.base.BaseServiceImpl;
|
||||
public class DeptServiceImpl extends BaseServiceImpl<DeptMapper, DeptDO, DeptResp, DeptDetailResp, DeptQuery, DeptReq>
|
||||
implements DeptService {
|
||||
|
||||
private final RoleDeptService roleDeptService;
|
||||
@Resource
|
||||
private UserService userService;
|
||||
private final RoleDeptService roleDeptService;
|
||||
|
||||
@Override
|
||||
public Long add(DeptReq req) {
|
||||
|
@ -42,7 +42,6 @@ import top.charles7c.continew.admin.system.model.resp.FileResp;
|
||||
import top.charles7c.continew.admin.system.model.resp.StorageDetailResp;
|
||||
import top.charles7c.continew.admin.system.service.FileService;
|
||||
import top.charles7c.continew.admin.system.service.StorageService;
|
||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||
import top.charles7c.continew.starter.core.util.URLUtils;
|
||||
import top.charles7c.continew.starter.core.util.validate.CheckUtils;
|
||||
import top.charles7c.continew.starter.extension.crud.base.BaseServiceImpl;
|
||||
@ -107,7 +106,7 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes
|
||||
// 处理本地存储文件 URL
|
||||
FileInfo fileInfo = uploadPretreatment.upload();
|
||||
fileInfo.setUrl(StorageTypeEnum.LOCAL.equals(storage.getType())
|
||||
? URLUtil.normalize(storage.getDomain() + StringConstants.SLASH + fileInfo.getUrl()) : fileInfo.getUrl());
|
||||
? URLUtil.normalize(storage.getDomain() + fileInfo.getUrl()) : fileInfo.getUrl());
|
||||
return fileInfo;
|
||||
}
|
||||
|
||||
@ -120,7 +119,7 @@ public class FileServiceImpl extends BaseServiceImpl<FileMapper, FileDO, FileRes
|
||||
protected void fill(Object baseObj) {
|
||||
if (baseObj instanceof FileResp fileResp && !URLUtils.isHttpUrl(fileResp.getUrl())) {
|
||||
StorageDetailResp storage = storageService.get(fileResp.getStorageId());
|
||||
fileResp.setUrl(URLUtil.normalize(storage.getDomain() + StringConstants.SLASH + fileResp.getUrl()));
|
||||
fileResp.setUrl(URLUtil.normalize(storage.getDomain() + fileResp.getUrl()));
|
||||
}
|
||||
super.fill(baseObj);
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ import top.charles7c.continew.admin.system.model.resp.StorageResp;
|
||||
import top.charles7c.continew.admin.system.service.FileService;
|
||||
import top.charles7c.continew.admin.system.service.StorageService;
|
||||
import top.charles7c.continew.starter.core.constant.StringConstants;
|
||||
import top.charles7c.continew.starter.core.util.URLUtils;
|
||||
import top.charles7c.continew.starter.core.util.validate.CheckUtils;
|
||||
import top.charles7c.continew.starter.core.util.validate.ValidationUtils;
|
||||
import top.charles7c.continew.starter.extension.crud.base.BaseServiceImpl;
|
||||
@ -130,10 +131,16 @@ public class StorageServiceImpl
|
||||
public void load(StorageReq req) {
|
||||
CopyOnWriteArrayList<FileStorage> fileStorageList = fileStorageService.getFileStorageList();
|
||||
String bucketName = req.getBucketName();
|
||||
String domain = req.getDomain();
|
||||
StorageTypeEnum type = req.getType();
|
||||
switch (type) {
|
||||
case LOCAL -> {
|
||||
ValidationUtils.throwIfBlank(bucketName, "存储路径不能为空");
|
||||
ValidationUtils.throwIfBlank(domain, "自定义域名不能为空");
|
||||
ValidationUtils.throwIf(!URLUtils.isHttpUrl(domain), "自定义域名格式错误");
|
||||
req.setDomain(StrUtil.appendIfMissing(domain, StringConstants.SLASH));
|
||||
req.setBucketName(StrUtil.appendIfMissing(
|
||||
bucketName.replace(StringConstants.BACKSLASH, StringConstants.SLASH), StringConstants.SLASH));
|
||||
FileStorageProperties.LocalPlusConfig config = new FileStorageProperties.LocalPlusConfig();
|
||||
config.setPlatform(req.getCode());
|
||||
config.setStoragePath(bucketName);
|
||||
@ -145,9 +152,9 @@ public class StorageServiceImpl
|
||||
String accessKey = req.getAccessKey();
|
||||
String secretKey = req.getSecretKey();
|
||||
String endpoint = req.getEndpoint();
|
||||
ValidationUtils.throwIfBlank(accessKey, "Access Key不能为空");
|
||||
ValidationUtils.throwIfBlank(secretKey, "Secret Key不能为空");
|
||||
ValidationUtils.throwIfBlank(endpoint, "Endpoint不能为空");
|
||||
ValidationUtils.throwIfBlank(accessKey, "访问密钥不能为空");
|
||||
ValidationUtils.throwIfBlank(secretKey, "私有密钥不能为空");
|
||||
ValidationUtils.throwIfBlank(endpoint, "终端节点不能为空");
|
||||
ValidationUtils.throwIfBlank(bucketName, "桶名称不能为空");
|
||||
FileStorageProperties.AmazonS3Config config = new FileStorageProperties.AmazonS3Config();
|
||||
config.setPlatform(req.getCode());
|
||||
@ -155,7 +162,7 @@ public class StorageServiceImpl
|
||||
config.setSecretKey(secretKey);
|
||||
config.setEndPoint(endpoint);
|
||||
config.setBucketName(bucketName);
|
||||
config.setDomain(req.getDomain());
|
||||
config.setDomain(domain);
|
||||
fileStorageList.addAll(
|
||||
FileStorageServiceBuilder.buildAmazonS3FileStorage(Collections.singletonList(config), null));
|
||||
}
|
||||
|
@ -81,8 +81,8 @@ import top.charles7c.continew.starter.messaging.mail.util.MailUtils;
|
||||
public class CaptchaController {
|
||||
|
||||
private final CaptchaService captchaService;
|
||||
private final CaptchaProperties captchaProperties;
|
||||
private final ProjectProperties projectProperties;
|
||||
private final CaptchaProperties captchaProperties;
|
||||
private final GraphicCaptchaProperties graphicCaptchaProperties;
|
||||
|
||||
@Log(ignore = true)
|
||||
|
@ -57,8 +57,8 @@ import top.charles7c.continew.starter.extension.crud.model.resp.R;
|
||||
@RequestMapping("/tool/generator")
|
||||
public class GeneratorController {
|
||||
|
||||
private final GeneratorService generatorService;
|
||||
private final ProjectProperties projectProperties;
|
||||
private final GeneratorService generatorService;
|
||||
|
||||
@Operation(summary = "分页查询数据表", description = "分页查询数据表")
|
||||
@SaCheckPermission("tool:generator:list")
|
||||
|
@ -26,7 +26,7 @@ CREATE TABLE IF NOT EXISTS `sys_storage` (
|
||||
`code` varchar(30) NOT NULL COMMENT '编码',
|
||||
`type` tinyint(1) UNSIGNED NOT NULL DEFAULT 1 COMMENT '类型(1:兼容S3协议存储;2:本地存储)',
|
||||
`access_key` varchar(255) DEFAULT NULL COMMENT 'Access Key(访问密钥)',
|
||||
`secret_key` varchar(255) DEFAULT NULL COMMENT 'Secret Key(私有访问密钥)',
|
||||
`secret_key` varchar(255) DEFAULT NULL COMMENT 'Secret Key(私有密钥)',
|
||||
`endpoint` varchar(255) DEFAULT NULL COMMENT 'Endpoint(终端节点)',
|
||||
`bucket_name` varchar(255) DEFAULT NULL COMMENT '桶名称',
|
||||
`domain` varchar(255) NOT NULL DEFAULT '' COMMENT '自定义域名',
|
||||
|
Loading…
Reference in New Issue
Block a user