Skip to content

Commit

Permalink
refactor: 优化存储管理相关 API,合并 StorageResp 及 StorageDetailResp
Browse files Browse the repository at this point in the history
  • Loading branch information
Charles7c committed Apr 10, 2024
1 parent a2cf072 commit f7b5a4f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 180 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* 创建或修改存储库信息
*
Expand Down Expand Up @@ -102,6 +100,12 @@ public class StorageReq extends BaseReq {
@Length(max = 255, message = "自定义域名长度不能超过 {max} 个字符")
private String domain;

/**
* 排序
*/
@Schema(description = "排序", example = "1")
private Integer sort;

/**
* 描述
*/
Expand All @@ -116,12 +120,6 @@ public class StorageReq extends BaseReq {
@NotNull(message = "是否为默认存储不能为空")
private Boolean isDefault;

/**
* 排序
*/
@Schema(description = "排序", example = "1")
private Integer sort;

/**
* 状态
*/
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
* 存储库信息
Expand All @@ -36,7 +33,7 @@
*/
@Data
@Schema(description = "存储库信息")
public class StorageResp extends BaseResp {
public class StorageResp extends BaseDetailResp {

@Serial
private static final long serialVersionUID = 1L;
Expand All @@ -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;

/**
* 类型
*/
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@
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;

/**
* 存储库业务接口
*
* @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> {

/**
* 查询默认存储库
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
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;
Expand All @@ -56,7 +55,7 @@
*/
@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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,14 @@
package top.charles7c.continew.admin.webapi.system;

import io.swagger.v3.oas.annotations.tags.Tag;

import org.springframework.web.bind.annotation.*;

import org.springframework.web.bind.annotation.RestController;
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.StorageService;
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.enums.Api;

/**
* 存储库管理 API
Expand All @@ -36,5 +34,5 @@
*/
@Tag(name = "存储库管理 API")
@RestController
@CrudRequestMapping("/system/storage")
public class StorageController extends BaseController<StorageService, StorageResp, StorageDetailResp, StorageQuery, StorageReq> {}
@CrudRequestMapping(value = "/system/storage", api = {Api.PAGE, Api.GET, Api.ADD, Api.UPDATE, Api.DELETE})
public class StorageController extends BaseController<StorageService, StorageResp, StorageResp, StorageQuery, StorageReq> {}

0 comments on commit f7b5a4f

Please sign in to comment.