统一返回值格式
ResultVO
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package com.hcycom.mc.web.vo;
public class ResultVO<T> {
private Integer code;
private String message;
private Object data;
private Object error;
public void setCode(Integer code) {
this.code = code;
}
public void setMessage(String message) {
this.message = message;
}
public void setData(Object data) {
this.data = data;
}
public void setError(Object error) {
this.error = error;
}
public Integer getCode() {
return this.code;
}
public String getMessage() {
return this.message;
}
public Object getData() {
return this.data;
}
public Object getError() {
return this.error;
}
public ResultVO() {
}
public boolean equals(final Object o) {
if (o == this) {
return true;
} else if (!(o instanceof ResultVO)) {
return false;
} else {
ResultVO<?> other = (ResultVO)o;
if (!other.canEqual(this)) {
return false;
} else {
label59: {
Object this$code = this.getCode();
Object other$code = other.getCode();
if (this$code == null) {
if (other$code == null) {
break label59;
}
} else if (this$code.equals(other$code)) {
break label59;
}
return false;
}
Object this$message = this.getMessage();
Object other$message = other.getMessage();
if (this$message == null) {
if (other$message != null) {
return false;
}
} else if (!this$message.equals(other$message)) {
return false;
}
Object this$data = this.getData();
Object other$data = other.getData();
if (this$data == null) {
if (other$data != null) {
return false;
}
} else if (!this$data.equals(other$data)) {
return false;
}
Object this$error = this.getError();
Object other$error = other.getError();
if (this$error == null) {
if (other$error != null) {
return false;
}
} else if (!this$error.equals(other$error)) {
return false;
}
return true;
}
}
}
protected boolean canEqual(final Object other) {
return other instanceof ResultVO;
}
public int hashCode() {
int PRIME = true;
int result = 1;
Object $code = this.getCode();
int result = result * 59 + ($code == null ? 43 : $code.hashCode());
Object $message = this.getMessage();
result = result * 59 + ($message == null ? 43 : $message.hashCode());
Object $data = this.getData();
result = result * 59 + ($data == null ? 43 : $data.hashCode());
Object $error = this.getError();
result = result * 59 + ($error == null ? 43 : $error.hashCode());
return result;
}
public String toString() {
return "ResultVO(code=" + this.getCode() + ", message=" + this.getMessage() + ", data=" + this.getData() + ", error=" + this.getError() + ")";
}
}
ResultVOUtil
//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//
package com.hcycom.mc.web.utils;
import com.hcycom.mc.web.vo.ResultVO;
public class ResultVOUtil {
public ResultVOUtil() {
}
public static ResultVO success(Object object) {
ResultVO resultVO = new ResultVO();
resultVO.setCode(0);
resultVO.setMessage("成功");
resultVO.setData(object);
resultVO.setError("");
return resultVO;
}
public static ResultVO success() {
return success(1);
}
public static ResultVO error(Integer code, String msg, Object error) {
ResultVO resultVO = new ResultVO();
resultVO.setCode(code);
resultVO.setMessage(msg);
resultVO.setError(error);
return resultVO;
}
public static ResultVO error(Integer code, String msg) {
return error(code, msg, "");
}
}
用法例子
{
“code”: 0,
“message”: “成功”,
“data”: {
“time”: [
“2021-05-10 08:00:00”,
“2021-05-11 08:00:00”,
“2021-05-12 08:00:00”,
“2021-05-13 08:00:00”
]
},
“error”: “”
}