55 lines
1.4 KiB
Java
55 lines
1.4 KiB
Java
package com.guo.learningprogresstracker.domain.entity;
|
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.Data;
|
|
import lombok.NoArgsConstructor;
|
|
|
|
|
|
@Data
|
|
@AllArgsConstructor
|
|
@NoArgsConstructor
|
|
public class CommonResult<T> {
|
|
private Integer code;
|
|
|
|
private String message;
|
|
|
|
private T data;
|
|
|
|
public CommonResult(Integer code, String message){
|
|
this(code,message, null);
|
|
}
|
|
|
|
public static CommonResult<String> success(){
|
|
return new CommonResult(200,"请求成功",null);
|
|
}
|
|
|
|
public static CommonResult<String> success(String message){
|
|
return new CommonResult(200,message,null);
|
|
}
|
|
|
|
public static CommonResult<Object> success(String message,Object data){
|
|
return new CommonResult(200,message,data);
|
|
}
|
|
|
|
public static CommonResult success(Object data){
|
|
return new CommonResult(200,"请求成功",data);
|
|
}
|
|
|
|
public static CommonResult<String> error(String message){
|
|
return new CommonResult<>(400,message,null);
|
|
}
|
|
|
|
public static CommonResult<String> notFind(){
|
|
return new CommonResult<>(404,"请求的资源不存在",null);
|
|
}
|
|
public static CommonResult<String> notFind(String message){
|
|
return new CommonResult<>(404,message,null);
|
|
}
|
|
|
|
public static CommonResult<String> serverError(String message){
|
|
return new CommonResult<>(500,message,null);
|
|
}
|
|
|
|
}
|