예제 #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");
  }
예제 #3
0
  /**
   * 保存授权信息
   *
   * <p>2015年4月28日 下午5:00:30 flyfox [email protected]
   *
   * @param roleid
   * @param menus
   */
  public void saveAuth(int roleid, String menus, int update_id) {
    // 删除原有数据库
    Db.update("delete from sys_role_menu where roleid = ? ", roleid);

    if (StrUtils.isNotEmpty(menus)) {
      String[] arr = menus.split(",");
      for (String menuid : arr) {
        SysRoleMenu roleMenu = new SysRoleMenu();
        roleMenu.set("roleid", roleid);
        roleMenu.set("menuid", NumberUtils.parseInt(menuid));

        // 日志添加
        roleMenu.put("update_id", update_id);
        roleMenu.put("update_time", DateUtils.getNow(DateUtils.DEFAULT_REGEX_YYYY_MM_DD_HH_MIN_SS));
        roleMenu.save();
      }
    }
  }
예제 #4
0
  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("保存成功");
  }