java 通用返回的对象记录

/** * 通用响应对象 * * @param */ @ToString public class Resp { private int code; private String msg; private T data; public Resp(CodeMsgEnum codeMsg, T data) { this.code = codeMsg.getCode(); this.msg = codeMsg.getMsg(); this.data = https://www.it610.com/article/data; }public Resp(CodeMsgEnum codeMsg) { this.code = codeMsg.getCode(); this.msg = codeMsg.getMsg(); }public Resp(int code, String msg, T data) { this.code = code; this.msg = msg; this.data = data; }public Resp(int code, String msg) { this.code = code; this.msg = msg; }public static Resp OK(T data) { return new Resp(CodeMsgEnum.OK, data); }public static Resp OK_WITHOUT_DATA() { return new Resp(CodeMsgEnum.OK); }public static Resp ERROR(CodeMsgEnum codeMsg) { return new Resp(codeMsg, null); }public static Resp ERROR(CodeMsgEnum codeMsg, T data) { return new Resp(codeMsg, data); }public int getCode() { return code; }public void setCode(int code) { this.code = code; }public String getMsg() { return msg; }public void setMsg(String msg) { this.msg = msg; }public T getData() { return data; }public void setData(T data) { this.data = https://www.it610.com/article/data; } }

    推荐阅读