mirror of
				https://github.com/continew-org/continew-admin.git
				synced 2025-10-31 10:57:13 +08:00 
			
		
		
		
	refactor: 优化存储管理相关 API,合并 StorageResp 及 StorageDetailResp
This commit is contained in:
		| @@ -38,15 +38,15 @@ public class StorageQuery implements Serializable { | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 名称 | ||||
|      * 关键词 | ||||
|      */ | ||||
|     @Schema(description = "名称") | ||||
|     @Query(type = QueryType.LIKE) | ||||
|     private String name; | ||||
|     @Schema(description = "关键词", example = "本地存储") | ||||
|     @Query(columns = {"name", "description"}, type = QueryType.LIKE) | ||||
|     private String description; | ||||
|  | ||||
|     /** | ||||
|      * 状态 | ||||
|      */ | ||||
|     @Schema(description = "状态") | ||||
|     @Schema(description = "状态(1:启用;2:禁用)", example = "1") | ||||
|     private Integer status; | ||||
| } | ||||
| @@ -16,21 +16,19 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.model.req; | ||||
|  | ||||
| import java.io.Serial; | ||||
|  | ||||
| import jakarta.validation.constraints.*; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
|  | ||||
| import jakarta.validation.constraints.NotBlank; | ||||
| import jakarta.validation.constraints.NotNull; | ||||
| import jakarta.validation.constraints.Pattern; | ||||
| import lombok.Data; | ||||
| import org.hibernate.validator.constraints.Length; | ||||
|  | ||||
| import top.charles7c.continew.admin.common.constant.RegexConstants; | ||||
| import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum; | ||||
| import top.charles7c.continew.admin.system.enums.StorageTypeEnum; | ||||
| import top.charles7c.continew.starter.extension.crud.model.req.BaseReq; | ||||
|  | ||||
| import java.io.Serial; | ||||
|  | ||||
| /** | ||||
|  * 创建或修改存储库信息 | ||||
|  * | ||||
| @@ -102,6 +100,12 @@ public class StorageReq extends BaseReq { | ||||
|     @Length(max = 255, message = "自定义域名长度不能超过 {max} 个字符") | ||||
|     private String domain; | ||||
|  | ||||
|     /** | ||||
|      * 排序 | ||||
|      */ | ||||
|     @Schema(description = "排序", example = "1") | ||||
|     private Integer sort; | ||||
|  | ||||
|     /** | ||||
|      * 描述 | ||||
|      */ | ||||
| @@ -116,12 +120,6 @@ public class StorageReq extends BaseReq { | ||||
|     @NotNull(message = "是否为默认存储不能为空") | ||||
|     private Boolean isDefault; | ||||
|  | ||||
|     /** | ||||
|      * 排序 | ||||
|      */ | ||||
|     @Schema(description = "排序", example = "1") | ||||
|     private Integer sort; | ||||
|  | ||||
|     /** | ||||
|      * 状态 | ||||
|      */ | ||||
|   | ||||
| @@ -1,135 +0,0 @@ | ||||
| /* | ||||
|  * Copyright (c) 2022-present Charles7c Authors. All Rights Reserved. | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|  * you may not use this file except in compliance with the License. | ||||
|  * You may obtain a copy of the License at | ||||
|  * | ||||
|  *     http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, | ||||
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
|  * See the License for the specific language governing permissions and | ||||
|  * limitations under the License. | ||||
|  */ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.model.resp; | ||||
|  | ||||
| import java.io.Serial; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
|  | ||||
| import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||||
| import com.alibaba.excel.annotation.ExcelProperty; | ||||
|  | ||||
| import top.charles7c.continew.starter.extension.crud.converter.ExcelBaseEnumConverter; | ||||
| import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum; | ||||
| import top.charles7c.continew.admin.system.enums.StorageTypeEnum; | ||||
| import top.charles7c.continew.starter.extension.crud.model.resp.BaseDetailResp; | ||||
|  | ||||
| /** | ||||
|  * 存储库详情信息 | ||||
|  * | ||||
|  * @author Charles7c | ||||
|  * @since 2023/12/26 22:09 | ||||
|  */ | ||||
| @Data | ||||
| @ExcelIgnoreUnannotated | ||||
| @Schema(description = "存储库详情信息") | ||||
| public class StorageDetailResp extends BaseDetailResp { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 1L; | ||||
|  | ||||
|     /** | ||||
|      * 名称 | ||||
|      */ | ||||
|     @Schema(description = "名称", example = "存储库1") | ||||
|     @ExcelProperty(value = "名称") | ||||
|     private String name; | ||||
|  | ||||
|     /** | ||||
|      * 编码 | ||||
|      */ | ||||
|     @Schema(description = "编码", example = "local") | ||||
|     @ExcelProperty(value = "编码") | ||||
|     private String code; | ||||
|  | ||||
|     /** | ||||
|      * 类型 | ||||
|      */ | ||||
|     @Schema(description = "类型(1:兼容S3协议存储;2:本地存储)", type = "Integer", allowableValues = {"1", "2"}, example = "2") | ||||
|     @ExcelProperty(value = "类型", converter = ExcelBaseEnumConverter.class) | ||||
|     private StorageTypeEnum type; | ||||
|  | ||||
|     /** | ||||
|      * 访问密钥 | ||||
|      */ | ||||
|     @Schema(description = "访问密钥", example = "") | ||||
|     @ExcelProperty(value = "访问密钥") | ||||
|     private String accessKey; | ||||
|  | ||||
|     /** | ||||
|      * 私有密钥 | ||||
|      */ | ||||
|     @Schema(description = "私有密钥", example = "") | ||||
|     @ExcelProperty(value = "私有密钥") | ||||
|     private String secretKey; | ||||
|  | ||||
|     /** | ||||
|      * 终端节点 | ||||
|      */ | ||||
|     @Schema(description = "终端节点", example = "") | ||||
|     @ExcelProperty(value = "终端节点") | ||||
|     private String endpoint; | ||||
|  | ||||
|     /** | ||||
|      * 桶名称 | ||||
|      */ | ||||
|     @Schema(description = "桶名称", example = "C:/continew-admin/data/file/") | ||||
|     @ExcelProperty(value = "桶名称") | ||||
|     private String bucketName; | ||||
|  | ||||
|     /** | ||||
|      * 自定义域名 | ||||
|      */ | ||||
|     @Schema(description = "自定义域名", example = "http://localhost:8000/file") | ||||
|     @ExcelProperty(value = "自定义域名") | ||||
|     private String domain; | ||||
|  | ||||
|     /** | ||||
|      * 描述 | ||||
|      */ | ||||
|     @Schema(description = "描述", example = "存储库描述") | ||||
|     @ExcelProperty(value = "描述") | ||||
|     private String description; | ||||
|  | ||||
|     /** | ||||
|      * 是否为默认存储 | ||||
|      */ | ||||
|     @Schema(description = "是否为默认存储", example = "true") | ||||
|     @ExcelProperty(value = "是否为默认存储") | ||||
|     private Boolean isDefault; | ||||
|  | ||||
|     /** | ||||
|      * 排序 | ||||
|      */ | ||||
|     @Schema(description = "排序", example = "1") | ||||
|     @ExcelProperty(value = "排序") | ||||
|     private Integer sort; | ||||
|  | ||||
|     /** | ||||
|      * 状态 | ||||
|      */ | ||||
|     @Schema(description = "状态(1:启用;2:禁用)", type = "Integer", allowableValues = {"1", "2"}, example = "1") | ||||
|     @ExcelProperty(value = "状态", converter = ExcelBaseEnumConverter.class) | ||||
|     private DisEnableStatusEnum status; | ||||
|  | ||||
|     @Override | ||||
|     public Boolean getDisabled() { | ||||
|         return this.getIsDefault(); | ||||
|     } | ||||
| } | ||||
| @@ -16,17 +16,14 @@ | ||||
|  | ||||
| package top.charles7c.continew.admin.system.model.resp; | ||||
|  | ||||
| import java.io.Serial; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
|  | ||||
| import com.fasterxml.jackson.annotation.JsonIgnore; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.Data; | ||||
| import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum; | ||||
| import top.charles7c.continew.admin.system.enums.StorageTypeEnum; | ||||
| import top.charles7c.continew.starter.extension.crud.model.resp.BaseResp; | ||||
| import top.charles7c.continew.starter.extension.crud.model.resp.BaseDetailResp; | ||||
|  | ||||
| import java.io.Serial; | ||||
|  | ||||
| /** | ||||
|  * 存储库信息 | ||||
| @@ -36,7 +33,7 @@ import top.charles7c.continew.starter.extension.crud.model.resp.BaseResp; | ||||
|  */ | ||||
| @Data | ||||
| @Schema(description = "存储库信息") | ||||
| public class StorageResp extends BaseResp { | ||||
| public class StorageResp extends BaseDetailResp { | ||||
|  | ||||
|     @Serial | ||||
|     private static final long serialVersionUID = 1L; | ||||
| @@ -53,6 +50,12 @@ public class StorageResp extends BaseResp { | ||||
|     @Schema(description = "编码", example = "local") | ||||
|     private String code; | ||||
|  | ||||
|     /** | ||||
|      * 状态 | ||||
|      */ | ||||
|     @Schema(description = "状态(1:启用;2:禁用)", type = "Integer", allowableValues = {"1", "2"}, example = "1") | ||||
|     private DisEnableStatusEnum status; | ||||
|  | ||||
|     /** | ||||
|      * 类型 | ||||
|      */ | ||||
| @@ -108,12 +111,6 @@ public class StorageResp extends BaseResp { | ||||
|     @Schema(description = "排序", example = "1") | ||||
|     private Integer sort; | ||||
|  | ||||
|     /** | ||||
|      * 状态 | ||||
|      */ | ||||
|     @Schema(description = "状态(1:启用;2:禁用)", type = "Integer", allowableValues = {"1", "2"}, example = "1") | ||||
|     private DisEnableStatusEnum status; | ||||
|  | ||||
|     @Override | ||||
|     public Boolean getDisabled() { | ||||
|         return this.getIsDefault(); | ||||
|   | ||||
| @@ -19,10 +19,9 @@ package top.charles7c.continew.admin.system.service; | ||||
| import top.charles7c.continew.admin.system.model.entity.StorageDO; | ||||
| import top.charles7c.continew.admin.system.model.query.StorageQuery; | ||||
| import top.charles7c.continew.admin.system.model.req.StorageReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.StorageDetailResp; | ||||
| import top.charles7c.continew.admin.system.model.resp.StorageResp; | ||||
| import top.charles7c.continew.starter.extension.crud.service.BaseService; | ||||
| import top.charles7c.continew.starter.data.mybatis.plus.service.IService; | ||||
| import top.charles7c.continew.starter.extension.crud.service.BaseService; | ||||
|  | ||||
| /** | ||||
|  * 存储库业务接口 | ||||
| @@ -30,7 +29,7 @@ import top.charles7c.continew.starter.data.mybatis.plus.service.IService; | ||||
|  * @author Charles7c | ||||
|  * @since 2023/12/26 22:09 | ||||
|  */ | ||||
| public interface StorageService extends BaseService<StorageResp, StorageDetailResp, StorageQuery, StorageReq>, IService<StorageDO> { | ||||
| public interface StorageService extends BaseService<StorageResp, StorageResp, StorageQuery, StorageReq>, IService<StorageDO> { | ||||
|  | ||||
|     /** | ||||
|      * 查询默认存储库 | ||||
|   | ||||
| @@ -33,7 +33,6 @@ import top.charles7c.continew.admin.system.mapper.StorageMapper; | ||||
| import top.charles7c.continew.admin.system.model.entity.StorageDO; | ||||
| import top.charles7c.continew.admin.system.model.query.StorageQuery; | ||||
| import top.charles7c.continew.admin.system.model.req.StorageReq; | ||||
| import top.charles7c.continew.admin.system.model.resp.StorageDetailResp; | ||||
| 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; | ||||
| @@ -56,7 +55,7 @@ import java.util.concurrent.CopyOnWriteArrayList; | ||||
|  */ | ||||
| @Service | ||||
| @RequiredArgsConstructor | ||||
| public class StorageServiceImpl extends BaseServiceImpl<StorageMapper, StorageDO, StorageResp, StorageDetailResp, StorageQuery, StorageReq> implements StorageService { | ||||
| public class StorageServiceImpl extends BaseServiceImpl<StorageMapper, StorageDO, StorageResp, StorageResp, StorageQuery, StorageReq> implements StorageService { | ||||
|  | ||||
|     @Resource | ||||
|     private FileService fileService; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user