import java.io.Serializable; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Getter; import lombok.Setter; /** * 结果基础类 */ @Getter @Setter @ApiModel(value = "结果基础类 ") public class DataResp<T> implements Serializable { private static final long serialVersionUID = 1L; @ApiModelProperty(value = "成功标志") private boolean success; @ApiModelProperty(value = "错误代码") private String err; @ApiModelProperty(value = "错误文本") private String msg; @ApiModelProperty(value = "业务数据") private T data; public static <T> DataResp<T> ok() { DataResp<T> res = new DataResp<T>(); res.setSuccess(true); return res; } public static <T> DataResp<T> ok(T data) { DataResp<T> res = new DataResp<T>(); res.setSuccess(true); res.setData(data); return res; } public static <T> DataResp<T> fail(String err, String msg) { DataResp<T> res = new DataResp<T>(); res.setSuccess(false); res.setErr(err); res.setMsg(msg); return res; } public boolean isSuccess() { return success; } }
java 结果基础类
最新推荐文章于 2024-04-19 21:34:01 发布