Commit 4ece1351 authored by gary's avatar gary

1、添加ERRORCODEMSG Enum

parent 5a5863cd
package pwc.taxtech.atms.constant.enums;
public enum EnumErrorCodeMsg {
SUCCESS(0, "成功"),
APIERROR(-1, "接口异常"),
APIDATAEMPTY(-2, "接口输入数据为空");
private Integer code;
private String msg;
EnumErrorCodeMsg(Integer code, String msg) {
this.code = code;
this.msg = msg;
}
public Integer getCode() {
return code;
}
public String getMsg() {
return msg;
}
public static EnumErrorCodeMsg fromCode(Integer code){
for(EnumErrorCodeMsg error: EnumErrorCodeMsg.values()){
if(error.getCode().intValue()==code.intValue())return error;
}
// 超出范围值默认返回异常
return EnumErrorCodeMsg.APIERROR;
}
public static String getMsg(Integer code){
for(EnumErrorCodeMsg error: EnumErrorCodeMsg.values()){
if(error.getCode().intValue()==code.intValue())return error.msg;
}
// 超出范围值默认返回异常
return EnumErrorCodeMsg.APIERROR.msg;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment