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>(true, modeMap); } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult>(false, GenReturnConstants.DB_EX); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @@ -116,7 +117,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); } } @@ -156,7 +157,7 @@ public class InterTableServiceImpl implements InterTableService { } catch (RuntimeException e) { logger.error(e.getMessage()); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - return new GenServerResult(false, GenReturnConstants.DB_EX); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @@ -177,7 +178,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); } } @@ -198,7 +199,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); } } @@ -225,7 +226,7 @@ public class InterTableServiceImpl implements InterTableService { return new GenServerResult>(true, dataMap); } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult>(false, GenReturnConstants.DB_EX); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @@ -253,7 +254,7 @@ public class InterTableServiceImpl implements InterTableService { return new GenServerResult>(true, dataMap); } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult>(false, GenReturnConstants.DB_EX); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @@ -292,7 +293,7 @@ public class InterTableServiceImpl implements InterTableService { } catch (RuntimeException e) { logger.error(e.getMessage()); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - return new GenServerResult(false, "代码生成失败!"); + throw new GenEbtsException("代码生成失败!",e); } } @@ -330,7 +331,7 @@ public class InterTableServiceImpl implements InterTableService { } catch (RuntimeException e) { logger.error(e.getMessage()); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - return new GenServerResult(false, "代码生成失败!"); + throw new GenEbtsException("代码生成失败!",e); } } diff --git a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/ModuleServiceImpl.java b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/ModuleServiceImpl.java index 876e13a..678a70e 100644 --- a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/ModuleServiceImpl.java +++ b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/ModuleServiceImpl.java @@ -8,6 +8,7 @@ import com.ebts.generator.service.ModuleService; 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 ModuleServiceImpl implements ModuleService { } } 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 ModuleServiceImpl implements ModuleService { } } 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 ModuleServiceImpl implements ModuleService { } } 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 ModuleServiceImpl implements ModuleService { } } 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 ModuleServiceImpl implements ModuleService { } } 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 ModuleServiceImpl implements ModuleService { } } 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/QueryServiceImpl.java b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/QueryServiceImpl.java index 2cb1073..34bd094 100644 --- a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/QueryServiceImpl.java +++ b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/QueryServiceImpl.java @@ -10,6 +10,7 @@ import com.ebts.generator.utils.GenReturnConstants; import com.ebts.generator.utils.GenSecurityUtils; import com.ebts.generator.utils.GenServerResult; import com.ebts.generator.utils.entity.GenMenu; +import com.ebts.generator.utils.exception.GenEbtsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -50,12 +51,12 @@ public class QueryServiceImpl implements QueryService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult<>(false, GenReturnConstants.SYS_FAILL); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public GenServerResult Release(UniQuery uniQuery) { try { Integer isRelease = queryDao.Release(uniQuery.getId()); @@ -87,8 +88,7 @@ public class QueryServiceImpl implements QueryService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - return new GenServerResult<>(false, GenReturnConstants.SYS_FAILL); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @@ -96,7 +96,7 @@ public class QueryServiceImpl implements QueryService { * 更新万能查询基本信息和条件 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public GenServerResult updateQueryInfo(UniQuery uniQuery) { try { int uqrenewal = uniQueryDao.updateUniQuery(uniQuery); @@ -113,8 +113,7 @@ public class QueryServiceImpl implements QueryService { return new GenServerResult<>(false, GenReturnConstants.OP_ERROR); } catch (RuntimeException e) { logger.error(e.getMessage()); - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - return new GenServerResult<>(false, GenReturnConstants.SYS_FAILL); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @@ -139,7 +138,7 @@ public class QueryServiceImpl implements QueryService { return new GenServerResult<>(true, dataMap); } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult<>(false, e.getMessage()); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } diff --git a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/RegularServiceImpl.java b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/RegularServiceImpl.java index 1a0f814..b62444b 100644 --- a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/RegularServiceImpl.java +++ b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/RegularServiceImpl.java @@ -9,6 +9,7 @@ import com.ebts.generator.utils.GenDateUtils; 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; @@ -44,7 +45,7 @@ public class RegularServiceImpl implements RegularService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult<>(false, GenReturnConstants.DB_EX); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @@ -65,7 +66,7 @@ public class RegularServiceImpl implements RegularService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult<>(false, GenReturnConstants.DB_EX); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } /** @@ -84,7 +85,7 @@ public class RegularServiceImpl implements RegularService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult<>(false, GenReturnConstants.DB_EX); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @@ -103,7 +104,7 @@ public class RegularServiceImpl implements RegularService { return new GenServerResult<>(true, renewal); } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult<>(false, GenReturnConstants.DB_EX); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @@ -122,7 +123,7 @@ public class RegularServiceImpl implements RegularService { return new GenServerResult<>(true, renewal); } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult<>(false, GenReturnConstants.DB_EX); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @@ -139,7 +140,7 @@ public class RegularServiceImpl implements RegularService { return new GenServerResult<>(true, renewals); } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult<>(false, GenReturnConstants.DB_EX); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @@ -156,7 +157,7 @@ public class RegularServiceImpl implements RegularService { return new GenServerResult<>(true, renewal); } 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/RelServiceImpl.java b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/RelServiceImpl.java index 78e8bcf..1605595 100644 --- a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/RelServiceImpl.java +++ b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/RelServiceImpl.java @@ -4,8 +4,10 @@ import com.ebts.generator.dao.RelDao; import com.ebts.generator.entity.RelColumn; import com.ebts.generator.entity.RelTable; import com.ebts.generator.service.RelService; +import com.ebts.generator.utils.GenReturnConstants; import com.ebts.generator.utils.GenServerResult; import com.ebts.generator.utils.RelUtil; +import com.ebts.generator.utils.exception.GenEbtsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -38,7 +40,7 @@ public class RelServiceImpl implements RelService { return new GenServerResult<>(dataMap); } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult<>(false, "获取数据库表信息错误"); + throw new GenEbtsException("获取数据库表信息错误",e); } } @@ -59,7 +61,7 @@ public class RelServiceImpl implements RelService { return new GenServerResult<>(true,relColumns); } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult<>(false, "获取关联边字段信息错误"); + throw new GenEbtsException("获取关联边字段信息错误",e); } } @@ -70,7 +72,7 @@ public class RelServiceImpl implements RelService { return new GenServerResult<>(columns); }catch (RuntimeException e){ logger.error(e.getMessage()); - return new GenServerResult<>(false,"获取字段信息错误!"); + throw new GenEbtsException("获取字段信息错误",e); } } @@ -81,7 +83,7 @@ public class RelServiceImpl implements RelService { return new GenServerResult<>(relTables); }catch (RuntimeException e){ logger.error(e.getMessage()); - return new GenServerResult<>(false,"获取关联数据错误!"); + throw new GenEbtsException("获取关联数据错误",e); } } } \ No newline at end of file diff --git a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/UniQueryServiceImpl.java b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/UniQueryServiceImpl.java index f8c2bae..96612fe 100644 --- a/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/UniQueryServiceImpl.java +++ b/ebts/ebts-generator/src/main/java/com/ebts/generator/service/impl/UniQueryServiceImpl.java @@ -5,6 +5,7 @@ import java.util.List; 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; @@ -45,7 +46,7 @@ public class UniQueryServiceImpl implements UniQueryService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult(false, GenReturnConstants.DB_EX); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @@ -66,7 +67,7 @@ public class UniQueryServiceImpl implements UniQueryService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult>(false, GenReturnConstants.DB_EX); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @@ -88,7 +89,7 @@ public class UniQueryServiceImpl implements UniQueryService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult(false, GenReturnConstants.DB_EX); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @@ -110,7 +111,7 @@ public class UniQueryServiceImpl implements UniQueryService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - return new GenServerResult(false, GenReturnConstants.DB_EX); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @@ -121,7 +122,7 @@ public class UniQueryServiceImpl implements UniQueryService { * @return 结果 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public GenServerResult deleteUniQueryByIds(Long[] ids) { try { Integer renewal = uniQueryDao.deleteUniQueryByIds(ids); @@ -135,9 +136,8 @@ public class UniQueryServiceImpl implements UniQueryService { return new GenServerResult<>(false, GenReturnConstants.SYS_FAILL); } } catch (RuntimeException e) { - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); logger.error(e.getMessage()); - return new GenServerResult<>(false, GenReturnConstants.DB_EX); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } @@ -148,7 +148,7 @@ public class UniQueryServiceImpl implements UniQueryService { * @return 结果 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public GenServerResult deleteUniQueryById(Long id) { try { Integer renewal = uniQueryDao.deleteUniQueryById(id); @@ -159,9 +159,8 @@ public class UniQueryServiceImpl implements UniQueryService { return new GenServerResult<>(false, GenReturnConstants.SYS_FAILL); } } catch (RuntimeException e) { - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); logger.error(e.getMessage()); - return new GenServerResult<>(false, GenReturnConstants.DB_EX); + throw new GenEbtsException(GenReturnConstants.OP_ERROR,e); } } } \ No newline at end of file diff --git a/ebts/ebts-generator/src/main/java/com/ebts/generator/utils/exception/GenEbtsException.java b/ebts/ebts-generator/src/main/java/com/ebts/generator/utils/exception/GenEbtsException.java new file mode 100644 index 0000000..0d00fc4 --- /dev/null +++ b/ebts/ebts-generator/src/main/java/com/ebts/generator/utils/exception/GenEbtsException.java @@ -0,0 +1,32 @@ +package com.ebts.generator.utils.exception; + +/** + * @Author 18209 + * @Date 2021/6/7 23:32 + * @Email clay@hchyun.com + * @Version 1.0 + */ +public class GenEbtsException extends RuntimeException { + + private String msg; + + private Exception exception; + + public GenEbtsException(String opError, Exception e) { + this.msg = opError; + this.exception = e; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + @Override + public String getMessage() { + return exception.getMessage(); + } +} diff --git a/ebts/ebts-generator/src/main/resources/vm/java/class.java.vm b/ebts/ebts-generator/src/main/resources/vm/java/class.java.vm index f641072..2d7ede3 100644 --- a/ebts/ebts-generator/src/main/resources/vm/java/class.java.vm +++ b/ebts/ebts-generator/src/main/resources/vm/java/class.java.vm @@ -12,7 +12,7 @@ import com.ebts.common.constant.ReturnConstants; import com.ebts.common.core.controller.BaseController; import com.ebts.common.core.entity.AjaxResult; import com.ebts.common.enums.BusinessType; -import com.ebts.common.exception.EBTSException; +import com.ebts.common.exception.EbtsException; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.slf4j.Logger; diff --git a/ebts/ebts-generator/src/main/resources/vm/java/controller.java.vm b/ebts/ebts-generator/src/main/resources/vm/java/controller.java.vm index 3913280..c815ec8 100644 --- a/ebts/ebts-generator/src/main/resources/vm/java/controller.java.vm +++ b/ebts/ebts-generator/src/main/resources/vm/java/controller.java.vm @@ -27,7 +27,7 @@ import org.springframework.web.bind.annotation.RestController; import com.ebts.common.annotation.Log; import com.ebts.common.core.entity.AjaxResult; import com.ebts.common.enums.BusinessType; -import com.ebts.common.exception.EBTSException; +import com.ebts.common.exception.EbtsException; import ${packageName}.entity.${ClassName}; import ${packageName}.service.${ClassName}Service; import com.ebts.common.utils.poi.ExcelUtil; diff --git a/ebts/ebts-quartz/src/main/java/com/ebts/quartz/service/impl/JobServiceImpl.java b/ebts/ebts-quartz/src/main/java/com/ebts/quartz/service/impl/JobServiceImpl.java index 9e300e7..cdcaca4 100644 --- a/ebts/ebts-quartz/src/main/java/com/ebts/quartz/service/impl/JobServiceImpl.java +++ b/ebts/ebts-quartz/src/main/java/com/ebts/quartz/service/impl/JobServiceImpl.java @@ -71,7 +71,7 @@ public class JobServiceImpl implements JobService { * @param job 调度信息 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public int pauseJob(Job job) throws SchedulerException { Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); @@ -89,7 +89,7 @@ public class JobServiceImpl implements JobService { * @param job 调度信息 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public int resumeJob(Job job) throws SchedulerException { Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); @@ -107,7 +107,7 @@ public class JobServiceImpl implements JobService { * @param job 调度信息 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public int deleteJob(Job job) throws SchedulerException { Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); @@ -125,7 +125,7 @@ public class JobServiceImpl implements JobService { * @return 结果 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public void deleteJobByIds(Long[] jobIds) throws SchedulerException { for (Long jobId : jobIds) { Job job = jobMapper.selectJobById(jobId); @@ -139,7 +139,7 @@ public class JobServiceImpl implements JobService { * @param job 调度信息 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public int changeStatus(Job job) throws SchedulerException { int rows = 0; String status = job.getStatus(); @@ -157,7 +157,7 @@ public class JobServiceImpl implements JobService { * @param job 调度信息 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public void run(Job job) throws SchedulerException { Long jobId = job.getJobId(); String jobGroup = job.getJobGroup(); @@ -174,7 +174,7 @@ public class JobServiceImpl implements JobService { * @param job 调度信息 调度信息 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public int insertJob(Job job) throws SchedulerException, TaskException { job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); int rows = jobMapper.insertJob(job); @@ -190,7 +190,7 @@ public class JobServiceImpl implements JobService { * @param job 调度信息 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public int updateJob(Job job) throws SchedulerException, TaskException { Job properties = selectJobById(job.getJobId()); int rows = jobMapper.updateJob(job); diff --git a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/ConfigServiceImpl.java b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/ConfigServiceImpl.java index ab1030f..fd5348e 100644 --- a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/ConfigServiceImpl.java +++ b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/ConfigServiceImpl.java @@ -5,6 +5,7 @@ import java.util.List; import javax.annotation.PostConstruct; import com.ebts.common.constant.ReturnConstants; +import com.ebts.common.exception.EbtsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -47,7 +48,7 @@ public class ConfigServiceImpl implements ConfigService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -66,7 +67,7 @@ public class ConfigServiceImpl implements ConfigService { return configMapper.selectConfig(config); } catch (RuntimeException e) { logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -93,7 +94,7 @@ public class ConfigServiceImpl implements ConfigService { return StringUtils.EMPTY; } catch (RuntimeException e) { logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -109,7 +110,7 @@ public class ConfigServiceImpl implements ConfigService { return configMapper.selectConfigList(config); } catch (RuntimeException e) { logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -129,7 +130,7 @@ public class ConfigServiceImpl implements ConfigService { return row; } catch (RuntimeException e) { logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -149,7 +150,7 @@ public class ConfigServiceImpl implements ConfigService { return row; } catch (RuntimeException e) { logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -176,7 +177,7 @@ public class ConfigServiceImpl implements ConfigService { return count; } catch (RuntimeException e) { logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -190,7 +191,7 @@ public class ConfigServiceImpl implements ConfigService { redisCache.deleteObject(keys); } catch (RuntimeException e) { logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -211,7 +212,7 @@ public class ConfigServiceImpl implements ConfigService { return UserConstants.UNIQUE; } catch (RuntimeException e) { logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -226,7 +227,7 @@ public class ConfigServiceImpl implements ConfigService { return Constants.SYS_CONFIG_KEY + configKey; } catch (RuntimeException e) { logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } } diff --git a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/DeptServiceImpl.java b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/DeptServiceImpl.java index 376c89f..2433bb8 100644 --- a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/DeptServiceImpl.java +++ b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/DeptServiceImpl.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.stream.Collectors; import com.ebts.common.constant.ReturnConstants; +import com.ebts.common.exception.EbtsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -49,7 +50,7 @@ public class DeptServiceImpl implements DeptService { return sysDeptDao.selectDeptList(dept); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -81,7 +82,7 @@ public class DeptServiceImpl implements DeptService { return returnList; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -98,7 +99,7 @@ public class DeptServiceImpl implements DeptService { return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -115,7 +116,7 @@ public class DeptServiceImpl implements DeptService { return sysDeptDao.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly()); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -131,7 +132,7 @@ public class DeptServiceImpl implements DeptService { return sysDeptDao.selectDeptById(deptId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -147,7 +148,7 @@ public class DeptServiceImpl implements DeptService { return sysDeptDao.selectNormalChildrenDeptById(deptId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -164,7 +165,7 @@ public class DeptServiceImpl implements DeptService { return result > 0 ? true : false; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -181,7 +182,7 @@ public class DeptServiceImpl implements DeptService { return result > 0 ? true : false; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -202,7 +203,7 @@ public class DeptServiceImpl implements DeptService { return UserConstants.UNIQUE; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -224,7 +225,7 @@ public class DeptServiceImpl implements DeptService { return sysDeptDao.insertDept(dept); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -253,7 +254,7 @@ public class DeptServiceImpl implements DeptService { return result; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -270,7 +271,7 @@ public class DeptServiceImpl implements DeptService { sysDeptDao.updateDeptStatus(dept); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -292,7 +293,7 @@ public class DeptServiceImpl implements DeptService { } }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -308,7 +309,7 @@ public class DeptServiceImpl implements DeptService { return sysDeptDao.deleteDeptById(deptId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } diff --git a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/DictDataServiceImpl.java b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/DictDataServiceImpl.java index 78c132e..9f08686 100644 --- a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/DictDataServiceImpl.java +++ b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/DictDataServiceImpl.java @@ -4,6 +4,7 @@ import java.util.List; import com.ebts.common.constant.ReturnConstants; import com.ebts.common.exception.CustomException; +import com.ebts.common.exception.EbtsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -36,7 +37,7 @@ public class DictDataServiceImpl implements DictDataService { return dictDataDao.selectDictDataList(dictData); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } diff --git a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/DictTypeServiceImpl.java b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/DictTypeServiceImpl.java index 5c95b2b..45f73e4 100644 --- a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/DictTypeServiceImpl.java +++ b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/DictTypeServiceImpl.java @@ -4,6 +4,7 @@ import java.util.List; import javax.annotation.PostConstruct; import com.ebts.common.constant.ReturnConstants; +import com.ebts.common.exception.EbtsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -48,7 +49,7 @@ public class DictTypeServiceImpl implements DictTypeService { } }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -64,7 +65,7 @@ public class DictTypeServiceImpl implements DictTypeService { return dictTypeMapper.selectDictTypeList(dictType); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -79,7 +80,7 @@ public class DictTypeServiceImpl implements DictTypeService { return dictTypeMapper.selectDictTypeAll(); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -104,7 +105,7 @@ public class DictTypeServiceImpl implements DictTypeService { return null; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -120,7 +121,7 @@ public class DictTypeServiceImpl implements DictTypeService { return dictTypeMapper.selectDictTypeById(dictId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -136,7 +137,7 @@ public class DictTypeServiceImpl implements DictTypeService { return dictTypeMapper.selectDictTypeByType(dictType); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -162,7 +163,7 @@ public class DictTypeServiceImpl implements DictTypeService { return count; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -175,7 +176,7 @@ public class DictTypeServiceImpl implements DictTypeService { DictUtils.clearDictCache(); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -195,7 +196,7 @@ public class DictTypeServiceImpl implements DictTypeService { return row; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -206,7 +207,7 @@ public class DictTypeServiceImpl implements DictTypeService { * @return 结果 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public int updateDictType(DictType dictType) { try { DictType oldDict = dictTypeMapper.selectDictTypeById(dictType.getDictId()); @@ -219,7 +220,7 @@ public class DictTypeServiceImpl implements DictTypeService { }catch (RuntimeException e){ logger.error(e.getMessage()); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -240,7 +241,7 @@ public class DictTypeServiceImpl implements DictTypeService { return UserConstants.UNIQUE; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } } diff --git a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/FileServiceImpl.java b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/FileServiceImpl.java index 292b1b0..bfaa966 100644 --- a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/FileServiceImpl.java +++ b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/FileServiceImpl.java @@ -6,6 +6,7 @@ import java.util.List; import com.ebts.common.constant.ReturnConstants; import com.ebts.common.core.entity.entity.Role; import com.ebts.common.core.entity.model.LoginUser; +import com.ebts.common.exception.EbtsException; import com.ebts.common.utils.SecurityUtils; import com.ebts.common.utils.ServerResult; import com.ebts.system.entity.SysFile; @@ -48,7 +49,7 @@ public class FileServiceImpl implements FileService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult<>(false, ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -69,7 +70,7 @@ public class FileServiceImpl implements FileService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult>(false, ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -80,7 +81,7 @@ public class FileServiceImpl implements FileService { return new ServerResult<>(true, sysFiles); } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult>(false, ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -117,7 +118,7 @@ public class FileServiceImpl implements FileService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult<>(false, ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -146,7 +147,7 @@ public class FileServiceImpl implements FileService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult<>(false, ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -228,7 +229,7 @@ public class FileServiceImpl implements FileService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult<>(false, ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -249,7 +250,7 @@ public class FileServiceImpl implements FileService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult<>(false, ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } diff --git a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/LogininforServiceImpl.java b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/LogininforServiceImpl.java index 8ee055d..9d34c0f 100644 --- a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/LogininforServiceImpl.java +++ b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/LogininforServiceImpl.java @@ -4,6 +4,7 @@ import java.util.List; import com.ebts.common.constant.ReturnConstants; import com.ebts.common.exception.CustomException; +import com.ebts.common.exception.EbtsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -35,7 +36,7 @@ public class LogininforServiceImpl implements LogininforService { logininforMapper.insertLogininfor(logininfor); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -51,7 +52,7 @@ public class LogininforServiceImpl implements LogininforService { return logininforMapper.selectLogininforList(logininfor); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -67,7 +68,7 @@ public class LogininforServiceImpl implements LogininforService { return logininforMapper.deleteLogininforByIds(infoIds); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -80,7 +81,7 @@ public class LogininforServiceImpl implements LogininforService { logininforMapper.cleanLogininfor(); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } } diff --git a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/MenuServiceImpl.java b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/MenuServiceImpl.java index 8fc3d2b..417c390 100644 --- a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/MenuServiceImpl.java +++ b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/MenuServiceImpl.java @@ -11,6 +11,7 @@ import java.util.stream.Collectors; import com.ebts.common.constant.ReturnConstants; import com.ebts.common.exception.CustomException; +import com.ebts.common.exception.EbtsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -61,7 +62,7 @@ public class MenuServiceImpl implements MenuService { return selectMenuList(new Menu(), userId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -85,7 +86,7 @@ public class MenuServiceImpl implements MenuService { return menuList; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -108,7 +109,7 @@ public class MenuServiceImpl implements MenuService { return permsSet; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -130,7 +131,7 @@ public class MenuServiceImpl implements MenuService { return getChildPerms(menus, 0); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -147,7 +148,7 @@ public class MenuServiceImpl implements MenuService { return menuMapper.selectMenuListByRoleId(roleId, role.isMenuCheckStrictly()); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -188,7 +189,7 @@ public class MenuServiceImpl implements MenuService { return routers; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -220,7 +221,7 @@ public class MenuServiceImpl implements MenuService { return returnList; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -237,7 +238,7 @@ public class MenuServiceImpl implements MenuService { return menuTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -253,7 +254,7 @@ public class MenuServiceImpl implements MenuService { return menuMapper.selectMenuById(menuId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -270,7 +271,7 @@ public class MenuServiceImpl implements MenuService { return result > 0 ? true : false; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -287,7 +288,7 @@ public class MenuServiceImpl implements MenuService { return result > 0 ? true : false; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -303,7 +304,7 @@ public class MenuServiceImpl implements MenuService { return menuMapper.insertMenu(menu); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -319,7 +320,7 @@ public class MenuServiceImpl implements MenuService { return menuMapper.updateMenu(menu); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -335,7 +336,7 @@ public class MenuServiceImpl implements MenuService { return menuMapper.deleteMenuById(menuId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -356,7 +357,7 @@ public class MenuServiceImpl implements MenuService { return UserConstants.UNIQUE; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } diff --git a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/NoticeServiceImpl.java b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/NoticeServiceImpl.java index 0ebff67..0162b4a 100644 --- a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/NoticeServiceImpl.java +++ b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/NoticeServiceImpl.java @@ -4,6 +4,7 @@ import java.util.List; import com.ebts.common.constant.ReturnConstants; import com.ebts.common.exception.CustomException; +import com.ebts.common.exception.EbtsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -36,7 +37,7 @@ public class NoticeServiceImpl implements NoticeService { return noticeMapper.selectNoticeById(noticeId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -52,7 +53,7 @@ public class NoticeServiceImpl implements NoticeService { return noticeMapper.selectNoticeList(notice); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -68,7 +69,7 @@ public class NoticeServiceImpl implements NoticeService { return noticeMapper.insertNotice(notice); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -84,7 +85,7 @@ public class NoticeServiceImpl implements NoticeService { return noticeMapper.updateNotice(notice); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -100,7 +101,7 @@ public class NoticeServiceImpl implements NoticeService { return noticeMapper.deleteNoticeById(noticeId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -116,7 +117,7 @@ public class NoticeServiceImpl implements NoticeService { return noticeMapper.deleteNoticeByIds(noticeIds); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } } diff --git a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/OperLogServiceImpl.java b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/OperLogServiceImpl.java index 0895017..1e2ffbd 100644 --- a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/OperLogServiceImpl.java +++ b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/OperLogServiceImpl.java @@ -4,6 +4,7 @@ import java.util.List; import com.ebts.common.constant.ReturnConstants; import com.ebts.common.exception.CustomException; +import com.ebts.common.exception.EbtsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -35,7 +36,7 @@ public class OperLogServiceImpl implements OperLogService { operLogMapper.insertOperlog(operLog); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -51,7 +52,7 @@ public class OperLogServiceImpl implements OperLogService { return operLogMapper.selectOperLogList(operLog); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -67,7 +68,7 @@ public class OperLogServiceImpl implements OperLogService { return operLogMapper.deleteOperLogByIds(operIds); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -83,7 +84,7 @@ public class OperLogServiceImpl implements OperLogService { return operLogMapper.selectOperLogById(operId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -96,7 +97,7 @@ public class OperLogServiceImpl implements OperLogService { operLogMapper.cleanOperLog(); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } } diff --git a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/PostServiceImpl.java b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/PostServiceImpl.java index 1bd4f08..3468685 100644 --- a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/PostServiceImpl.java +++ b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/PostServiceImpl.java @@ -3,6 +3,7 @@ package com.ebts.system.service.impl; import java.util.List; import com.ebts.common.constant.ReturnConstants; +import com.ebts.common.exception.EbtsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -42,7 +43,7 @@ public class PostServiceImpl implements PostService { return postMapper.selectPostList(post); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -57,7 +58,7 @@ public class PostServiceImpl implements PostService { return postMapper.selectPostAll(); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -73,7 +74,7 @@ public class PostServiceImpl implements PostService { return postMapper.selectPostById(postId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -89,7 +90,7 @@ public class PostServiceImpl implements PostService { return postMapper.selectPostListByUserId(userId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -110,7 +111,7 @@ public class PostServiceImpl implements PostService { return UserConstants.UNIQUE; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -131,7 +132,7 @@ public class PostServiceImpl implements PostService { return UserConstants.UNIQUE; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -147,7 +148,7 @@ public class PostServiceImpl implements PostService { return userPostMapper.countUserPostById(postId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -163,7 +164,7 @@ public class PostServiceImpl implements PostService { return postMapper.deletePostById(postId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -186,7 +187,7 @@ public class PostServiceImpl implements PostService { return postMapper.deletePostByIds(postIds); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -202,7 +203,7 @@ public class PostServiceImpl implements PostService { return postMapper.insertPost(post); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -218,7 +219,7 @@ public class PostServiceImpl implements PostService { return postMapper.updatePost(post); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } } diff --git a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/RealQueryServiceImpl.java b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/RealQueryServiceImpl.java index 405dc39..ae171e0 100644 --- a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/RealQueryServiceImpl.java +++ b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/RealQueryServiceImpl.java @@ -1,6 +1,7 @@ package com.ebts.system.service.impl; import com.alibaba.fastjson.JSONObject; +import com.ebts.common.exception.EbtsException; import com.github.pagehelper.PageHelper; import com.ebts.common.constant.ReturnConstants; import com.ebts.common.utils.ServerResult; @@ -36,7 +37,7 @@ public class RealQueryServiceImpl implements RealQueryService { return new ServerResult<>(true, uniCons); } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult<>(false, ReturnConstants.DB_EX); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -68,7 +69,7 @@ public class RealQueryServiceImpl implements RealQueryService { } } catch (RuntimeException e) { logger.error(e.getMessage()); - return new ServerResult<>(false, ReturnConstants.SYS_FAILL); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } diff --git a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/RoleServiceImpl.java b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/RoleServiceImpl.java index b10819f..4f77a25 100644 --- a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/RoleServiceImpl.java +++ b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/RoleServiceImpl.java @@ -7,6 +7,7 @@ import java.util.List; import java.util.Set; import com.ebts.common.constant.ReturnConstants; +import com.ebts.common.exception.EbtsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -61,7 +62,7 @@ public class RoleServiceImpl implements RoleService { return roleMapper.selectRoleList(role); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -84,7 +85,7 @@ public class RoleServiceImpl implements RoleService { return permsSet; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -100,7 +101,7 @@ public class RoleServiceImpl implements RoleService { return SpringUtils.getAopProxy(this).selectRoleList(new Role(type)); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -116,7 +117,7 @@ public class RoleServiceImpl implements RoleService { return roleMapper.selectRoleListByUserId(userId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -132,7 +133,7 @@ public class RoleServiceImpl implements RoleService { return roleMapper.selectRoleById(roleId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -153,7 +154,7 @@ public class RoleServiceImpl implements RoleService { return UserConstants.UNIQUE; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -174,7 +175,7 @@ public class RoleServiceImpl implements RoleService { return UserConstants.UNIQUE; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -191,7 +192,7 @@ public class RoleServiceImpl implements RoleService { } }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -207,7 +208,7 @@ public class RoleServiceImpl implements RoleService { return userRoleMapper.countUserRoleByRoleId(roleId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -227,7 +228,7 @@ public class RoleServiceImpl implements RoleService { }catch (RuntimeException e){ logger.error(e.getMessage()); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -249,7 +250,7 @@ public class RoleServiceImpl implements RoleService { }catch (RuntimeException e){ logger.error(e.getMessage()); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -265,7 +266,7 @@ public class RoleServiceImpl implements RoleService { return roleMapper.updateRole(role); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -288,7 +289,7 @@ public class RoleServiceImpl implements RoleService { }catch (RuntimeException e){ TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } diff --git a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/UserOnlineServiceImpl.java b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/UserOnlineServiceImpl.java index 817721c..6b38b56 100644 --- a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/UserOnlineServiceImpl.java +++ b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/UserOnlineServiceImpl.java @@ -2,6 +2,7 @@ package com.ebts.system.service.impl; import com.ebts.common.constant.ReturnConstants; import com.ebts.common.exception.CustomException; +import com.ebts.common.exception.EbtsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; @@ -35,7 +36,7 @@ public class UserOnlineServiceImpl implements UserOnlineService { return null; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -55,7 +56,7 @@ public class UserOnlineServiceImpl implements UserOnlineService { return null; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -76,7 +77,7 @@ public class UserOnlineServiceImpl implements UserOnlineService { return null; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -106,7 +107,7 @@ public class UserOnlineServiceImpl implements UserOnlineService { return userOnline; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } } diff --git a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/UserServiceImpl.java b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/UserServiceImpl.java index c27f418..676bba6 100644 --- a/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/UserServiceImpl.java +++ b/ebts/ebts-system/src/main/java/com/ebts/system/service/impl/UserServiceImpl.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import com.ebts.common.constant.ReturnConstants; +import com.ebts.common.exception.EbtsException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -68,7 +69,7 @@ public class UserServiceImpl implements UserService { return userMapper.selectUserList(user); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -84,7 +85,7 @@ public class UserServiceImpl implements UserService { return userMapper.selectUserByUserName(userName); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -100,7 +101,7 @@ public class UserServiceImpl implements UserService { return userMapper.selectUserById(userId); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -124,7 +125,7 @@ public class UserServiceImpl implements UserService { return idsStr.toString(); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -148,7 +149,7 @@ public class UserServiceImpl implements UserService { return idsStr.toString(); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -168,7 +169,7 @@ public class UserServiceImpl implements UserService { return UserConstants.UNIQUE; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -189,7 +190,7 @@ public class UserServiceImpl implements UserService { return UserConstants.UNIQUE; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -210,7 +211,7 @@ public class UserServiceImpl implements UserService { return UserConstants.UNIQUE; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -227,7 +228,7 @@ public class UserServiceImpl implements UserService { } }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -251,7 +252,7 @@ public class UserServiceImpl implements UserService { }catch (RuntimeException e){ logger.error(e.getMessage()); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -262,7 +263,7 @@ public class UserServiceImpl implements UserService { * @return 结果 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public int updateUser(User user) { try { Long userId = user.getUserId(); @@ -278,7 +279,7 @@ public class UserServiceImpl implements UserService { }catch (RuntimeException e){ logger.error(e.getMessage()); TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -294,7 +295,7 @@ public class UserServiceImpl implements UserService { return userMapper.updateUser(user); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -310,7 +311,7 @@ public class UserServiceImpl implements UserService { return userMapper.updateUser(user); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -327,7 +328,7 @@ public class UserServiceImpl implements UserService { return userMapper.updateUserAvatar(userName, avatar) > 0; }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -343,7 +344,7 @@ public class UserServiceImpl implements UserService { return userMapper.updateUser(user); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -360,7 +361,7 @@ public class UserServiceImpl implements UserService { return userMapper.resetUserPwd(userName, password); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -415,7 +416,7 @@ public class UserServiceImpl implements UserService { * @return 结果 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public int deleteUserById(Long userId) { try { // 删除用户与角色关联 @@ -425,8 +426,7 @@ public class UserServiceImpl implements UserService { return userMapper.deleteUserById(userId); }catch (RuntimeException e){ logger.error(e.getMessage()); - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -445,7 +445,7 @@ public class UserServiceImpl implements UserService { return userMapper.deleteUserByIds(userIds); }catch (RuntimeException e){ logger.error(e.getMessage()); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } @@ -458,7 +458,7 @@ public class UserServiceImpl implements UserService { * @return 结果 */ @Override - @Transactional + @Transactional(rollbackFor = Exception.class) public String importUser(List userList, Boolean isUpdateSupport, Long operName) { try { if (StringUtils.isNull(userList) || userList.size() == 0) { @@ -504,8 +504,7 @@ public class UserServiceImpl implements UserService { return successMsg.toString(); }catch (RuntimeException e){ logger.error(e.getMessage()); - TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); - throw new CustomException(ReturnConstants.OP_ERROR); + throw new EbtsException(ReturnConstants.OP_ERROR,e); } } }