refactor: 优化存储管理相关 API,合并 StorageResp 及 StorageDetailResp

This commit is contained in:
Charles7c 2024-04-10 22:17:00 +08:00
parent a2cf072609
commit f7b5a4ff8d
7 changed files with 36 additions and 180 deletions

View File

@ -38,15 +38,15 @@ public class StorageQuery implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** /**
* 名称 * 关键词
*/ */
@Schema(description = "名称") @Schema(description = "关键词", example = "本地存储")
@Query(type = QueryType.LIKE) @Query(columns = {"name", "description"}, type = QueryType.LIKE)
private String name; private String description;
/** /**
* 状态 * 状态
*/ */
@Schema(description = "状态") @Schema(description = "状态1启用2禁用", example = "1")
private Integer status; private Integer status;
} }

View File

@ -16,21 +16,19 @@
package top.charles7c.continew.admin.system.model.req; 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 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 org.hibernate.validator.constraints.Length;
import top.charles7c.continew.admin.common.constant.RegexConstants; import top.charles7c.continew.admin.common.constant.RegexConstants;
import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum; import top.charles7c.continew.admin.common.enums.DisEnableStatusEnum;
import top.charles7c.continew.admin.system.enums.StorageTypeEnum; import top.charles7c.continew.admin.system.enums.StorageTypeEnum;
import top.charles7c.continew.starter.extension.crud.model.req.BaseReq; 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} 个字符") @Length(max = 255, message = "自定义域名长度不能超过 {max} 个字符")
private String domain; private String domain;
/**
* 排序
*/
@Schema(description = "排序", example = "1")
private Integer sort;
/** /**
* 描述 * 描述
*/ */
@ -116,12 +120,6 @@ public class StorageReq extends BaseReq {
@NotNull(message = "是否为默认存储不能为空") @NotNull(message = "是否为默认存储不能为空")
private Boolean isDefault; private Boolean isDefault;
/**
* 排序
*/
@Schema(description = "排序", example = "1")
private Integer sort;
/** /**
* 状态 * 状态
*/ */

View File

@ -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();
}
}

View File

@ -16,17 +16,14 @@
package top.charles7c.continew.admin.system.model.resp; 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 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.common.enums.DisEnableStatusEnum;
import top.charles7c.continew.admin.system.enums.StorageTypeEnum; 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 @Data
@Schema(description = "存储库信息") @Schema(description = "存储库信息")
public class StorageResp extends BaseResp { public class StorageResp extends BaseDetailResp {
@Serial @Serial
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -53,6 +50,12 @@ public class StorageResp extends BaseResp {
@Schema(description = "编码", example = "local") @Schema(description = "编码", example = "local")
private String code; 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") @Schema(description = "排序", example = "1")
private Integer sort; private Integer sort;
/**
* 状态
*/
@Schema(description = "状态1启用2禁用", type = "Integer", allowableValues = {"1", "2"}, example = "1")
private DisEnableStatusEnum status;
@Override @Override
public Boolean getDisabled() { public Boolean getDisabled() {
return this.getIsDefault(); return this.getIsDefault();

View File

@ -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.entity.StorageDO;
import top.charles7c.continew.admin.system.model.query.StorageQuery; 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.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.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.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 * @author Charles7c
* @since 2023/12/26 22:09 * @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> {
/** /**
* 查询默认存储库 * 查询默认存储库

View File

@ -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.entity.StorageDO;
import top.charles7c.continew.admin.system.model.query.StorageQuery; 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.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.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;
@ -56,7 +55,7 @@ import java.util.concurrent.CopyOnWriteArrayList;
*/ */
@Service @Service
@RequiredArgsConstructor @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 @Resource
private FileService fileService; private FileService fileService;

View File

@ -17,16 +17,14 @@
package top.charles7c.continew.admin.webapi.system; package top.charles7c.continew.admin.webapi.system;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import top.charles7c.continew.admin.system.model.query.StorageQuery; 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.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.model.resp.StorageResp;
import top.charles7c.continew.admin.system.service.StorageService; import top.charles7c.continew.admin.system.service.StorageService;
import top.charles7c.continew.starter.extension.crud.annotation.CrudRequestMapping; import top.charles7c.continew.starter.extension.crud.annotation.CrudRequestMapping;
import top.charles7c.continew.starter.extension.crud.controller.BaseController; import top.charles7c.continew.starter.extension.crud.controller.BaseController;
import top.charles7c.continew.starter.extension.crud.enums.Api;
/** /**
* 存储库管理 API * 存储库管理 API
@ -36,5 +34,5 @@ import top.charles7c.continew.starter.extension.crud.controller.BaseController;
*/ */
@Tag(name = "存储库管理 API") @Tag(name = "存储库管理 API")
@RestController @RestController
@CrudRequestMapping("/system/storage") @CrudRequestMapping(value = "/system/storage", api = {Api.PAGE, Api.GET, Api.ADD, Api.UPDATE, Api.DELETE})
public class StorageController extends BaseController<StorageService, StorageResp, StorageDetailResp, StorageQuery, StorageReq> {} public class StorageController extends BaseController<StorageService, StorageResp, StorageResp, StorageQuery, StorageReq> {}