| | |
| | | * @return 执行结果 |
| | | */ |
| | | @Override |
| | | public R submit(BtmTypeDTO btmTypeDTO, boolean autoCreateTable) { |
| | | TransactionStatus transaction = null; |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R submit(BtmTypeDTO btmTypeDTO, boolean autoCreateTable) throws ServiceException { |
| | | /*TransactionStatus transaction = null; |
| | | DefaultTransactionDefinition def = null; |
| | | if (autoCreateTable) { |
| | | def = new DefaultTransactionDefinition(); |
| | |
| | | // 事物隔离级别,开启新事务,这样会比较安全些。 |
| | | transaction = dataSourceTransactionManager.getTransaction(def); |
| | | // 获得事务状态 |
| | | } |
| | | }*/ |
| | | checkBtmTypeBeforeSave(btmTypeDTO); |
| | | BtmType btmTypeDO = Optional.ofNullable(BeanUtil.copy(btmTypeDTO, BtmType.class)).orElseGet(BtmType::new); |
| | | btmTypeDO.setBizDomain(btmTypeDTO.getBizDomain()); |
| | |
| | | btmTypeVO.setAttributes(afterAttributes); |
| | | try { |
| | | if (autoCreateTable) { |
| | | // checkTableSame(btmTypeVO); |
| | | // checkTableSame(btmTypeVO); |
| | | R result = DomainRepeater.submitBtmType(btmTypeDTO.getBizDomain(), btmTypeVO); |
| | | if (result.isSuccess()){ |
| | | List<ModifyAttributeInfo> infoList = new ArrayList<>(); |
| | |
| | | }); |
| | | modifyAttributeService.saveBatch(ModifyAttributeWrapper.build().listEntityBeforeSave(infoList)); |
| | | } |
| | | dataSourceTransactionManager.commit(transaction); |
| | | // dataSourceTransactionManager.commit(transaction); |
| | | }else { |
| | | dataSourceTransactionManager.rollback(transaction); |
| | | return R.fail(result.getMsg()); |
| | | // dataSourceTransactionManager.rollback(transaction); |
| | | // 创建表报错,抛出异常让该方法回滚 |
| | | throw new VciBaseException(result.getMsg()); |
| | | // return R.fail(result.getMsg()); |
| | | } |
| | | } |
| | | } catch (Throwable e) { |
| | | if (autoCreateTable) { |
| | | dataSourceTransactionManager.rollback(transaction); |
| | | // dataSourceTransactionManager.rollback(transaction); |
| | | throw new VciBaseException(e.getMessage()); |
| | | } |
| | | } |