diff --git a/ebts/ebts-common/src/main/java/com/ebts/common/exception/EBTSException.java b/ebts/ebts-common/src/main/java/com/ebts/common/exception/EbtsException.java
similarity index 80%
rename from ebts/ebts-common/src/main/java/com/ebts/common/exception/EBTSException.java
rename to ebts/ebts-common/src/main/java/com/ebts/common/exception/EbtsException.java
index cafd39b..703b9d4 100644
--- a/ebts/ebts-common/src/main/java/com/ebts/common/exception/EBTSException.java
+++ b/ebts/ebts-common/src/main/java/com/ebts/common/exception/EbtsException.java
@@ -6,13 +6,13 @@ package com.ebts.common.exception;
* @Email clay@hchyun.com
* @Version 1.0
*/
-public class EBTSException extends RuntimeException {
+public class EbtsException extends RuntimeException {
private String msg;
private RuntimeException exception;
- public EBTSException(String opError, RuntimeException e) {
+ public EbtsException(String opError, RuntimeException e) {
this.msg = opError;
this.exception = e;
}
diff --git a/ebts/ebts-framework/pom.xml b/ebts/ebts-framework/pom.xml
index 9111b7c..92fc480 100644
--- a/ebts/ebts-framework/pom.xml
+++ b/ebts/ebts-framework/pom.xml
@@ -59,6 +59,13 @@
ebts-system
+
+
+
+ com.ebts
+ ebts-generator
+
+
\ No newline at end of file
diff --git a/ebts/ebts-framework/src/main/java/com/ebts/framework/web/exception/GlobalExceptionHandler.java b/ebts/ebts-framework/src/main/java/com/ebts/framework/web/exception/GlobalExceptionHandler.java
index d9fa1b0..0ef7acf 100644
--- a/ebts/ebts-framework/src/main/java/com/ebts/framework/web/exception/GlobalExceptionHandler.java
+++ b/ebts/ebts-framework/src/main/java/com/ebts/framework/web/exception/GlobalExceptionHandler.java
@@ -5,8 +5,10 @@ import com.ebts.common.core.entity.AjaxResult;
import com.ebts.common.exception.BaseException;
import com.ebts.common.exception.CustomException;
import com.ebts.common.exception.DemoModeException;
-import com.ebts.common.exception.EBTSException;
+import com.ebts.common.exception.EbtsException;
import com.ebts.common.utils.StringUtils;
+import com.ebts.generator.utils.exception.GenCustomException;
+import com.ebts.generator.utils.exception.GenEbtsException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.security.access.AccessDeniedException;
@@ -34,19 +36,43 @@ public class GlobalExceptionHandler {
public AjaxResult baseException(BaseException e) {
return AjaxResult.error(e.getMessage());
}
+
+
+
+
+
/**
* EBTS基础异常
*/
- @ExceptionHandler(EBTSException.class)
- public AjaxResult ebtsException(EBTSException e) {
+ @ExceptionHandler(EbtsException.class)
+ public AjaxResult ebtsException(EbtsException e) {
+ return AjaxResult.error(e.getMsg());
+ }
+ /**
+ * 业务异常
+ */
+ @ExceptionHandler(CustomException.class)
+ public AjaxResult businessException(CustomException e) {
+ if (StringUtils.isNull(e.getCode())) {
+ return AjaxResult.error(e.getMessage());
+ }
+ return AjaxResult.error(e.getCode(), e.getMessage());
+ }
+
+
+ /**
+ * GenEBTS基础异常
+ */
+ @ExceptionHandler(GenEbtsException.class)
+ public AjaxResult genEbtsException(GenEbtsException e) {
return AjaxResult.error(e.getMsg());
}
/**
* 业务异常
*/
- @ExceptionHandler(CustomException.class)
- public AjaxResult businessException(CustomException e) {
+ @ExceptionHandler(GenCustomException.class)
+ public AjaxResult genBusinessException(GenCustomException e) {
if (StringUtils.isNull(e.getCode())) {
return AjaxResult.error(e.getMessage());
}
diff --git a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/ApiClassServiceImpl.java b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/ApiClassServiceImpl.java
index 8083226..2ec1ab6 100644
--- a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/ApiClassServiceImpl.java
+++ b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/ApiClassServiceImpl.java
@@ -8,6 +8,7 @@ import com.ebts.generator.service.ApiClassService;
import com.ebts.generator.utils.GenReturnConstants;
import com.ebts.generator.utils.GenSecurityUtils;
import com.ebts.generator.utils.GenServerResult;
+import com.ebts.generator.utils.exception.GenEbtsException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@@ -43,7 +44,7 @@ public class ApiClassServiceImpl implements ApiClassService {
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
- return new GenServerResult(false, GenReturnConstants.DB_EX);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -64,7 +65,7 @@ public class ApiClassServiceImpl implements ApiClassService {
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
- return new GenServerResult>(false, GenReturnConstants.DB_EX);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -86,7 +87,7 @@ public class ApiClassServiceImpl implements ApiClassService {
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
- return new GenServerResult(false, GenReturnConstants.DB_EX);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -108,7 +109,7 @@ public class ApiClassServiceImpl implements ApiClassService {
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
- return new GenServerResult(false, GenReturnConstants.DB_EX);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -129,7 +130,7 @@ public class ApiClassServiceImpl implements ApiClassService {
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
- return new GenServerResult(false, GenReturnConstants.DB_EX);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -150,7 +151,7 @@ public class ApiClassServiceImpl implements ApiClassService {
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
- return new GenServerResult(false, GenReturnConstants.DB_EX);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
}
diff --git a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/GenTableColumnServiceImpl.java b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/GenTableColumnServiceImpl.java
index 06414b2..7c3254c 100644
--- a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/GenTableColumnServiceImpl.java
+++ b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/GenTableColumnServiceImpl.java
@@ -6,6 +6,7 @@ import java.util.List;
import com.ebts.generator.service.GenTableColumnService;
import com.ebts.generator.utils.GenReturnConstants;
import com.ebts.generator.utils.exception.GenCustomException;
+import com.ebts.generator.utils.exception.GenEbtsException;
import com.ebts.generator.utils.text.Convert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -38,7 +39,7 @@ public class GenTableColumnServiceImpl implements GenTableColumnService {
return genTableColumnDao.selectGenTableColumnListByTableId(tableId);
}catch (RuntimeException e){
logger.error(e.getMessage());
- throw new GenCustomException(GenReturnConstants.OP_ERROR);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -54,7 +55,7 @@ public class GenTableColumnServiceImpl implements GenTableColumnService {
return genTableColumnDao.insertGenTableColumn(genTableColumn);
}catch (RuntimeException e){
logger.error(e.getMessage());
- throw new GenCustomException(GenReturnConstants.OP_ERROR);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -72,7 +73,7 @@ public class GenTableColumnServiceImpl implements GenTableColumnService {
return genTableColumnDao.updateGenTableColumn(genTableColumns);
}catch (RuntimeException e){
logger.error(e.getMessage());
- throw new GenCustomException(GenReturnConstants.OP_ERROR);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -88,7 +89,7 @@ public class GenTableColumnServiceImpl implements GenTableColumnService {
return genTableColumnDao.deleteGenTableColumnByIds(Convert.toLongArray(ids));
}catch (RuntimeException e){
logger.error(e.getMessage());
- throw new GenCustomException(GenReturnConstants.OP_ERROR);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
}
diff --git a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/GenTableServiceImpl.java b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/GenTableServiceImpl.java
index 9dfd7bd..acfc99f 100644
--- a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/GenTableServiceImpl.java
+++ b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/GenTableServiceImpl.java
@@ -19,6 +19,7 @@ import com.ebts.generator.utils.*;
import com.ebts.generator.utils.constant.Constants;
import com.ebts.generator.utils.constant.GenConstants;
import com.ebts.generator.utils.exception.GenCustomException;
+import com.ebts.generator.utils.exception.GenEbtsException;
import com.ebts.generator.utils.text.CharsetKit;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
@@ -69,7 +70,7 @@ public class GenTableServiceImpl implements GenTableService {
return genTable;
} catch (RuntimeException e) {
logger.error(e.getMessage());
- throw new GenCustomException(GenReturnConstants.OP_ERROR);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -85,7 +86,7 @@ public class GenTableServiceImpl implements GenTableService {
return genTableDao.selectGenTableList(genTable);
} catch (RuntimeException e) {
logger.error(e.getMessage());
- throw new GenCustomException(GenReturnConstants.OP_ERROR);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -101,7 +102,7 @@ public class GenTableServiceImpl implements GenTableService {
return genTableDao.selectDbTableList(genTable);
} catch (RuntimeException e) {
logger.error(e.getMessage());
- throw new GenCustomException(GenReturnConstants.OP_ERROR);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -117,7 +118,7 @@ public class GenTableServiceImpl implements GenTableService {
return genTableDao.selectDbTableListByNames(tableNames);
} catch (RuntimeException e) {
logger.error(e.getMessage());
- throw new GenCustomException(GenReturnConstants.OP_ERROR);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -132,7 +133,7 @@ public class GenTableServiceImpl implements GenTableService {
return genTableDao.selectGenTableAll();
} catch (RuntimeException e) {
logger.error(e.getMessage());
- throw new GenCustomException(GenReturnConstants.OP_ERROR);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -143,7 +144,7 @@ public class GenTableServiceImpl implements GenTableService {
* @return 结果
*/
@Override
- @Transactional
+ @Transactional(rollbackFor = Exception.class)
public void updateGenTable(GenTable genTable) {
try {
String options = JSON.toJSONString(genTable.getParams());
@@ -177,8 +178,7 @@ public class GenTableServiceImpl implements GenTableService {
}
} catch (GenCustomException e) {
logger.error(e.getMessage());
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- throw new GenCustomException(GenReturnConstants.DB_EX);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -207,7 +207,7 @@ public class GenTableServiceImpl implements GenTableService {
} catch (RuntimeException e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
logger.error(e.getMessage());
- return new GenServerResult<>(false, GenReturnConstants.DB_EX);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -217,7 +217,7 @@ public class GenTableServiceImpl implements GenTableService {
* @param tableList 导入表列表
*/
@Override
- @Transactional
+ @Transactional(rollbackFor = Exception.class)
public void importGenTable(List tableList) {
Long operName = GenSecurityUtils.getUserId();
try {
@@ -235,7 +235,8 @@ public class GenTableServiceImpl implements GenTableService {
}
}
} catch (Exception e) {
- throw new GenCustomException("导入失败:" + e.getMessage());
+ logger.error(e.getMessage());
+ throw new GenEbtsException("导入失败:" + e.getMessage(),e);
}
}
@@ -292,7 +293,7 @@ public class GenTableServiceImpl implements GenTableService {
return dataMap;
} catch (RuntimeException e) {
logger.error(e.getMessage());
- throw new GenCustomException(e.getMessage());
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -312,7 +313,7 @@ public class GenTableServiceImpl implements GenTableService {
return outputStream.toByteArray();
} catch (RuntimeException e) {
logger.error(e.getMessage());
- throw new GenCustomException(GenReturnConstants.OP_ERROR);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -383,7 +384,7 @@ public class GenTableServiceImpl implements GenTableService {
return true;
} catch (RuntimeException e) {
logger.error(e.getMessage());
- throw new GenCustomException(GenReturnConstants.OP_ERROR);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -393,7 +394,7 @@ public class GenTableServiceImpl implements GenTableService {
* @param tableName 表名称
*/
@Override
- @Transactional
+ @Transactional(rollbackFor = Exception.class)
public void synchDb(String tableName) {
try {
GenTable table = genTableDao.selectGenTableByName(tableName);
@@ -419,7 +420,7 @@ public class GenTableServiceImpl implements GenTableService {
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
- throw new GenCustomException(GenReturnConstants.OP_ERROR);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -445,11 +446,11 @@ public class GenTableServiceImpl implements GenTableService {
return outputStream.toByteArray();
} catch (RuntimeException e) {
logger.error(e.getMessage());
- throw new GenCustomException(GenReturnConstants.OP_ERROR);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
- @Transactional
+ @Transactional(rollbackFor = Exception.class)
boolean insertMenuItem(StringWriter stringWriter) {
try {
String sql = stringWriter.toString();
@@ -460,9 +461,8 @@ public class GenTableServiceImpl implements GenTableService {
return true;
}
} catch (RuntimeException e) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
logger.error(e.getMessage());
- return true;
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
diff --git a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/InterTableServiceImpl.java b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/InterTableServiceImpl.java
index fd428ed..538f4d3 100644
--- a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/InterTableServiceImpl.java
+++ b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/InterTableServiceImpl.java
@@ -18,6 +18,7 @@ import com.ebts.generator.entity.ApiClass;
import com.ebts.generator.entity.Module;
import com.ebts.generator.utils.*;
import com.ebts.generator.utils.constant.Constants;
+import com.ebts.generator.utils.exception.GenEbtsException;
import org.apache.commons.io.IOUtils;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
@@ -68,7 +69,7 @@ public class InterTableServiceImpl implements InterTableService {
}
} catch (RuntimeException e) {
logger.error(e.getMessage());
- return new GenServerResult(false, GenReturnConstants.DB_EX);
+ throw new GenEbtsException(GenReturnConstants.OP_ERROR,e);
}
}
@@ -94,7 +95,7 @@ public class InterTableServiceImpl implements InterTableService {
return new GenServerResult