Updated status filter in get all application api

This commit is contained in:
rajesh
2024-11-07 16:06:50 +05:30
parent d550f97ea8
commit 647b41b231
5 changed files with 14 additions and 11 deletions

View File

@@ -294,11 +294,11 @@ public class ApplicationDao {
// return applicationResponses; // return applicationResponses;
// } // }
public List<ApplicationResponse> getAllApplications(UserEntity userEntity, Long callId, Long companyId,String status) { public List<ApplicationResponse> getAllApplications(UserEntity userEntity, Long callId, Long companyId,List<ApplicationStatusTypeEnum> statusList) {
log.info("Fetching applications for RoleType: {}", userEntity.getRoleEntity().getRoleType()); log.info("Fetching applications for RoleType: {}", userEntity.getRoleEntity().getRoleType());
Specification<ApplicationEntity> spec = search(userEntity, callId, companyId,status); Specification<ApplicationEntity> spec = search(userEntity, callId, companyId,statusList);
List<ApplicationEntity> applicationEntities = applicationRepository.findAll(spec); List<ApplicationEntity> applicationEntities = applicationRepository.findAll(spec);
@@ -308,7 +308,7 @@ public class ApplicationDao {
} }
private Specification<ApplicationEntity> search(UserEntity userEntity, Long callId, Long companyId,String status) { private Specification<ApplicationEntity> search(UserEntity userEntity, Long callId, Long companyId,List<ApplicationStatusTypeEnum> statusList) {
return (root, query, builder) -> { return (root, query, builder) -> {
Boolean isBeneficiary = validator.checkIsBeneficiary(); Boolean isBeneficiary = validator.checkIsBeneficiary();
Predicate predicate = builder.isFalse(root.get("isDeleted")); Predicate predicate = builder.isFalse(root.get("isDeleted"));
@@ -321,8 +321,11 @@ public class ApplicationDao {
if (companyId != null) { if (companyId != null) {
predicate = builder.and(predicate, builder.equal(root.get("company").get("id"), companyId)); predicate = builder.and(predicate, builder.equal(root.get("company").get("id"), companyId));
} }
if (status != null) { if (statusList != null && !statusList.isEmpty()) {
predicate = builder.and(predicate, builder.equal(root.get("status"), status)); List<String> statusNames = statusList.stream()
.map(Enum::name)
.collect(Collectors.toList());
predicate = builder.and(predicate, root.get("status").in(statusNames));
} }
predicate = builder.and(predicate, builder.equal(root.get("hubId"), userEntity.getHub().getId())); predicate = builder.and(predicate, builder.equal(root.get("hubId"), userEntity.getHub().getId()));
return predicate; return predicate;

View File

@@ -22,7 +22,7 @@ public interface ApplicationService {
ApplicationGetResponseBean getApplicationByFormId(HttpServletRequest request, Long applicationId,Long formId); ApplicationGetResponseBean getApplicationByFormId(HttpServletRequest request, Long applicationId,Long formId);
List<ApplicationResponse> getAllApplications(HttpServletRequest request,Long callId, Long companyId,String status); List<ApplicationResponse> getAllApplications(HttpServletRequest request,Long callId, Long companyId,List<ApplicationStatusTypeEnum> statusList);
void deleteApplication(HttpServletRequest request, Long applicationId); void deleteApplication(HttpServletRequest request, Long applicationId);

View File

@@ -86,12 +86,12 @@ public class ApplicationServiceImpl implements ApplicationService {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public List<ApplicationResponse> getAllApplications(HttpServletRequest request, Long callId, Long companyId , String status) { public List<ApplicationResponse> getAllApplications(HttpServletRequest request, Long callId, Long companyId ,List<ApplicationStatusTypeEnum> statusList) {
UserEntity userEntity = validator.validateUser(request); UserEntity userEntity = validator.validateUser(request);
if (companyId != null) { if (companyId != null) {
validator.validateUserWithCompany(request, companyId); validator.validateUserWithCompany(request, companyId);
} }
return applicationDao.getAllApplications(userEntity, callId, companyId , status); return applicationDao.getAllApplications(userEntity, callId, companyId , statusList);
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)

View File

@@ -72,7 +72,7 @@ public interface ApplicationApi {
ResponseEntity<Response<List<ApplicationResponse>>> getAllApplications(HttpServletRequest request, ResponseEntity<Response<List<ApplicationResponse>>> getAllApplications(HttpServletRequest request,
@Parameter(description = "The call id", required = false) @RequestParam(value = "callId", required = false) Long callId, @Parameter(description = "The call id", required = false) @RequestParam(value = "callId", required = false) Long callId,
@Parameter(description = "The company id", required = false) @RequestParam(value = "companyId", required = false) Long companyId, @Parameter(description = "The company id", required = false) @RequestParam(value = "companyId", required = false) Long companyId,
@Parameter(description = "Application status" ,required = false) @RequestParam(value = "status",required = false)String status); @Parameter(description = "Application status" ,required = false) @RequestParam(value = "status",required = false) List<ApplicationStatusTypeEnum> statusList);
@Operation(summary = "Api to delete application", @Operation(summary = "Api to delete application",
responses = { responses = {

View File

@@ -76,8 +76,8 @@ public class ApplicationApiController implements ApplicationApi {
} }
@Override @Override
public ResponseEntity<Response<List<ApplicationResponse>>> getAllApplications(HttpServletRequest request, Long callId, Long companyId, String status) { public ResponseEntity<Response<List<ApplicationResponse>>> getAllApplications(HttpServletRequest request, Long callId, Long companyId, List<ApplicationStatusTypeEnum> statusList) {
List<ApplicationResponse> applications = applicationService.getAllApplications(request, callId, companyId,status); List<ApplicationResponse> applications = applicationService.getAllApplications(request, callId, companyId,statusList);
log.info("Get All Applications"); log.info("Get All Applications");
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(applications, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG))); .body(new Response<>(applications, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));