Example #1
0
  /**
   * 默认方法 查询现有的数据权限组
   *
   * @throws ToftException
   */
  public void doInsert() throws ToftException {
    Map params = this.getContext().getAllParams();
    params.put("flag", "1");
    params.put("status", "1");
    TableUtils utils = TableUtils.getUtils("dataGroup");
    // 同一类型下组名称重复性验证
    String group_name = (String) this.getContext().getParam("group_name");
    String data_id = (String) this.getContext().getParam("data_id");
    // select * from sys_data_group where group_name=
    String sqlcode =
        "select count(*) from  sys_data_group  where data_id='"
            + data_id
            + "'and group_name='"
            + group_name
            + "'";

    int countcode = SqlUtils.selectInteger(sqlcode, this.getContext().getConn());

    if (countcode > 0) {
      // 缂栧彿閲嶅
      throw ToftException.ThrowToftException(getText("norepeat"));
    }

    String msg = utils.execute();
    this.getContext().dataResult.setMessage(msg);
  }
Example #2
0
  /**
   * 在更新的时候加上验证 同一类型下
   *
   * @throws ToftException
   */
  public void doUpdate() throws ToftException {

    TableUtils utils = TableUtils.getUtils("dataGroup");
    // 同一类型下组名称重复性验证
    String group_name = (String) this.getContext().getParam("group_name");
    String data_id = (String) this.getContext().getParam("data_id");
    // select * from sys_data_group where group_name=
    String sqlcode =
        "select count(*) from  sys_data_group  where data_id='"
            + data_id
            + "'and group_name='"
            + group_name
            + "'";

    int countcode = SqlUtils.selectInteger(sqlcode, this.getContext().getConn());

    if (countcode > 0) {
      // 抛出异常-提示同一类型下组名不重复
      throw ToftException.ThrowToftException(getText("norepeat"));
    }

    String msg = utils.execute();
    this.getContext().dataResult.setMessage(msg);
  }