Resolved conflicts for GEPAFINBE-31.

This commit is contained in:
piyushkag
2024-11-25 19:10:24 +05:30
61 changed files with 1473 additions and 601 deletions

View File

@@ -721,13 +721,29 @@ public class CallDao {
return createCallResponseBean;
}
public List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,UserEntity user, Long companyId) {
public List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,UserEntity user, Long companyId,Boolean onlyPreferredCall) {
String type = user.getRoleEntity().getRoleType();
List<String> callStatusList = CallStatusEnum.getStatusValues();
if (Boolean.FALSE.equals(ROLE_SUPER_ADMIN.getValue().equals(type))) {
callStatusList = List.of(CallStatusEnum.PUBLISH.getValue());
}
List<CallEntity> calls = callRepository.findByStatusInAndHubId(callStatusList, user.getHub().getId());
List<CallEntity> calls;
if (Boolean.TRUE.equals(onlyPreferredCall) && companyId == null) {
throw new CustomValidationException(Status.VALIDATION_ERROR,
Translator.toLocale(GepafinConstant.COMPANY_ID_REQUIRED_FOR_PREFERRED_CALL));
}
if (Boolean.TRUE.equals(onlyPreferredCall)) {
validator.validateUserWithCompany(request, companyId);
List<BeneficiaryPreferredCallEntity> preferredCalls = beneficiaryPreferredCallRepository
.findByUserIdAndCompanyIdAndIsDeletedFalse(user.getId(), companyId);
List<Long> preferredCallIds = preferredCalls.stream()
.map(BeneficiaryPreferredCallEntity::getCallId)
.collect(Collectors.toList());
calls = callRepository.findByIdInAndStatusIn(preferredCallIds, callStatusList);
} else {
calls = callRepository.findByStatusInAndHubId(callStatusList, user.getHub().getId());
}
List<Long> callIds = calls.stream().map(CallEntity::getId).collect(Collectors.toList());
Map<String, BeneficiaryPreferredCallEntity> preferredCallsMap =
getBeneficiaryPreferredCallsForUser(request,user, callIds, companyId);