public Boolean save(HtmlElementConfig htmlElementConfig) throws Exception { try { Long id = htmlElementConfigMapper.save(htmlElementConfig); return id == 0 ? false : true; } catch (Exception e) { if (e instanceof DuplicateKeyException) { ErpException erpException = new ErpException("", "请检查是否唯一"); e = erpException; } throw e; } }
@Override public Boolean batchSave(List<HtmlElementConfig> htmlElementConfigList) { // 事务控制 TransactionStatus status = null; try { // 开始事务 status = this.initTansactionStatus(transactionManager, TransactionDefinition.PROPAGATION_REQUIRED); for (HtmlElementConfig htmlElementConfig : htmlElementConfigList) { htmlElementConfigMapper.save(htmlElementConfig); } transactionManager.commit(status); return true; } catch (Exception e) { transactionManager.rollback(status); logger.error("批量保存失败", e); return false; } }