Done ticket GEPAFINBE-104

This commit is contained in:
rajesh
2024-11-26 19:23:12 +05:30
parent e9ce58a96e
commit 6d2374c3e6
24 changed files with 240 additions and 115 deletions

View File

@@ -95,6 +95,9 @@ public class CallDao {
@Autowired
private Validator validator;
@Autowired
private CompanyService companyService;
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, UserEntity userEntity) {
createCallRequest.setRegionId(userEntity.getRoleEntity().getRegion().getId());
@@ -433,8 +436,9 @@ public class CallDao {
BeneficiaryPreferredCallEntity preferredCall;
if (companyId != null) {
validator.validateUserWithCompany(request, companyId);
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(user.getId(),companyId);
preferredCall = beneficiaryPreferredCallRepository
.findByUserIdAndCallIdAndCompanyIdAndIsDeletedFalse(userId, callId, companyId)
.findByUserIdAndCallIdAndUserWithCompanyIdAndIsDeletedFalse(userId, callId, userWithCompanyEntity.getId())
.orElse(null);
} else {
preferredCall = beneficiaryPreferredCallRepository
@@ -670,8 +674,9 @@ public class CallDao {
if (Boolean.TRUE.equals(onlyPreferredCall)) {
validator.validateUserWithCompany(request, companyId);
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(user.getId(),companyId);
List<BeneficiaryPreferredCallEntity> preferredCalls = beneficiaryPreferredCallRepository
.findByUserIdAndCompanyIdAndIsDeletedFalse(user.getId(), companyId);
.findByUserIdAndUserWithCompanyIdAndIsDeletedFalse(user.getId(), userWithCompanyEntity.getId());
List<Long> preferredCallIds = preferredCalls.stream()
.map(BeneficiaryPreferredCallEntity::getCallId)
.collect(Collectors.toList());
@@ -699,10 +704,11 @@ public class CallDao {
public Map<String, BeneficiaryPreferredCallEntity> getBeneficiaryPreferredCallsForUser(HttpServletRequest request, UserEntity user, List<Long> callIds, Long companyId) {
List<BeneficiaryPreferredCallEntity> beneficiaryPreferredCalls;
if (companyId != null) {
if (companyId != null && Boolean.TRUE.equals(validator.checkIsBeneficiary())) {
validator.validateUserWithCompany(request, companyId);
UserWithCompanyEntity userWithCompanyEntity=companyService.getUserWithCompany(user.getId(),companyId);
beneficiaryPreferredCalls = beneficiaryPreferredCallRepository
.findByUserIdAndCallIdInAndCompanyIdAndIsDeletedFalse(user.getId(), callIds, companyId);
.findByUserIdAndCallIdInAndUserWithCompanyIdAndIsDeletedFalse(user.getId(), callIds, userWithCompanyEntity.getId());
} else {
beneficiaryPreferredCalls = beneficiaryPreferredCallRepository
.findByUserIdAndCallIdInAndIsDeletedFalse(user.getId(), callIds);