}
@RequestMapping(value = "gethealthworkers", method = RequestMethod.GET)
public @ResponseBody CustomHealthWorkerResponse fetchHealthWorkers(@RequestParam("postId") int postId,
@RequestParam("rows") int rows, @RequestParam("page") int page) {
CustomHealthWorkerResponse response = new CustomHealthWorkerResponse();
//HealthPost healthPost = healthPostService.findById(postId);
StringBuilder sb = new StringBuilder();
List<HealthExtensionWorker> healthWorkers = healthPostService.getHealthWorkersForHealthPost(postId, rows, page, sb);
List<HealthWorkerDTO> healthWorkerDTOs = new ArrayList<HealthWorkerDTO>();
for (HealthExtensionWorker healthWorker : healthWorkers) {
HealthWorkerDTO hDTO = new HealthWorkerDTO();
hDTO.setWorkerId(healthWorker.getWorkerId());
hDTO.setFullName(healthWorker.getFullName());
hDTO.setPhoneNumber(healthWorker.getPhoneNumber());
hDTO.setPostId(postId);
hDTO.setSex(healthWorker.getSex());
healthWorkerDTOs.add(hDTO);
}
response.setPage(String.valueOf(page));
response.setRows(healthWorkerDTOs);
response.setTotal(sb.toString());
response.setRecords(String.valueOf(healthWorkerDTOs.size()));
return response;
}