配置响应公共代码和消息
SUCCESS(200,"成功"),
FAIL(201, "失败"),
PARAM_ERROR(203, "参数错误"),
DATA_ERROR(204, "数据异常"),
ILLEGAL_REQUEST(205, "非法请求"),
REPEAT_SUBMIT(206, "重复提交"),
LOGIN_AUTH(208, "未登陆"),
PERMISSION(209, "没有权限"),
CODE_ERROR(210, "验证码不正确"),
PHONE_REGISTER_ERROR(210, "手机号已注册"),
ACCOUNT_ERROR(210, "账号不正确"),
PASSWORD_ERROR(210, "密码不正确"),
ACCOUNT_LOCK_ERROR(210, "该账户已被锁定"),
;
public Integer code;
public String message;
配置相应类
package com.itfangyi.commons;标签:210,resul,ResultCommon,public,ERROR,message,data,response From: https://www.cnblogs.com/fangyilovebc/p/17897392.html
import com.sun.org.apache.regexp.internal.RE;
import org.omg.CORBA.PUBLIC_MEMBER;
public class ResultCommon <T> {
private Integer Status ;
private String message;
private T data ;
public ResultCommon(Integer status, String message) {
Status = status;
this.message = message;
}
public static <T> ResultCommon<T> REQUEST_SUCCESS(ResultCodeEnum resultCodeEnum , T data){
return new ResultCommon<T>(resultCodeEnum.code,resultCodeEnum.message,data);
}
public static ResultCommon REQUEST_FAIL(ResultCommon resultCommon ){
return new ResultCommon(resultCommon.Status,resultCommon.message);
}
public ResultCommon(Integer status, String message, T data) {
Status = status;
this.message = message;
this.data = data;
}
}