修改异常枚举名称

This commit is contained in:
TinyAnts
2023-03-23 09:50:41 +08:00
parent 57053cc0e6
commit a9549e23c9
10 changed files with 58 additions and 59 deletions

View File

@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mdd.common.aop.NotLogin;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.entity.user.User;
import com.mdd.common.enums.HttpEnum;
import com.mdd.common.enums.ErrorEnum;
import com.mdd.common.exception.LoginException;
import com.mdd.common.mapper.user.UserMapper;
import com.mdd.common.util.StringUtils;
@@ -140,16 +140,16 @@ public class LikeFrontInterceptor implements HandlerInterceptor {
// 令牌校验
String token = StpUtil.getTokenValue();
if (StringUtils.isNull(token) || StringUtils.isBlank(token)) {
Integer errCode = HttpEnum.TOKEN_EMPTY.getCode();
String errMsg = HttpEnum.TOKEN_EMPTY.getMsg();
Integer errCode = ErrorEnum.TOKEN_EMPTY.getCode();
String errMsg = ErrorEnum.TOKEN_EMPTY.getMsg();
throw new LoginException(errCode, errMsg);
}
// 登录校验
Object id = StpUtil.getLoginId();
if (StringUtils.isNull(id)) {
Integer errCode = HttpEnum.TOKEN_INVALID.getCode();
String errMsg = HttpEnum.TOKEN_INVALID.getMsg();
Integer errCode = ErrorEnum.TOKEN_INVALID.getCode();
String errMsg = ErrorEnum.TOKEN_INVALID.getMsg();
throw new LoginException(errCode, errMsg);
}
@@ -163,15 +163,15 @@ public class LikeFrontInterceptor implements HandlerInterceptor {
// 删除校验
if (StringUtils.isNull(user)) {
Integer errCode = HttpEnum.TOKEN_INVALID.getCode();
String errMsg = HttpEnum.TOKEN_INVALID.getMsg();
Integer errCode = ErrorEnum.TOKEN_INVALID.getCode();
String errMsg = ErrorEnum.TOKEN_INVALID.getMsg();
throw new LoginException(errCode, errMsg);
}
// 禁用校验
if (user.getIsDisable().equals(1)) {
Integer errCode = HttpEnum.LOGIN_DISABLE_ERROR.getCode();
String errMsg = HttpEnum.LOGIN_DISABLE_ERROR.getMsg();
Integer errCode = ErrorEnum.LOGIN_DISABLE_ERROR.getCode();
String errMsg = ErrorEnum.LOGIN_DISABLE_ERROR.getMsg();
throw new LoginException(errCode, errMsg);
}

View File

@@ -3,7 +3,7 @@ package com.mdd.front.config.stp;
import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.exception.NotPermissionException;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.enums.HttpEnum;
import com.mdd.common.enums.ErrorEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ControllerAdvice;
@@ -26,7 +26,7 @@ public class StpInException {
@ResponseBody
public AjaxResult<Object> handleNotLoginException(NotLoginException e){
String msg = e.getMessage().startsWith("Token无效") ? "尚未登录,请先登录!" : e.getMessage();
return AjaxResult.failed(HttpEnum.TOKEN_INVALID.getCode(), msg);
return AjaxResult.failed(ErrorEnum.TOKEN_INVALID.getCode(), msg);
}
/**
@@ -36,7 +36,7 @@ public class StpInException {
@ExceptionHandler(NotPermissionException.class)
@ResponseBody
public AjaxResult<Object> handleNotPermissionException(){
return AjaxResult.failed(HttpEnum.NO_PERMISSION.getCode(), HttpEnum.NO_PERMISSION.getMsg());
return AjaxResult.failed(ErrorEnum.NO_PERMISSION.getCode(), ErrorEnum.NO_PERMISSION.getMsg());
}
}