Пример #1
0
  @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;
  }
Пример #2
0
  @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;
  }