@Transactional(rollbackFor = MYException.class) public boolean updateBean(BlackRuleBean bean, User user) throws MYException { BlackRuleBean oldBean = blackRuleDAO.find(bean.getId()); if (null == oldBean) { throw new MYException("数据错误,原单不存在"); } List<BlackRuleProductBean> productList = bean.getProductList(); List<BlackRuleStafferBean> stafferList = bean.getStafferList(); String id = bean.getId(); blackRuleDAO.updateEntityBean(bean); blackRuleProductDAO.deleteEntityBeansByFK(id); blackRuleStafferDAO.deleteEntityBeansByFK(id); for (BlackRuleProductBean each : productList) { each.setRefId(id); blackRuleProductDAO.saveEntityBean(each); } for (BlackRuleStafferBean each1 : stafferList) { each1.setRefId(id); blackRuleStafferDAO.saveEntityBean(each1); } return true; }
@Transactional(rollbackFor = MYException.class) public boolean deleteBean(String id, User user) throws MYException { BlackRuleBean bean = blackRuleDAO.find(id); if (null == bean) { throw new MYException("数据不存在"); } operationLog.info("DEL BlackRuleBean:" + bean); blackRuleDAO.deleteEntityBean(id); blackRuleProductDAO.deleteEntityBeansByFK(id); blackRuleStafferDAO.deleteEntityBeansByFK(id); return true; }