@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 addBean(BlackRuleBean bean, User user) throws MYException { Expression exp = new Expression(bean, this); exp.check("#name &unique @blackRuleDAO", "名称已经存在"); List<BlackRuleProductBean> productList = bean.getProductList(); List<BlackRuleStafferBean> stafferList = bean.getStafferList(); String id = commonDAO.getSquenceString20(); bean.setId(id); blackRuleDAO.saveEntityBean(bean); for (BlackRuleProductBean each : productList) { each.setRefId(id); blackRuleProductDAO.saveEntityBean(each); } for (BlackRuleStafferBean each1 : stafferList) { each1.setRefId(id); blackRuleStafferDAO.saveEntityBean(each1); } return true; }
/** * @param stafferId * @param ruleId * @return */ private boolean stafferIdInBlackRule(String stafferId, String ruleId) { List<BlackRuleStafferBean> ruleStafferList = blackRuleStafferDAO.queryEntityBeansByFK(ruleId); for (BlackRuleStafferBean eachRuleStaffer : ruleStafferList) { if (stafferId.equals(eachRuleStaffer.getStafferId())) { return true; } } return false; }
@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; }