From 4592be4760b607580ad33c257ad906bfe1e5922f Mon Sep 17 00:00:00 2001 From: wenc000 <450292408@qq.com> Date: Tue, 27 Aug 2019 11:20:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=AE=BE=E5=A4=87=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cm/common/advice/ResponseAdvice.java | 4 ++- .../cm/common/config/TransactionConfig.java | 2 ++ .../cm/common/enums/ErrorResultCodeEnum.java | 3 +- .../common/exception/AppDeviceException.java | 35 +++++++++++++++++++ 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 cloud-common/src/main/java/com/cm/common/exception/AppDeviceException.java diff --git a/cloud-common/src/main/java/com/cm/common/advice/ResponseAdvice.java b/cloud-common/src/main/java/com/cm/common/advice/ResponseAdvice.java index ccb3f76..5d88b75 100644 --- a/cloud-common/src/main/java/com/cm/common/advice/ResponseAdvice.java +++ b/cloud-common/src/main/java/com/cm/common/advice/ResponseAdvice.java @@ -48,7 +48,9 @@ public class ResponseAdvice { result.setCode(ErrorResultCodeEnum.PARAMS_ERROR.getValue()); } else if (e instanceof FileException) { result.setCode(ErrorResultCodeEnum.FILE_ERROR.getValue()); - } else if(e instanceof AccessTokenException) { + } else if (e instanceof AppDeviceException) { + result.setCode(ErrorResultCodeEnum.DEVICE_ERROR.getValue()); + } else if (e instanceof AccessTokenException) { response.setStatus(HttpStatus.UNAUTHORIZED.value()); } // 自定义提示信息 diff --git a/cloud-common/src/main/java/com/cm/common/config/TransactionConfig.java b/cloud-common/src/main/java/com/cm/common/config/TransactionConfig.java index 42e69f8..309ee09 100644 --- a/cloud-common/src/main/java/com/cm/common/config/TransactionConfig.java +++ b/cloud-common/src/main/java/com/cm/common/config/TransactionConfig.java @@ -54,6 +54,8 @@ public class TransactionConfig { source.addTransactionalMethod("exec*", required); source.addTransactionalMethod("set*", required); + source.addTransactionalMethod("login", required); + source.addTransactionalMethod("get*", readOnly); source.addTransactionalMethod("query*", readOnly); source.addTransactionalMethod("find*", readOnly); diff --git a/cloud-common/src/main/java/com/cm/common/enums/ErrorResultCodeEnum.java b/cloud-common/src/main/java/com/cm/common/enums/ErrorResultCodeEnum.java index bb752cd..d5305d0 100644 --- a/cloud-common/src/main/java/com/cm/common/enums/ErrorResultCodeEnum.java +++ b/cloud-common/src/main/java/com/cm/common/enums/ErrorResultCodeEnum.java @@ -25,7 +25,8 @@ public enum ErrorResultCodeEnum { TOKEN_ERROR(40302), USERNAME_PASSWORD_ERROR(40303), USER_EXIST(40304), - PERMISSION_ERROR(40401); + PERMISSION_ERROR(40401), + DEVICE_ERROR(40501); private int value; diff --git a/cloud-common/src/main/java/com/cm/common/exception/AppDeviceException.java b/cloud-common/src/main/java/com/cm/common/exception/AppDeviceException.java new file mode 100644 index 0000000..8c0d5db --- /dev/null +++ b/cloud-common/src/main/java/com/cm/common/exception/AppDeviceException.java @@ -0,0 +1,35 @@ +package com.cm.common.exception; + +import com.cm.common.exception.base.SystemException; + +/** + * When you feel like quitting. Think about why you started + * 当你想要放弃的时候,想想当初你为何开始 + * + * @ClassName: AppDeviceException + * @Description: APP设备异常 + * @Author: WangGeng + * @Date: 2019/8/27 11:14 上午 + * @Version: 1.0 + **/ +public class AppDeviceException extends SystemException { + + public AppDeviceException() { + } + + public AppDeviceException(String message) { + super(message); + } + + public AppDeviceException(String message, boolean withMsg) { + super(message, withMsg); + } + + public AppDeviceException(String message, Throwable cause) { + super(message, cause); + } + + public AppDeviceException(Throwable cause) { + super(cause); + } +}