private ChooseOrganizationResponse queryOrg(ChooseOrganizationRequest request) {
    OrganSearchResult rs = new OrganSearchResult();
    List<OrganicationClient> lt = new ArrayList<OrganicationClient>();
    OrganicationClient client = new OrganicationClient();
    Corporation corp =
        corporationService.findCorporationById(request.getSession().getCorporationId());
    client.setId(corp.getId());
    client.setName(corp.getName());
    client.setType(OrganType.ORG);
    lt.add(client);

    rs.setResult(lt);
    rs.setTotal(1);
    return new ChooseOrganizationResponse(rs);
  }
 private ChooseOrganizationResponse queryDept(ChooseOrganizationRequest request) {
   List<Department> result =
       departmentService.getDepartmentsOfCorporationAndKey(
           request.getSession().getCorporationId(), request.getCriteria().getKey());
   List<OrganicationClient> lt = new ArrayList<OrganicationClient>();
   for (Department dept : result) {
     OrganicationClient client = new OrganicationClient();
     client.setId(dept.getId());
     client.setName(dept.getName());
     client.setType(OrganType.DEPT);
     lt.add(client);
   }
   OrganSearchResult rs = new OrganSearchResult();
   rs.setResult(lt);
   rs.setTotal(result.size());
   return new ChooseOrganizationResponse(rs);
 }
  private ChooseOrganizationResponse queryStaff(ChooseOrganizationRequest request) {
    StaffSearchCriteria criteria = new StaffSearchCriteria();
    if (request.getCriteria().getPagination() != null) {
      PaginationDetail detail = new PaginationDetail();
      detail.setLimit(request.getCriteria().getPagination().getLimit());
      detail.setStart(request.getCriteria().getPagination().getStart());

      criteria.setPaginationDetail(detail);
    }

    if (request.getCriteria().getSorting() != null) {
      SortingDetail sortingDetail = new SortingDetail();
      sortingDetail.setSort(request.getCriteria().getSorting().getSort());
      sortingDetail.setDirection(request.getCriteria().getSorting().getDirection());
      criteria.setSortingDetail(sortingDetail);
    }
    if (request.getCriteria().getKey() != null)
      criteria.setStaffNameorNo(request.getCriteria().getKey());

    UserContext context = new UserContext();
    context.setCorporationId(request.getSession().getCorporationId());
    context.setUserId(request.getSession().getToken());
    context.setLoginName(request.getSession().getLoginName());
    context.setUserRoles(UserRoleTool.adaptToRole(request.getSession().getUserRoles()));

    QueryStaffPageActionResult result = staffService.queryStaffList(criteria, context);

    List<OrganicationClient> lt = new ArrayList<OrganicationClient>();

    for (Staff staff : result.getResultList()) {
      OrganicationClient client = new OrganicationClient();
      client.setId(staff.getId());
      client.setName(staff.getName());
      client.setType(OrganType.STAFF);
      lt.add(client);
    }
    OrganSearchResult rs = new OrganSearchResult();
    rs.setResult(lt);
    rs.setTotal(result.getTotal());
    return new ChooseOrganizationResponse(rs);
  }
  private ChooseOrganizationResponse queryGroup(ChooseOrganizationRequest request) {
    UserContext context = new UserContext();
    context.setCorporationId(request.getSession().getCorporationId());
    context.setUserId(request.getSession().getToken());
    context.setLoginName(request.getSession().getLoginName());
    context.setUserRoles(UserRoleTool.adaptToRole(request.getSession().getUserRoles()));

    TeamListVo teamListVo = new TeamListVo();
    if (request.getCriteria().getPagination() != null) {
      PaginationDetail detail = new PaginationDetail();
      detail.setLimit(request.getCriteria().getPagination().getLimit());
      detail.setStart(request.getCriteria().getPagination().getStart());

      teamListVo.setPaginationDetail(detail);
    }
    if (request.getCriteria().getKey() != null) teamListVo.setName(request.getCriteria().getKey());

    if (request.getCriteria().getSorting() != null) {
      SortingDetail sortingDetail = new SortingDetail();
      sortingDetail.setSort(request.getCriteria().getSorting().getSort());
      sortingDetail.setDirection(request.getCriteria().getSorting().getDirection());
      teamListVo.setSortingDetail(sortingDetail);
    }

    OrganSearchResult rs = new OrganSearchResult();
    List<OrganicationClient> lt = new ArrayList<OrganicationClient>();

    PageStore<TeamListVo> volist = teamService.teamList(context, teamListVo);
    for (TeamListVo team : volist.getResultList()) {
      OrganicationClient client = new OrganicationClient();
      client.setId(team.getId());
      client.setName(team.getName());
      client.setType(OrganType.GROUP);
      lt.add(client);
    }

    rs.setResult(lt);
    rs.setTotal(volist.getResultCount());
    return new ChooseOrganizationResponse(rs);
  }