mirror of https://gitee.com/stylefeng/roses
【auth】整理auth的异常
parent
7499b60000
commit
d00f963142
|
@ -1,6 +1,5 @@
|
||||||
package cn.stylefeng.roses.kernel.auth.api.enums;
|
package cn.stylefeng.roses.kernel.auth.api.enums;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
|
||||||
import cn.stylefeng.roses.kernel.auth.api.exception.AuthException;
|
import cn.stylefeng.roses.kernel.auth.api.exception.AuthException;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@ -63,8 +62,7 @@ public enum DataScopeTypeEnum {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
String userTip = StrUtil.format(DATA_SCOPE_ERROR.getUserTip(), code);
|
throw new AuthException(DATA_SCOPE_ERROR, code);
|
||||||
throw new AuthException(DATA_SCOPE_ERROR, userTip);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package cn.stylefeng.roses.kernel.auth.api.exception;
|
package cn.stylefeng.roses.kernel.auth.api.exception;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
import cn.stylefeng.roses.kernel.auth.api.constants.AuthConstants;
|
import cn.stylefeng.roses.kernel.auth.api.constants.AuthConstants;
|
||||||
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
import cn.stylefeng.roses.kernel.rule.exception.AbstractExceptionEnum;
|
||||||
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||||
|
@ -12,12 +13,8 @@ import cn.stylefeng.roses.kernel.rule.exception.base.ServiceException;
|
||||||
*/
|
*/
|
||||||
public class AuthException extends ServiceException {
|
public class AuthException extends ServiceException {
|
||||||
|
|
||||||
public AuthException(String errorCode, String userTip) {
|
public AuthException(AbstractExceptionEnum exception, Object... params) {
|
||||||
super(AuthConstants.AUTH_MODULE_NAME, errorCode, userTip);
|
super(AuthConstants.AUTH_MODULE_NAME, exception.getErrorCode(), StrUtil.format(exception.getUserTip(), params));
|
||||||
}
|
|
||||||
|
|
||||||
public AuthException(AbstractExceptionEnum exception, String userTip) {
|
|
||||||
super(AuthConstants.AUTH_MODULE_NAME, exception.getErrorCode(), userTip);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public AuthException(AbstractExceptionEnum exception) {
|
public AuthException(AbstractExceptionEnum exception) {
|
||||||
|
|
|
@ -201,8 +201,7 @@ public class AuthServiceImpl implements AuthServiceApi {
|
||||||
|
|
||||||
// 6. 校验用户是否异常(不是正常状态)
|
// 6. 校验用户是否异常(不是正常状态)
|
||||||
if (!UserStatusEnum.ENABLE.getCode().equals(userValidateInfo.getUserStatus())) {
|
if (!UserStatusEnum.ENABLE.getCode().equals(userValidateInfo.getUserStatus())) {
|
||||||
String userTip = StrUtil.format(AuthExceptionEnum.USER_STATUS_ERROR.getErrorCode(), UserStatusEnum.getCodeMessage(userValidateInfo.getUserStatus()));
|
throw new AuthException(AuthExceptionEnum.USER_STATUS_ERROR, UserStatusEnum.getCodeMessage(userValidateInfo.getUserStatus()));
|
||||||
throw new AuthException(AuthExceptionEnum.USER_STATUS_ERROR.getErrorCode(), userTip);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 7. 获取LoginUser,用于用户的缓存
|
// 7. 获取LoginUser,用于用户的缓存
|
||||||
|
|
Loading…
Reference in New Issue