utils/Result
package com.example.demo.utils;
public class Result {
public Integer code;
public String message;
public Object data;
public Result(Integer code, String message, Object data) {
System.out.println("数据实例初始化");
this.code = (CodeSataus.whiteValue() ? CodeSataus.value : code);
this.message = (CodeSataus.whiteValue() ? "操作失败!" : message);
this.data = data;
}
public static Result ok () {
return Result.build(200, "操作成功!", "");
}
public static Result ok (Object data) {
return Result.build(200, "操作成功!", data);
}
public static Result error () {
return Result.build(500, "操作失败!", "");
}
public static Result error (Integer code, String message) {
return Result.build(code, message, "");
}
public static Result build (Integer code, String message, Object data) {
System.out.println("数据返回实例化");
return new Result(code, message, data);
}
}