package com.nova.sankuai.domain.api.yangqianguan;
|
|
import io.swagger.annotations.ApiModelProperty;
|
import lombok.Data;
|
|
/**
|
* @Description: 洋钱罐响应类
|
* @Author: Very
|
* @Date: 2022/4/24 19:58
|
*/
|
@Data
|
public class MoneyPotResultJson<T> {
|
|
private static final long serialVersionUID = 783015033603078674L;
|
|
@ApiModelProperty(value = "返回代码")
|
private int code;
|
|
@ApiModelProperty(value = "返回处理消息")
|
private String message;
|
|
@ApiModelProperty(value = "返回数据对象")
|
private T data;
|
|
/**
|
* 成功
|
*
|
* @param <T>
|
* @return
|
*/
|
public static <T> MoneyPotResultJson<T> success() {
|
MoneyPotResultJson<T> moneyPotResultJson = new MoneyPotResultJson<>();
|
moneyPotResultJson.setCode(0);
|
moneyPotResultJson.setMessage("ok");
|
return moneyPotResultJson;
|
}
|
|
/**
|
* 成功
|
*
|
* @param <T>
|
* @return
|
*/
|
public static <T> MoneyPotResultJson<T> success(T data) {
|
MoneyPotResultJson<T> moneyPotResultJson = new MoneyPotResultJson<>();
|
moneyPotResultJson.setCode(0);
|
moneyPotResultJson.setMessage("OK");
|
moneyPotResultJson.setData(data);
|
return moneyPotResultJson;
|
}
|
|
/**
|
* 失败
|
*
|
* @param <T>
|
* @return
|
*/
|
public static <T> MoneyPotResultJson<T> error(int code, String msg) {
|
MoneyPotResultJson<T> moneyPotResultJson = new MoneyPotResultJson<>();
|
moneyPotResultJson.setCode(code);
|
moneyPotResultJson.setMessage(msg);
|
return moneyPotResultJson;
|
}
|
|
@Override
|
public String toString() {
|
return "{" +
|
"\"code\":" + code +
|
", \"msg\":\"" + message + '\"' +
|
", \"data\":\"" + data + '\"' +
|
'}';
|
}
|
|
}
|