diff --git a/src/main/java/com/cmhi/cf/controller/OperationLogApi.java b/src/main/java/com/cmhi/cf/controller/OperationLogApi.java index fda6f6e..896d74a 100644 --- a/src/main/java/com/cmhi/cf/controller/OperationLogApi.java +++ b/src/main/java/com/cmhi/cf/controller/OperationLogApi.java @@ -4,6 +4,7 @@ import com.cmhi.cf.common.ErrorCode; import com.cmhi.cf.misc.HelperUtils; import com.cmhi.cf.restapi.annotation.EncryptionProtocol; import com.cmhi.cf.restapi.annotation.OperationLogAnnotation; +import com.cmhi.cf.restapi.pojo.base.BasePageResultResp; import com.cmhi.cf.restapi.pojo.base.BaseRespStatus; import com.cmhi.cf.restapi.pojo.dto.OperationLogDetailsReq; import com.cmhi.cf.restapi.pojo.dto.OperationLogReq; @@ -12,7 +13,6 @@ import com.cmhi.cf.restapi.pojo.po.OperationLogDetails; import com.cmhi.cf.restapi.pojo.po.OperationLogSummary; import com.cmhi.cf.restapi.pojo.po.PageResults; import com.cmhi.cf.restapi.pojo.vo.OperationLogDetailsResp; -import com.cmhi.cf.restapi.pojo.vo.OperationLogSummaryResp; import com.cmhi.cf.restapi.pojo.vo.ProtocolResp; import com.cmhi.cf.service.OperationLogService; import com.cmhi.cf.validation.group.ValidGroups; @@ -49,11 +49,11 @@ public class OperationLogApi { PageResults ret = operationLogService.getOperationLogSummary(req.getPageNumber(), req.getPageSize(), req.getTotalSize(), req.getUserName()); - return ProtocolResp.result(OperationLogSummaryResp.builder() - .operationLog(ret) - .status(ErrorCode.ERR_OK.getCode()) - .message(new String[] {ErrorCode.ERR_OK.getDescription()}) - .build()); + return ProtocolResp.result(BasePageResultResp.builder() + .items(ret) + .status(ErrorCode.ERR_OK.getCode()) + .message(new String[] {ErrorCode.ERR_OK.getDescription()}) + .build()); } else { return ProtocolResp.result(ErrorCode.ERR_PARAMEXCEPTION, ErrorCode.ERR_PARAMEXCEPTION.getHttpCode(), diff --git a/src/main/java/com/cmhi/cf/restapi/pojo/base/BasePageResultResp.java b/src/main/java/com/cmhi/cf/restapi/pojo/base/BasePageResultResp.java new file mode 100644 index 0000000..7cf762e --- /dev/null +++ b/src/main/java/com/cmhi/cf/restapi/pojo/base/BasePageResultResp.java @@ -0,0 +1,22 @@ +package com.cmhi.cf.restapi.pojo.base; + +import com.cmhi.cf.restapi.pojo.po.PageResults; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonPropertyOrder; +import lombok.Builder; +import lombok.Data; +import lombok.EqualsAndHashCode; + +@EqualsAndHashCode(callSuper = true) +@Data +@JsonInclude(JsonInclude.Include.NON_NULL) +@JsonPropertyOrder({"items", "status", "message"}) +public class BasePageResultResp extends BaseRespStatus { + private PageResults items; + + @Builder + public BasePageResultResp(PageResults items, Integer status, String[] message) { + super(status, message); + this.items = items; + } +} diff --git a/src/main/java/com/cmhi/cf/restapi/pojo/base/BasePagedReq.java b/src/main/java/com/cmhi/cf/restapi/pojo/base/BasePagedReq.java new file mode 100644 index 0000000..3a4077e --- /dev/null +++ b/src/main/java/com/cmhi/cf/restapi/pojo/base/BasePagedReq.java @@ -0,0 +1,34 @@ +package com.cmhi.cf.restapi.pojo.base; + +import com.cmhi.cf.validation.group.ValidGroups; +import com.cmhi.cf.validation.valids.ValidPageSize; +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import jakarta.validation.constraints.NotNull; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@NoArgsConstructor +@AllArgsConstructor +@JsonInclude(JsonInclude.Include.NON_NULL) +@Schema(name = "BasePagedReq", description = "分页请求基础参数") +public class BasePagedReq { + @Schema(description = "分页号,最小值为1") + @NotNull(message = "pageNumber 必须指定分页配置", groups = ValidGroups.BasePagedReqValid.class) + @Min(value = 1, message = "pageNumber 最小值为1", groups = ValidGroups.BasePagedReqValid.class) + private Long pageNumber; + + @Schema(description = "分页大小,最小值为5, 最大值100, 取值必须为5的整数倍") + @NotNull(message = "pageSize 必须指定分页配置", groups = ValidGroups.BasePagedReqValid.class) + @ValidPageSize(message = "pageSize 取值必须为 5 的整数倍", groups = ValidGroups.BasePagedReqValid.class) + @Min(value = 5, message = "pageSize 最小值为5", groups = ValidGroups.BasePagedReqValid.class) + @Max(value = 100, message = "pageSize 最大值为100", groups = ValidGroups.BasePagedReqValid.class) + private Long pageSize; + + @Schema(description = "数据总数,未知时可以为空或者小于0, 存在时可以加快后端数据库查询速度") + private Long totalSize; +} diff --git a/src/main/java/com/cmhi/cf/restapi/pojo/dto/OperationLogReq.java b/src/main/java/com/cmhi/cf/restapi/pojo/dto/OperationLogReq.java index edc520e..ee0127f 100644 --- a/src/main/java/com/cmhi/cf/restapi/pojo/dto/OperationLogReq.java +++ b/src/main/java/com/cmhi/cf/restapi/pojo/dto/OperationLogReq.java @@ -1,41 +1,22 @@ package com.cmhi.cf.restapi.pojo.dto; -import com.cmhi.cf.validation.group.ValidGroups; -import com.cmhi.cf.validation.valids.ValidPageSize; +import com.cmhi.cf.restapi.pojo.base.BasePagedReq; import com.fasterxml.jackson.annotation.JsonInclude; import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; -import jakarta.validation.constraints.NotNull; import lombok.AllArgsConstructor; -import lombok.Builder; import lombok.Data; +import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import java.util.List; +@EqualsAndHashCode(callSuper = true) @Data -@Builder @NoArgsConstructor @AllArgsConstructor @JsonInclude(JsonInclude.Include.NON_NULL) @Schema(name = "OperationLogReq", description = "操作日志摘要信息请求参数") -public class OperationLogReq { - @Schema(description = "分页号,最小值为1") - @NotNull(message = "pageNumber 必须指定分页配置", groups = ValidGroups.OperationLogReqValid.class) - @Min(value = 1, message = "pageNumber 最小值为1", groups = ValidGroups.OperationLogReqValid.class) - private Long pageNumber; - - @Schema(description = "分页大小,最小值为5, 最大值100, 取值必须为5的整数倍") - @NotNull(message = "pageSize 必须指定分页配置", groups = ValidGroups.OperationLogReqValid.class) - @ValidPageSize(message = "pageSize 取值必须为 5 的整数倍", groups = ValidGroups.OperationLogReqValid.class) - @Min(value = 5, message = "pageSize 最小值为5", groups = ValidGroups.OperationLogReqValid.class) - @Max(value = 100, message = "pageSize 最大值为100", groups = ValidGroups.OperationLogReqValid.class) - private Long pageSize; - - @Schema(description = "数据总数,未知时可以为空或者小于0, 存在时可以加快后端数据库查询速度") - private Long totalSize; - +public class OperationLogReq extends BasePagedReq { @Schema(description = "用户名, 需要查询指定用户的操作日志时指定用户, 支持同时指定多个用户, 分页查询过程中该参数不能改变") private List userName; } diff --git a/src/main/java/com/cmhi/cf/restapi/pojo/vo/OperationLogSummaryResp.java b/src/main/java/com/cmhi/cf/restapi/pojo/vo/OperationLogSummaryResp.java deleted file mode 100644 index 1e558db..0000000 --- a/src/main/java/com/cmhi/cf/restapi/pojo/vo/OperationLogSummaryResp.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.cmhi.cf.restapi.pojo.vo; - -import com.cmhi.cf.restapi.pojo.base.BaseRespStatus; -import com.cmhi.cf.restapi.pojo.po.PageResults; -import com.fasterxml.jackson.annotation.JsonInclude; -import com.fasterxml.jackson.annotation.JsonPropertyOrder; -import lombok.Builder; -import lombok.Data; -import lombok.EqualsAndHashCode; - -@EqualsAndHashCode(callSuper = true) -@Data -@JsonInclude(JsonInclude.Include.NON_NULL) -@JsonPropertyOrder({"operationLog", "status", "message"}) -public class OperationLogSummaryResp extends BaseRespStatus { - private PageResults operationLog; - @Builder - public OperationLogSummaryResp(PageResults operationLog, Integer status, String[] message) { - super(status, message); - this.operationLog = operationLog; - } -}