package com.qxueyou.scc.base.model;
|
|
/**
|
* apiרÓ÷µ»Ø½á¹ûmodel
|
* @author cyq
|
*
|
*/
|
public class ApiResult {
|
|
/**
|
* ·µ»Ø½á¹ûµÄö¾Ù
|
* @author cyq
|
*
|
*/
|
public enum ResultCode {
|
Success(1), // ³É¹¦
|
UserNotExist(40001), // Óû§²»´æÔÚ
|
PasswordInvalid(40002), // ÃÜÂë²»ÕýÈ·
|
TokenInvalid(50001), // TokenÎÞЧ
|
ParamInvalid(60001), // ²ÎÊýÎÞЧ
|
SystemException(60002), // ϵͳÒì³£
|
DataNotExist(60003); // Êý¾Ý²»´æÔÚ
|
|
private Integer resultCode;
|
|
ResultCode(int code) {
|
this.resultCode = code;
|
}
|
|
public Integer getCode() {
|
return resultCode;
|
}
|
}
|
|
|
private boolean result;
|
|
/**
|
* 40001Óû§²»´æÔÚ
|
* 40002ÃÜÂë´íÎó
|
* 50001tokenÎÞЧ
|
* 60001²ÎÊý´íÎó
|
* 60001ϵͳÒì³£
|
* 60003Êý¾Ý²»´æÔÚ
|
*/
|
private int code = 1;
|
|
private Object data;
|
|
public ApiResult (boolean result) {
|
this.result = result;
|
}
|
|
public ApiResult (boolean result, int code) {
|
this.result = result;
|
this.code = code;
|
}
|
|
public ApiResult (boolean result, ResultCode code) {
|
this.result = result;
|
this.code = code.getCode();
|
}
|
|
public ApiResult (boolean result, int code, Object data) {
|
this.result = result;
|
this.code = code;
|
this.data = data;
|
}
|
|
public static ApiResult resultTrue() {
|
return new ApiResult(true);
|
}
|
|
public static ApiResult resultTrue(Object data) {
|
return new ApiResult(true, 1, data);
|
}
|
|
public static ApiResult resultFalse(int code) {
|
return new ApiResult(false, code);
|
}
|
|
public boolean isResult() {
|
return result;
|
}
|
|
public void setResult(boolean result) {
|
this.result = result;
|
}
|
|
public int getCode() {
|
return code;
|
}
|
|
public void setCode(int code) {
|
this.code = code;
|
}
|
|
public Object getData() {
|
return data;
|
}
|
|
public void setData(Object data) {
|
this.data = data;
|
}
|
|
}
|