コード例 #1
0
  /**
   * 检索角色包含角色信息列表
   *
   * @throws Exception
   */
  public String listHaveRoles() throws Exception {
    String type = Struts2Utils.getParameter("type");
    long id = Struts2Utils.getLongParameter("id", 0);

    RightHold rightHold = rightHoldManager.getRightHold(type, id);
    List<Role> roleList = rightHoldManager.listHoldsRoles(rightHold);

    String jsonStr = JsonHelper.formatObjectToJsonString(roleList);
    Struts2Utils.renderJson(jsonStr);
    return null;
  }
コード例 #2
0
  /**
   * 去除角色包含角色
   *
   * @throws Exception
   */
  public String removeHaveRole() throws Exception {
    String type = Struts2Utils.getParameter("type");
    long id = Struts2Utils.getLongParameter("id", 0);
    long haveId = Struts2Utils.getLongParameter("haveId", 0);

    String jsonStr;
    try {
      RightHold rightHold = rightHoldManager.getRightHold(type, id);
      Role haveRole = roleManager.getRole(haveId);

      rightHoldManager.removeHaveRole(rightHold, haveRole);

      jsonStr = JsonHelper.combinSuccessJsonString("data", haveId);
    } catch (Exception e) {
      jsonStr = JsonHelper.combinFailJsonString(e);
    }

    Struts2Utils.renderJson(jsonStr);
    return null;
  }
コード例 #3
0
  /**
   * 添加角色包含许可
   *
   * @throws Exception
   */
  public String addHavePermission() throws Exception {
    String type = Struts2Utils.getParameter("type");
    long id = Struts2Utils.getLongParameter("id", 0);
    String objectCode = Struts2Utils.getParameter("objectCode");
    String haveOperations = Struts2Utils.getParameter("haveOperations");

    String jsonStr;
    try {
      RightHold rightHold = rightHoldManager.getRightHold(type, id);
      Permission permission =
          rightHoldManager.addHavePermission(rightHold, objectCode, haveOperations, "");

      jsonStr = JsonHelper.combinSuccessJsonString("data", permission);
    } catch (Exception e) {
      jsonStr = JsonHelper.combinFailJsonString(e);
    }

    Struts2Utils.renderJson(jsonStr);
    return null;
  }