package com.mogoroom.bs.common; public enum StatusConstant { /** * 请登录 code */ LOGIN_STATUS_ERROR("10503","Please login!"), /** * 数据不存在 */ DATA_NOT_EXIST("10504","The data does not exist!"), /** * 参数错误 */ PARAMS_ERROR("10508","Parameter is incorrect!"), /** * 重复请求校验 */ TOKEN_CHECK_ERROR("10555","The request processing failure:Repeat Request!"), /** * 重复请求校验成功 */ TOKEN_CHECK_SUCCESS("200","check success!"), /** * 非法操作 */ FAIL_EXCEPTION("2400","FAIL!"), CUSTOMER_UPDATE_CUSTOMER_NICKNAME_IS_EXIST("11816","11816"), CUSTOMER_UPDATE_CUSTOMER_NICKNAME_IS_NULL("11817","11817"), REGIST_SUCCESS("10000","Regist success!"), ACCOUNT_EXIST("10001","User name has been registered already!"), ACCOUNT_EMPTY("10502","Account name is empty!"), PASSWORD_EMPTY("10505","Password is empty!"), PASSWORD_LENGTH_ERROR("10512","Password length error!"), EMAIL_EMPTY("10513","Email is empty!"), EMAIL_FORMAT_INVALIDATE("10514","Email format invalidate!"), EMAIL_EXIST("10012","Email has been registered already!"), SUCCESS("200","success!"), REQUEST_DATA_NULL("20000","Request object is null!"), ACCOUNTINFO_NULL("20001","AccountInfo is null!"), OVERLENGTH_ERROR("20002","Field length is to long!"), DB_ERROR("20003","The database throw an Exception!"), SERVICE_ERROR("20004","Service Error(Such as: exist or not exist...)!"), UNKNOW_ERROR("20005","Unknow Exception"), CUSTOMERINFO_NULL("20006","CustomerInfo is null!"), CUSTNAME_NULL("20009","CustName is null"), INSERT_EXCEPTION("20500","Insert Error(such as : insert row may be existuser the same as the owner...)!"), TOKEN_ERROR("20504","Token is empty or incorrect, you may be login first and get a correct token!"), TOKEN_EXPIRED("20506","Token is expired, please refresh token!"), REFRESH_TOKEN_ERROR("20507","refresh TOKEN error,you should login again and get a fresh token!"), PARAMS_EXCEPTION("20505","Parameter error!"), UPLOAD_SIZE_EXCEPTION("20510","Upload size exception!"), UPLOAD_TYPE_EXCEPTION("20511","Upload types exception!"), NATION_VALID_ERROR("90001","NATIONAL VALID ERROR!"), ORDER_DELETE_ERROR("50001","ORDER DELETE ERROR!"), CONSTANT_VALID_ERROR("90002","CONSTANT VALID ERROR!"), VERIFYCODE_ERROR("220114","verfiCode error!"), ; private String code; private String msg; private StatusConstant(String code,String msg){ this.code=code; this.msg=msg; } public String getCode() { return code; } public String getMsg() { return msg; } }
package com.mogoroom.bs.common; import java.io.Serializable; public class RSCommonResp implements Serializable{ private static final long serialVersionUID = 8388737639759326013L; private String code; private String message; private String repeatToken; //private String hiddenMsg; public RSCommonResp(){} public RSCommonResp(StatusConstant sc){ this.setCode(sc); } public void setCode(StatusConstant sc){ this.code=sc.getCode(); this.message=sc.getMsg(); } public void setCode(StatusConstant sc,String message){ this.code=sc.getCode(); this.message=message!=null?message:sc.getMsg(); } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public String getCode() { return code; } public void setCode(String code) { this.code = code; } public String getRepeatToken() { return repeatToken; } public void setRepeatToken(String repeatToken) { this.repeatToken = repeatToken; } // public String getHiddenMsg() { // return hiddenMsg; // } // // public void setHiddenMsg(String hiddenMsg) { // this.hiddenMsg = hiddenMsg; // } }
package com.mogoroom.bs.common; import java.io.Serializable; public class RSObjectResultResp<T> extends RSCommonResp implements Serializable{ private static final long serialVersionUID = 6126886548726302314L; private T result; public RSObjectResultResp(){} public RSObjectResultResp(StatusConstant sc){ this.setCode(sc); } public T getResult() { return result; } public void setResult(T result) { this.result = result; } /** * @Title: suc * @Description: 成功返回结果 * @param * @return RSObjectResultResp 返回类型 * @throws */ public static RSObjectResultResp<Object> suc(Object result) { RSObjectResultResp<Object> resultResp = new RSObjectResultResp<Object>(); resultResp.setCode(StatusConstant.SUCCESS.getCode()); resultResp.setMessage(StatusConstant.SUCCESS.getMsg()); resultResp.setResult(result); return resultResp; } /** * @Title: check * @Description: 失败返回结果(带token) * @param * @return true:false 返回类型 * @throws */ public static RSObjectResultResp<Object> errToken() { RSObjectResultResp<Object> resultResp = new RSObjectResultResp<Object>(); resultResp.setCode(StatusConstant.TOKEN_CHECK_ERROR.getCode()); resultResp.setMessage(StatusConstant.TOKEN_CHECK_ERROR.getMsg()); return resultResp; } /** * @Title: err * @Description: 失败返回结果 * @param * @return RSObjectResultResp 返回类型 * @throws */ public static RSObjectResultResp<Object> err(Object result) { RSObjectResultResp<Object> resultResp = new RSObjectResultResp<Object>(); resultResp.setCode(StatusConstant.UNKNOW_ERROR.getCode()); resultResp.setMessage(StatusConstant.UNKNOW_ERROR.getMsg()); resultResp.setResult(result); return resultResp; } /** * 指定 返回类型 的 返回结果 * @param statusConstant * @param result * @return */ public static RSObjectResultResp<Object> result(StatusConstant statusConstant, Object result) { RSObjectResultResp<Object> resultResp = new RSObjectResultResp<Object>(); resultResp.setCode(statusConstant.getCode()); resultResp.setMessage(statusConstant.getMsg()); resultResp.setResult(result); return resultResp; } /** * @Title: define * @Description: 自定义返回结果 * @param * @return RSObjectResultResp 返回类型 * @throws */ public static RSObjectResultResp<Object> define(String resultCode, String reslutMessage, Object result) { RSObjectResultResp<Object> resultResp = new RSObjectResultResp<Object>(); resultResp.setCode(resultCode); resultResp.setMessage(reslutMessage); resultResp.setResult(result); return resultResp; } /** * @description * @return * @Exception */ public static RSObjectResultResp<Object> define(String resultCode, String reslutMessage) { RSObjectResultResp<Object> resultResp = new RSObjectResultResp<Object>(); resultResp.setCode(resultCode); resultResp.setMessage(reslutMessage); resultResp.setResult(""); return resultResp; } }