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");
  }
  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");
  }
  public void save() {
    Integer pid = getParaToInt();
    SysUser model = getModel(SysUser.class);

    // 日志添加
    Integer userid = getSessionUser().getUserID();
    String now = getNow();
    model.put("update_id", userid);
    model.put("update_time", now);
    if (pid != null && pid > 0) { // 更新
      model.update();
    } else { // 新增
      model.remove("userid");
      if (StrUtils.isEmpty(model.getStr("password"))) {
        model.put("password", JFlyFoxUtils.getDefaultPassword());
      }
      model.put("create_id", userid);
      model.put("create_time", now);
      model.save();
    }
    UserCache.init();
    renderMessage("保存成功");
  }