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