rest项目的基础返回类设计
package com.hmy.erp.api.vo; import java.io.Serializable; import lombok.Data; /** * erp基本状态返回类 * * @author WanHongLei * 2019年4月12日 */ @Data public class ErpBaseResult implements Serializable{ private static final long serialVersionUID = -5669856511733166376L; public static final int SUCCESSCODE = 200; public static final int FAILEDCODE = 999; /** * 200 success * 999 failed */ private Integer errCode; private String errMsg; private Object data; public static final ErpBaseResult SUCCESS = successWithData(null); public static final ErpBaseResult FAILED = failedWithData(null); public ErpBaseResult(){ this.errCode = 200; this.errMsg = "SUCCESS"; } public ErpBaseResult(Integer errCode, String errMsg){ this.errCode = errCode; this.errMsg = errMsg; } public ErpBaseResult(Integer errCode, String errMsg, Object obj){ this.errCode = errCode; this.errMsg = errMsg; this.data = obj; } public static ErpBaseResult successWithData(Object obj){ return new ErpBaseResult(200,"SUCCESS", obj); } public static ErpBaseResult failedWithData(Object obj){ return new ErpBaseResult(999,"FAILED", obj); } public static ErpBaseResult failedWithMsg(String errMsg){ return new ErpBaseResult(999,errMsg); } }