fix商品接口报错
This commit is contained in:
@@ -12,9 +12,9 @@ public class BusinessException extends RuntimeException {
|
||||
private final String msg;
|
||||
|
||||
public BusinessException(ResultEnum resultEnum) {
|
||||
super(resultEnum.getMessage());
|
||||
super(resultEnum.getMsg());
|
||||
this.code = resultEnum.getCode();
|
||||
this.msg = resultEnum.getMessage();
|
||||
this.msg = resultEnum.getMsg();
|
||||
}
|
||||
|
||||
public BusinessException(Integer code, String msg) {
|
||||
|
||||
@@ -1,29 +1,42 @@
|
||||
package com.aida.buyer.common.result;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName PageResponse
|
||||
* @Description 分页响应
|
||||
*/
|
||||
@Data
|
||||
public class PageResponse<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long page;
|
||||
private Long size;
|
||||
private Long pages;
|
||||
private Long total;
|
||||
@NoArgsConstructor
|
||||
@Schema(description = "分页响应结果")
|
||||
public class PageResponse<T> {
|
||||
@Schema(description = "页码")
|
||||
private long page;
|
||||
@Schema(description = "每页数量")
|
||||
private long size;
|
||||
@Schema(description = "总页数")
|
||||
private long pages;
|
||||
@Schema(description = "总条数")
|
||||
private long total;
|
||||
@Schema(description = "结果集")
|
||||
private List<T> content;
|
||||
|
||||
|
||||
public PageResponse(List<T> list, long page, long size, long total, long pages) {
|
||||
this.page = page;
|
||||
this.size = size;
|
||||
this.total = total;
|
||||
this.pages = pages;
|
||||
this.content = list;
|
||||
}
|
||||
|
||||
public static <T> PageResponse<T> success(IPage<T> page) {
|
||||
PageResponse<T> response = new PageResponse<>();
|
||||
response.setPage(page.getCurrent());
|
||||
response.setSize(page.getSize());
|
||||
response.setPages(page.getPages());
|
||||
response.setTotal(page.getTotal());
|
||||
response.setContent(page.getRecords());
|
||||
return response;
|
||||
return new PageResponse<>(page.getRecords(), page.getCurrent(), page.getSize(), page.getTotal(), page.getPages());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ public class Response<T> implements Serializable {
|
||||
public static <T> Response<T> success(T data) {
|
||||
Response<T> response = new Response<>();
|
||||
response.setErrCode(ResultEnum.SUCCESS.getCode());
|
||||
response.setErrMsg(ResultEnum.SUCCESS.getMessage());
|
||||
response.setErrMsg(ResultEnum.SUCCESS.getMsg());
|
||||
response.setData(data);
|
||||
return response;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,11 @@ import lombok.Getter;
|
||||
* @Author dwjian
|
||||
* @Date 2019/9/8 21:58
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ClassName ResultEnum
|
||||
* @Description 响应结果枚举
|
||||
*/
|
||||
public enum ResultEnum {
|
||||
|
||||
SUCCESS(true, 0, "SUCCESS"),
|
||||
@@ -23,13 +28,12 @@ public enum ResultEnum {
|
||||
|
||||
PROMPT(false, 1, "Prompt"),
|
||||
WARNING(false, 2, "Warning"),
|
||||
|
||||
;
|
||||
|
||||
private int code;
|
||||
private String msg;
|
||||
private boolean isOK;
|
||||
|
||||
|
||||
ResultEnum(boolean isOK, int code, String msg) {
|
||||
this.isOK = isOK;
|
||||
this.code = code;
|
||||
@@ -44,7 +48,7 @@ public enum ResultEnum {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
public String getMsg() {
|
||||
return msg;
|
||||
}
|
||||
|
||||
@@ -59,4 +63,4 @@ public enum ResultEnum {
|
||||
public void setOK(boolean OK) {
|
||||
isOK = OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user