From 06887604fda6d13a8052f0a649a5f6299a5cc36b Mon Sep 17 00:00:00 2001 From: Charles7c Date: Sat, 30 Dec 2023 23:01:14 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=AE=8C=E5=96=84=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=A0=A1=E9=AA=8C=E3=80=81=E6=B3=A8=E9=87=8A=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86=E5=90=8E=E7=AB=AF=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/system/model/req/StorageReq.java | 18 ++++++++--------- .../admin/system/model/resp/FileResp.java | 3 ++- .../system/model/resp/StorageDetailResp.java | 20 +++++++++---------- .../admin/system/model/resp/StorageResp.java | 14 ++++++------- .../system/service/impl/DeptServiceImpl.java | 2 +- .../system/service/impl/FileServiceImpl.java | 5 ++--- .../service/impl/StorageServiceImpl.java | 15 ++++++++++---- .../webapi/common/CaptchaController.java | 2 +- .../webapi/tool/GeneratorController.java | 2 +- .../changelog/v2.2.0/continew-admin_table.sql | 2 +- 10 files changed, 45 insertions(+), 38 deletions(-) diff --git a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/model/req/StorageReq.java b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/model/req/StorageReq.java index aaedc5b8..0a44c1b2 100644 --- a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/model/req/StorageReq.java +++ b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/model/req/StorageReq.java @@ -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; /** diff --git a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/model/resp/FileResp.java b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/model/resp/FileResp.java index d903e25f..62766f9f 100644 --- a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/model/resp/FileResp.java +++ b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/model/resp/FileResp.java @@ -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; /** diff --git a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/model/resp/StorageDetailResp.java b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/model/resp/StorageDetailResp.java index 3146d25d..c6151d28 100644 --- a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/model/resp/StorageDetailResp.java +++ b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/model/resp/StorageDetailResp.java @@ -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; /** diff --git a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/model/resp/StorageResp.java b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/model/resp/StorageResp.java index 6d568a1d..01d10479 100644 --- a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/model/resp/StorageResp.java +++ b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/model/resp/StorageResp.java @@ -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; /** diff --git a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/DeptServiceImpl.java b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/DeptServiceImpl.java index 820e816e..f7573765 100644 --- a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/DeptServiceImpl.java +++ b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/DeptServiceImpl.java @@ -57,9 +57,9 @@ import top.charles7c.continew.starter.extension.crud.base.BaseServiceImpl; public class DeptServiceImpl extends BaseServiceImpl implements DeptService { - private final RoleDeptService roleDeptService; @Resource private UserService userService; + private final RoleDeptService roleDeptService; @Override public Long add(DeptReq req) { diff --git a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/FileServiceImpl.java b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/FileServiceImpl.java index 80f2ad1a..3f09dd99 100644 --- a/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/FileServiceImpl.java +++ b/continew-admin-system/src/main/java/top/charles7c/continew/admin/system/service/impl/FileServiceImpl.java @@ -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 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)); } diff --git a/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/webapi/common/CaptchaController.java b/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/webapi/common/CaptchaController.java index 81004e71..a2233139 100644 --- a/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/webapi/common/CaptchaController.java +++ b/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/webapi/common/CaptchaController.java @@ -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) diff --git a/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/webapi/tool/GeneratorController.java b/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/webapi/tool/GeneratorController.java index 9d5e78ca..d4a2589d 100644 --- a/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/webapi/tool/GeneratorController.java +++ b/continew-admin-webapi/src/main/java/top/charles7c/continew/admin/webapi/tool/GeneratorController.java @@ -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") diff --git a/continew-admin-webapi/src/main/resources/db/changelog/v2.2.0/continew-admin_table.sql b/continew-admin-webapi/src/main/resources/db/changelog/v2.2.0/continew-admin_table.sql index 53f14d04..d1d0a4f5 100644 --- a/continew-admin-webapi/src/main/resources/db/changelog/v2.2.0/continew-admin_table.sql +++ b/continew-admin-webapi/src/main/resources/db/changelog/v2.2.0/continew-admin_table.sql @@ -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 '自定义域名',