Exemplo n.º 1
0
  /**
   * 展示没有分配到组织的其他权限 描述
   *
   * @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;
  }
Exemplo n.º 2
0
  /**
   * 给组织分配权限 描述
   *
   * @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()}));
  }