/**
* @Author : 初bai
* @Date : 2022/3/23 18:01
* @Description : 返回结果类
*/
@Data
public class ReponseResult implements Serializable {
private int code; //200为正常 400异常
private String msg;
private Object data;
public static ReponseResult success(Object data){
return result(200,"操作成功",data);
}
public static ReponseResult success(String msg, Object data){
return result(200,msg,data);
}
public static ReponseResult fail(String msg){
return result(400,msg,null);
}
public static ReponseResult fail(String msg, Object data){
return result(400,msg,data);
}
public static ReponseResult result(int code, String msg, Object data){
ReponseResult res = new ReponseResult();
res.setCode(code);
res.setMsg(msg);
res.setData(data);
return res;
}
}
ResponseResult(spring最简单的统一返回方式)
于 2022-04-22 11:43:09 首次发布