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