package net.lab1024.smartadmin.common.domain; import net.lab1024.smartadmin.common.constant.ResponseCodeConst; /** * 返回类 * * @param * @author zhuoda */ public class ResponseDTO { protected Integer code; protected String msg; protected Boolean success; protected T data; public ResponseDTO() { } public ResponseDTO(ResponseCodeConst responseCodeConst, String msg) { this.code = responseCodeConst.getCode(); this.msg = msg; this.success = responseCodeConst.isSuccess(); } public ResponseDTO(ResponseCodeConst responseCodeConst, T data) { super(); this.code = responseCodeConst.getCode(); this.msg = responseCodeConst.getMsg(); this.data = data; this.success = responseCodeConst.isSuccess(); } public ResponseDTO(ResponseCodeConst responseCodeConst, T data, String msg) { super(); this.code = responseCodeConst.getCode(); this.msg = msg; this.data = data; this.success = responseCodeConst.isSuccess(); } private ResponseDTO(ResponseCodeConst responseCodeConst) { this.code = responseCodeConst.getCode(); this.msg = responseCodeConst.getMsg(); this.success = responseCodeConst.isSuccess(); } public ResponseDTO(ResponseDTO responseDTO) { this.code = responseDTO.getCode(); this.msg = responseDTO.getMsg(); this.success = responseDTO.isSuccess(); } public static ResponseDTO succ() { return new ResponseDTO(ResponseCodeConst.SUCCESS); } public static ResponseDTO succData(T data, String msg) { return new ResponseDTO(ResponseCodeConst.SUCCESS, data, msg); } public static ResponseDTO succData(T data) { return new ResponseDTO(ResponseCodeConst.SUCCESS, data); } public static ResponseDTO succMsg(String msg) { return new ResponseDTO(ResponseCodeConst.SUCCESS, msg); } public static ResponseDTO wrap(ResponseCodeConst codeConst) { return new ResponseDTO<>(codeConst); } public static ResponseDTO wrap(ResponseCodeConst codeConst, T t) { return new ResponseDTO(codeConst, t); } public static ResponseDTO wrap(ResponseCodeConst codeConst, String msg) { return new ResponseDTO(codeConst, msg); } public String getMsg() { return msg; } public ResponseDTO setMsg(String msg) { this.msg = msg; return this; } public int getCode() { return code; } public ResponseDTO setCode(Integer code) { this.code = code; return this; } public T getData() { return data; } public ResponseDTO setData(T data) { this.data = data; return this; } public boolean isSuccess() { return success; } public void setSuccess(boolean success) { this.success = success; } @Override public String toString() { return "ResponseDTO{" + "code=" + code + ", msg='" + msg + '\'' + ", success=" + success + ", data=" + data + '}'; } }