mirror of
https://gitee.com/likeadmin/likeadmin_java.git
synced 2026-06-04 08:38:26 +08:00
修改异常枚举名称
This commit is contained in:
@@ -7,7 +7,7 @@ import com.mdd.common.aop.NotPower;
|
||||
import com.mdd.common.aop.NotLogin;
|
||||
import com.mdd.common.core.AjaxResult;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
import com.mdd.common.enums.HttpEnum;
|
||||
import com.mdd.common.enums.ErrorEnum;
|
||||
import com.mdd.common.exception.LoginException;
|
||||
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
|
||||
import com.mdd.common.util.StringUtils;
|
||||
@@ -73,7 +73,7 @@ public class LikeAdminInterceptor implements HandlerInterceptor {
|
||||
List<String> ignoreUrl = Arrays.asList("system:login", "system:logout");
|
||||
if (request.getMethod().equals("POST") && !ignoreUrl.contains(auths)) {
|
||||
String message = "演示环境不支持修改数据,请下载源码本地部署体验";
|
||||
AjaxResult<Object> result = AjaxResult.failed(HttpEnum.NO_PERMISSION.getCode(), message);
|
||||
AjaxResult<Object> result = AjaxResult.failed(ErrorEnum.NO_PERMISSION.getCode(), message);
|
||||
response.getWriter().print(JSON.toJSONString(result));
|
||||
return false;
|
||||
}
|
||||
@@ -139,16 +139,16 @@ public class LikeAdminInterceptor 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);
|
||||
}
|
||||
|
||||
@@ -162,15 +162,15 @@ public class LikeAdminInterceptor implements HandlerInterceptor {
|
||||
|
||||
// 删除校验
|
||||
if (StringUtils.isNull(adminUser)) {
|
||||
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 (adminUser.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);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.mdd.admin.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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.mdd.admin.vo.system.SystemCaptchaVo;
|
||||
import com.mdd.admin.vo.system.SystemLoginVo;
|
||||
import com.mdd.common.entity.system.SystemAuthAdmin;
|
||||
import com.mdd.common.entity.system.SystemLogLogin;
|
||||
import com.mdd.common.enums.HttpEnum;
|
||||
import com.mdd.common.enums.ErrorEnum;
|
||||
import com.mdd.common.exception.LoginException;
|
||||
import com.mdd.common.exception.OperateException;
|
||||
import com.mdd.common.mapper.system.SystemAuthAdminMapper;
|
||||
@@ -101,7 +101,7 @@ public class SystemLoginServiceImpl implements ISystemLoginService {
|
||||
|
||||
String code = CaptchaCache.get(loginsValidate.getUuid());
|
||||
if (!loginsValidate.getCode().equals(code)) {
|
||||
throw new LoginException(HttpEnum.CAPTCHA_ERROR.getCode(), HttpEnum.CAPTCHA_ERROR.getMsg());
|
||||
throw new LoginException(ErrorEnum.CAPTCHA_ERROR.getCode(), ErrorEnum.CAPTCHA_ERROR.getMsg());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,20 +110,20 @@ public class SystemLoginServiceImpl implements ISystemLoginService {
|
||||
.last("limit 1"));
|
||||
|
||||
if (StringUtils.isNull(sysAdmin) || sysAdmin.getIsDelete().equals(1)) {
|
||||
this.recordLoginLog(0, loginsValidate.getUsername(), HttpEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
throw new LoginException(HttpEnum.LOGIN_ACCOUNT_ERROR.getCode(), HttpEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
this.recordLoginLog(0, loginsValidate.getUsername(), ErrorEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
throw new LoginException(ErrorEnum.LOGIN_ACCOUNT_ERROR.getCode(), ErrorEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
}
|
||||
|
||||
if (sysAdmin.getIsDisable().equals(1)) {
|
||||
this.recordLoginLog(sysAdmin.getId(), loginsValidate.getUsername(), HttpEnum.LOGIN_DISABLE_ERROR.getMsg());
|
||||
throw new LoginException(HttpEnum.LOGIN_DISABLE_ERROR.getCode(), HttpEnum.LOGIN_DISABLE_ERROR.getMsg());
|
||||
this.recordLoginLog(sysAdmin.getId(), loginsValidate.getUsername(), ErrorEnum.LOGIN_DISABLE_ERROR.getMsg());
|
||||
throw new LoginException(ErrorEnum.LOGIN_DISABLE_ERROR.getCode(), ErrorEnum.LOGIN_DISABLE_ERROR.getMsg());
|
||||
}
|
||||
|
||||
String newPWd = password + sysAdmin.getSalt();
|
||||
String md5Pwd = ToolUtils.makeMd5(newPWd);
|
||||
if (!md5Pwd.equals(sysAdmin.getPassword())) {
|
||||
this.recordLoginLog(sysAdmin.getId(), loginsValidate.getUsername(), HttpEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
throw new LoginException(HttpEnum.LOGIN_ACCOUNT_ERROR.getCode(), HttpEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
this.recordLoginLog(sysAdmin.getId(), loginsValidate.getUsername(), ErrorEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
throw new LoginException(ErrorEnum.LOGIN_ACCOUNT_ERROR.getCode(), ErrorEnum.LOGIN_ACCOUNT_ERROR.getMsg());
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user