Resolved conflicts

This commit is contained in:
nisha
2024-11-20 19:11:51 +05:30
9 changed files with 31 additions and 9 deletions

View File

@@ -293,5 +293,7 @@ public class GepafinConstant {
public static final String APPLICATION_DOCUMENTS_NOT_FOUND_MSG = "application.documents.not.found"; public static final String APPLICATION_DOCUMENTS_NOT_FOUND_MSG = "application.documents.not.found";
public static final String DUPLICATE_BENEFICIARY_CALL = "beneficiary.call.duplicate"; public static final String DUPLICATE_BENEFICIARY_CALL = "beneficiary.call.duplicate";
public static final String USER_MUST_BE_ASSOCIATED_WITH_COMPANY="user.must.be.associated.with.company.to.create.application"; public static final String USER_MUST_BE_ASSOCIATED_WITH_COMPANY="user.must.be.associated.with.company.to.create.application";
public static final String COMPANY_ID_REQUIRED_FOR_PREFERRED_CALL = "company.id.required.for.preferred.call";
} }

View File

@@ -656,13 +656,29 @@ public class CallDao {
return createCallResponseBean; 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(); String type = user.getRoleEntity().getRoleType();
List<String> callStatusList = CallStatusEnum.getStatusValues(); List<String> callStatusList = CallStatusEnum.getStatusValues();
if (Boolean.FALSE.equals(ROLE_SUPER_ADMIN.getValue().equals(type))) { if (Boolean.FALSE.equals(ROLE_SUPER_ADMIN.getValue().equals(type))) {
callStatusList = List.of(CallStatusEnum.PUBLISH.getValue()); 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()); List<Long> callIds = calls.stream().map(CallEntity::getId).collect(Collectors.toList());
Map<String, BeneficiaryPreferredCallEntity> preferredCallsMap = Map<String, BeneficiaryPreferredCallEntity> preferredCallsMap =
getBeneficiaryPreferredCallsForUser(request,user, callIds, companyId); getBeneficiaryPreferredCallsForUser(request,user, callIds, companyId);

View File

@@ -45,4 +45,6 @@ public interface CallRepository extends JpaRepository<CallEntity, Long> {
@Query("SELECT COALESCE(SUM(c.amount), 0) FROM CallEntity c WHERE c.status = 'PUBLISH' And c.hub.id = :hubId") @Query("SELECT COALESCE(SUM(c.amount), 0) FROM CallEntity c WHERE c.status = 'PUBLISH' And c.hub.id = :hubId")
BigDecimal findTotalAmountOfPublishedCallsAndHubId(@Param("hubId") Long hubId); BigDecimal findTotalAmountOfPublishedCallsAndHubId(@Param("hubId") Long hubId);
@Query("SELECT c FROM CallEntity c WHERE c.id IN :ids AND c.status IN :status")
List<CallEntity> findByIdInAndStatusIn(@Param("ids") List<Long> ids, @Param("status") List<String> status);
} }

View File

@@ -21,7 +21,7 @@ public interface CallService {
CallResponse getCallById (HttpServletRequest request, Long callId,Long companyId); CallResponse getCallById (HttpServletRequest request, Long callId,Long companyId);
List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,Long companyId); List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,Long companyId,Boolean onlyPreferredCall);
CallResponse validateCallData(HttpServletRequest request, Long callId); CallResponse validateCallData(HttpServletRequest request, Long callId);

View File

@@ -62,9 +62,9 @@ public class CallServiceImpl implements CallService {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,Long companyId) { public List<CallDetailsResponseBean> getAllCalls(HttpServletRequest request,Long companyId,Boolean onlyPreferredCall) {
UserEntity user = validator.validateUser(request); UserEntity user = validator.validateUser(request);
return callDao.getAllCalls(request,user,companyId); return callDao.getAllCalls(request,user,companyId,onlyPreferredCall);
} }

View File

@@ -100,8 +100,8 @@ public interface CallApi {
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) }) @ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
@GetMapping(value = "", @GetMapping(value = "",
produces = { "application/json" }) produces = { "application/json" })
ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls(HttpServletRequest request,@RequestParam(value = "companyId", required = false) Long companyId); ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls(HttpServletRequest request,@RequestParam(value = "companyId", required = false) Long companyId , @RequestParam(value = "onlyPreferredCall", required = false, defaultValue = "false") Boolean onlyPreferredCall);
@Operation(summary = "Api to validate call", @Operation(summary = "Api to validate call",
responses = { responses = {

View File

@@ -67,8 +67,8 @@ public class CallApiController implements CallApi {
@Override @Override
@Transactional(readOnly = true) @Transactional(readOnly = true)
public ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls(HttpServletRequest request,Long companyId) { public ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls(HttpServletRequest request,Long companyId,Boolean onlyPreferredCall) {
List<CallDetailsResponseBean> calls = callService.getAllCalls(request,companyId); List<CallDetailsResponseBean> calls = callService.getAllCalls(request,companyId,onlyPreferredCall);
return ResponseEntity.status(HttpStatus.OK) return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(calls, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_FETCH_SUCCESS_MSG))); .body(new Response<>(calls, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_FETCH_SUCCESS_MSG)));

View File

@@ -309,3 +309,4 @@ DD_MM_YYYY_HH_MM = dd_MM_yyyy HH:mm
application.documents.not.found=No documents found for the application. application.documents.not.found=No documents found for the application.
beneficiary.call.duplicate = A preferred call with this call ID and company ID already exists for this user. beneficiary.call.duplicate = A preferred call with this call ID and company ID already exists for this user.
user.must.be.associated.with.company.to.create.application=You must be associated with a company to apply for this application. user.must.be.associated.with.company.to.create.application=You must be associated with a company to apply for this application.
company.id.required.for.preferred.call=Company ID is required when requesting only preferred calls.

View File

@@ -304,3 +304,4 @@ reminder.email.sent.success.msg=Email di promemoria inviata con successo!
application.documents.not.found=Nessun documento trovato per la domanda. application.documents.not.found=Nessun documento trovato per la domanda.
beneficiary.call.duplicate = Una chiamata preferita con questo ID di chiamata e ID azienda esiste gi<67> per questo utente. beneficiary.call.duplicate = Una chiamata preferita con questo ID di chiamata e ID azienda esiste gi<67> per questo utente.
user.must.be.associated.with.company.to.create.application=Devi essere associato a un'azienda per poter presentare domanda per questa applicazione. user.must.be.associated.with.company.to.create.application=Devi essere associato a un'azienda per poter presentare domanda per questa applicazione.
company.id.required.for.preferred.call=ID azienda obbligatorio quando si richiedono solo chiamate preferite.