Exemplo n.º 1
0
  /**
   * 设置权限
   *
   * @param mapping
   * @param actionForm
   * @param request
   * @param response
   * @return
   * @throws Exception
   */
  public ActionForward setPrivilege(
      ActionMapping mapping,
      ActionForm actionForm,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    long roleId = ParamUtil.getLongParameter(request, "roleId", 0);
    long[] appId = ParamUtil.getLongParameterValues(request, "appId");
    for (int i = 0; i < appId.length; i++) {
      long id = ParamUtil.getLongParameter(request, "access" + appId[i], 0);
      if (id != 1) {
        appId[i] = 0;
      }
    }
    long[] funcId = ParamUtil.getLongParameterValues(request, "funcId");

    boolean ret = sysDeptRoleService.saveRoleApplication(roleId, appId, funcId);
    ActionMessages messages = new ActionMessages();
    if (ret) { // 保存成功
      messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("role.app_success"));
    } else { // 保存失败
      messages.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage("role.app_failure"));
    }
    addMessages(request, messages);

    return mapping.findForward("show_msg");
  }
Exemplo n.º 2
0
 /**
  * 显示角色权限映射页面
  *
  * @param mapping
  * @param actionForm
  * @param request
  * @param response
  * @return
  * @throws Exception
  */
 public ActionForward showPrivilege(
     ActionMapping mapping,
     ActionForm actionForm,
     HttpServletRequest request,
     HttpServletResponse response)
     throws Exception {
   long deptId = ParamUtil.getLongParameter(request, "deptId", 0);
   long roleId = ParamUtil.getLongParameter(request, "roleId", 0);
   SysDeptRole deptRole = sysDeptRoleService.find(deptId, roleId);
   if (deptRole == null) { // 如果没有找到则创建一个
     deptRole = new SysDeptRole();
     deptRole.setDept(sysDepartmentService.findById(deptId));
     deptRole.setRole(sysRoleService.findById(roleId));
     sysDeptRoleService.create(deptRole);
   }
   request.setAttribute("role", deptRole);
   SysTree parent = sysTreeService.getSysTreeByCode(Constants.TREE_APP);
   List list = new ArrayList();
   sysTreeService.getSysTree(list, (int) parent.getId(), 0);
   request.setAttribute("list", list);
   return mapping.findForward("show_privilege");
 }