예제 #1
0
  public void list() {
    SysRole model = getModelByAttr(SysRole.class);

    SQLUtils sql = new SQLUtils(" from sys_role t where 1=1 ");
    if (model.getAttrValues().length != 0) {
      sql.setAlias("t");
      // 查询条件
      sql.whereLike("name", model.getStr("name"));
    }

    // 排序
    String orderBy = getBaseForm().getOrderBy();
    if (StrUtils.isEmpty(orderBy)) {
      sql.append(" order by sort,id desc");
    } else {
      sql.append(" order by ").append(orderBy);
    }

    String sqlSelect =
        "select t.* "
            + ",(select group_concat(m.name) from sys_role_menu rm left JOIN  sys_menu m ON rm.menuid = m.id where rm.roleid = t.id ) as menus ";

    Page<SysRole> page =
        SysRole.dao.paginate(
            getPaginator(),
            sqlSelect, //
            sql.toString().toString());

    // 下拉框
    setAttr("page", page);
    setAttr("attr", model);
    render(path + "list.html");
  }
예제 #2
0
  public void list() {
    SysUser model = getModelByAttr(SysUser.class);

    SQLUtils sql =
        new SQLUtils(
            " from sys_user t " //
                + " left join sys_department d on d.id = t.departid " //
                + " where 1 = 1 and userid != 1 ");

    if (model.getAttrValues().length != 0) {
      sql.whereLike("username", model.getStr("username"));
      sql.whereLike("realname", model.getStr("realname"));
      sql.whereEquals("usertype", model.getInt("usertype"));
      sql.whereEquals("departid", model.getInt("departid"));
    }

    // 排序
    String orderBy = getBaseForm().getOrderBy();
    if (StrUtils.isEmpty(orderBy)) {
      sql.append(" order by userid desc");
    } else {
      sql.append(" order by ").append(orderBy);
    }

    Page<SysUser> page =
        SysUser.dao.paginate(
            getPaginator(), "select t.*,d.name as departname ", sql.toString().toString());
    // 下拉框
    setAttr("departSelect", new DepartmentSvc().selectDepart(model.getInt("departid")));

    setAttr("page", page);
    setAttr("attr", model);
    render(path + "list.html");
  }