Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #850 from egovernments/hrms-user
Browse files Browse the repository at this point in the history
addded user call in plainsearch
  • Loading branch information
pradeepkumarcm-egov authored Jul 8, 2024
2 parents 7968a86 + 8234d7d commit 2719d6a
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ public EmployeeResponse search(EmployeeSearchCriteria criteria, RequestInfo requ
* @param criteria
* @return
*/
public List<Employee> plainsearch(EmployeePlainSearchCriteria criteria) {
public List<Employee> plainsearch(EmployeePlainSearchCriteria criteria,RequestInfo requestInfo) {
if (criteria.getLimit() != null && criteria.getLimit() > propertiesManager.getHrmsMaxLimit())
criteria.setLimit(propertiesManager.getHrmsMaxLimit());

Expand All @@ -233,12 +233,31 @@ public List<Employee> plainsearch(EmployeePlainSearchCriteria criteria) {
else
employeeIds = criteria.getUuids();

EmployeePlainSearchCriteria employeePlainSearchCriteria = EmployeePlainSearchCriteria.builder().uuids(employeeIds).build();
List<Employee> employees=repository.fetchPlainSearchEmployees(employeePlainSearchCriteria);

Map<String, User> mapOfUsers = new HashMap<String, User>();

if(!CollectionUtils.isEmpty(employeeIds)){
Map<String, Object> UserSearchCriteria = new HashMap<>();
UserSearchCriteria.put(HRMSConstants.HRMS_USER_SEARCH_CRITERA_UUID,employeeIds);
if(mapOfUsers.isEmpty()){
UserResponse userResponse = userService.getUser(requestInfo, UserSearchCriteria);
if(!CollectionUtils.isEmpty(userResponse.getUser())) {
mapOfUsers = userResponse.getUser().stream()
.collect(Collectors.toMap(User :: getUuid, Function.identity()));
}
}
for(Employee employee: employees){
employee.setUser(mapOfUsers.get(employee.getUuid()));
}
}

if(employeeIds.isEmpty())
return Collections.emptyList();

EmployeePlainSearchCriteria employeePlainSearchCriteria = EmployeePlainSearchCriteria.builder().uuids(employeeIds).build();
return repository.fetchPlainSearchEmployees(employeePlainSearchCriteria);

return employees;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,10 @@ private ResponseEntity<?> countV1(@RequestParam("tenantId") String tenantId, @Re

@PostMapping("/_plainsearch")
@ResponseBody
private ResponseEntity<?> plainsearch(@RequestBody @Valid RequestInfoWrapper requestInfoWrapper, @ModelAttribute @Valid EmployeePlainSearchCriteria criteria) {
private ResponseEntity<?> plainsearch(@RequestBody @Valid RequestInfoWrapper requestInfoWrapper, @ModelAttribute @Valid EmployeePlainSearchCriteria criteria,@RequestBody RequestInfo requestInfo) {

EmployeeResponse employeeResponse = EmployeeResponse.builder().responseInfo(factory.createResponseInfoFromRequestInfo(requestInfoWrapper.getRequestInfo(), true))
.employees(employeeService.plainsearch(criteria)).build();
.employees(employeeService.plainsearch(criteria,requestInfo)).build();
return new ResponseEntity<>(employeeResponse,HttpStatus.OK);
}

Expand Down

0 comments on commit 2719d6a

Please sign in to comment.