/**
   * 展示没有分配到组织的其他权限 描述
   *
   * @param map
   * @param organizationId
   * @return
   */
  @RequiresPermissions("Organization:assign")
  @RequestMapping(
      value = "/lookup2create/organizationRole/{organizationId}",
      method = {RequestMethod.GET, RequestMethod.POST})
  public String listUnassignRole(Map<String, Object> map, @PathVariable Long organizationId) {
    Page page = new Page();
    page.setNumPerPage(Integer.MAX_VALUE);

    List<OrganizationRole> organizationRoles =
        organizationRoleService.findByOrganizationId(organizationId);
    List<Role> roles = roleService.findAll(page);

    List<Role> rentList = new ArrayList<Role>();
    // 删除已分配roles
    for (Role role : roles) {
      boolean isHas = false;
      for (OrganizationRole or : organizationRoles) {
        if (or.getRole().getId().equals(role.getId())) {
          isHas = true;
          break;
        }
      }
      if (isHas == false) {
        rentList.add(role);
      }
    }

    map.put("organizationRoles", organizationRoles);
    map.put("roles", rentList);

    map.put("organizationId", organizationId);
    return LOOK_UP_ROLE;
  }
  /**
   * 给组织分配权限 描述
   *
   * @param userRole
   */
  @Log(message = "向{0}组织分配了{1}的角色。")
  @RequiresPermissions("Organization:assign")
  @RequestMapping(
      value = "/create/organizationRole",
      method = {RequestMethod.POST})
  public @ResponseBody void assignRole(OrganizationRole organizationRole) {
    organizationRoleService.saveOrUpdate(organizationRole);

    Organization organization = organizationService.get(organizationRole.getOrganization().getId());
    Role role = roleService.get(organizationRole.getRole().getId());
    LogUitls.putArgs(
        LogMessageObject.newWrite()
            .setObjects(new Object[] {organization.getName(), role.getName()}));
  }
  /**
   * 删除组织分配的角色 描述
   *
   * @param organizationId
   */
  @Log(message = "撤销了{0}组织的{1}角色。")
  @RequiresPermissions("Organization:assign")
  @RequestMapping(
      value = "/delete/organizationRole/{organizationRoleId}",
      method = {RequestMethod.POST})
  public @ResponseBody void deleteOrganizationRole(@PathVariable Long organizationRoleId) {
    OrganizationRole organizationRole = organizationRoleService.get(organizationRoleId);
    LogUitls.putArgs(
        LogMessageObject.newWrite()
            .setObjects(
                new Object[] {
                  organizationRole.getOrganization().getName(), organizationRole.getRole().getName()
                }));

    organizationRoleService.delete(organizationRoleId);
  }