Done ticket GEPAFINBE-150

This commit is contained in:
Piyush
2025-01-27 19:11:16 +05:30
parent 9d8757b384
commit 15bf2e4d4a
5 changed files with 24 additions and 9 deletions

View File

@@ -226,7 +226,7 @@ public class AssignedApplicationsDao {
log.info("Assigned Application deleted with ID: {}", id);
}
public List<AssignedApplicationsResponse> getAllAssignedApplications(HttpServletRequest request, Long userId) {
public List<AssignedApplicationsResponse> getAllAssignedApplications(HttpServletRequest request, Long userId,List<AssignedApplicationEnum> statusList) {
UserEntity user = validator.validateUser(request);
if(validator.checkIsPreInstructor() && userId == null) {
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.USER_ID_NOT_NULL_MSG));
@@ -234,18 +234,24 @@ public class AssignedApplicationsDao {
if(userId != null) {
validator.validatePreInstructor(request, userId);
}
Specification<AssignedApplicationsEntity> spec = search(user.getHub().getId() ,userId);
Specification<AssignedApplicationsEntity> spec = search(user.getHub().getId() ,userId,statusList);
List<AssignedApplicationsEntity> assignedApplicationsEntityList = assignedApplicationsRepository.findAll(spec);
return assignedApplicationsEntityList.stream()
.map(entity -> convertEntityToResponse(entity))
.collect(Collectors.toList());
}
private Specification<AssignedApplicationsEntity> search(Long hubId, Long userId) {
private Specification<AssignedApplicationsEntity> search(Long hubId, Long userId,List<AssignedApplicationEnum> statusList) {
return (root, query, builder) -> {
Predicate predicate = builder.isFalse(root.get("isDeleted"));
if (userId != null) {
predicate = builder.and(predicate, builder.equal(root.get("userId"), userId));
}
if (statusList != null && !statusList.isEmpty()) {
List<String> statusNames = statusList.stream()
.map(Enum::name)
.collect(Collectors.toList());
predicate = builder.and(predicate, root.get("status").in(statusNames));
}
query.orderBy(
builder.desc(builder.isNotNull(root.get(GepafinConstant.ASSIGNED_AT))),
builder.desc(root.get(GepafinConstant.ASSIGNED_AT))