Procházet zdrojové kódy

修改账号激活

humuyu před 3 roky
rodič
revize
a8e8bdfe34

+ 10 - 0
eladmin-common/src/main/java/me/zhengjie/exception/AccountNoActivationException.java

@@ -0,0 +1,10 @@
+package me.zhengjie.exception;
+
+public class AccountNoActivationException extends RuntimeException{
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
+}

+ 15 - 6
eladmin-common/src/main/java/me/zhengjie/exception/handler/GlobalExceptionHandler.java

@@ -42,6 +42,7 @@ import lombok.extern.slf4j.Slf4j;
 import me.zhengjie.base.ResponseCodeConst;
 import me.zhengjie.base.ResponseDTO;
 import me.zhengjie.base.ResultCode;
+import me.zhengjie.exception.AccountNoActivationException;
 import me.zhengjie.exception.BadRequestException;
 import me.zhengjie.exception.EntityExistException;
 import me.zhengjie.exception.EntityNotFoundException;
@@ -65,8 +66,8 @@ public class GlobalExceptionHandler {
 	@ResponseBody
 	@ExceptionHandler(Exception.class)
 	public ResponseDTO<?> exceptionHandler(Exception e) {
-		log.error("error: {}", e.getMessage());
-		e.printStackTrace();
+		log.error("error: {} Cause {} ", e.getMessage(), e.getCause());
+//		e.printStackTrace();
 		// http 请求方式错误
 		if (e instanceof HttpRequestMethodNotSupportedException) {
 			return ResponseDTO.error(ResultCode.REQUEST_METHOD_ERROR);
@@ -77,6 +78,10 @@ public class GlobalExceptionHandler {
 			return ResponseDTO.error(ResultCode.ERROR_PARAM);
 		}
 
+		// 账号没有激活
+		if (e instanceof AccountNoActivationException) {
+			return ResponseDTO.error(ResultCode.USER_ACCOUNT_FORBIDDEN);
+		}
 		// json 格式错误
 		if (e instanceof HttpMessageNotReadableException) {
 			return ResponseDTO.error(ResultCode.JSON_FORMAT_ERROR);
@@ -86,11 +91,15 @@ public class GlobalExceptionHandler {
 		}
 		if (e instanceof InternalAuthenticationServiceException) {
 			InternalAuthenticationServiceException error = (InternalAuthenticationServiceException) e;
-			String  message= error.getMessage();
- 			if(message.contains("UsernameNotFoundException")) {
+			String message = error.getMessage();
+			if (message != null && message.contains("UsernameNotFoundException")) {
 				return ResponseDTO.error(ResultCode.USER_LOGIN_ERROR);
- 			}
-		
+			}
+			Throwable t = e.getCause();
+			if (t instanceof AccountNoActivationException) {
+				return ResponseDTO.error(ResultCode.USER_ACCOUNT_FORBIDDEN);
+			}
+
 		}
 		// 参数校验未通过
 		if (e instanceof MethodArgumentNotValidException) {

+ 0 - 1
eladmin-system/src/main/java/me/zhengjie/application/admin/controller/vo/OrderDetailDto.java

@@ -122,7 +122,6 @@ public class OrderDetailDto {
 	/**
 	 * 其他上传
 	 */
-
 	private String otherUpload;
 	// 其他上传预览地址
 	private List<String> otherUploadUrl;

+ 1 - 0
eladmin-system/src/main/java/me/zhengjie/application/admin/service/impl/AdminOrderServiceImpl.java

@@ -684,4 +684,5 @@ public class AdminOrderServiceImpl implements AdminOrderService {
 		Integer[] intArray = Arrays.stream(array).mapToInt(Integer::parseInt).boxed().toArray(Integer[]::new);
 		return Arrays.asList(intArray);
 	}
+
 }

+ 2 - 1
eladmin-system/src/main/java/me/zhengjie/application/admin/service/impl/UserDetailsServiceImpl.java

@@ -25,6 +25,7 @@ import me.zhengjie.dao.mybatis.entity.BankEntity;
 import me.zhengjie.dao.mybatis.entity.NotaryOfficeEntity;
 import me.zhengjie.dao.mybatis.mapper.BankMapper;
 import me.zhengjie.dao.mybatis.mapper.NotaryOfficeMapper;
+import me.zhengjie.exception.AccountNoActivationException;
 import me.zhengjie.exception.BadRequestException;
 import me.zhengjie.exception.EntityNotFoundException;
 import me.zhengjie.security.config.bean.LoginProperties;
@@ -71,7 +72,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
                 throw new UsernameNotFoundException("");
             } else {
                 if (!user.getEnabled()) {
-                    throw new BadRequestException("账号未激活!");
+                    throw new AccountNoActivationException("账号未激活!");
                 }
                 if (!org.springframework.util.StringUtils.isEmpty(user.getOrgId())){
                     String[] split = user.getOrgId().split("_");