Preferred call changes
This commit is contained in:
@@ -425,10 +425,22 @@ public class CallDao {
|
||||
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||
}
|
||||
|
||||
public CallResponse getCallById(CallEntity callEntity) {
|
||||
return getCallResponseBean(callEntity);
|
||||
public CallResponse getCallById(UserEntity user, CallEntity callEntity) {
|
||||
Long userId = user.getId();
|
||||
Long callId = callEntity.getId();
|
||||
|
||||
BeneficiaryPreferredCallEntity preferredCall = beneficiaryPreferredCallRepository
|
||||
.findByUserIdAndCallIdInAndIsDeletedFalse(userId, List.of(callId))
|
||||
.stream()
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
CallResponse callResponse = getCallResponseBean(callEntity);
|
||||
callResponse.setPreferredCallId(preferredCall != null ? preferredCall.getId() : null);
|
||||
|
||||
return callResponse;
|
||||
}
|
||||
|
||||
|
||||
public CallResponse createCallStep2(CallEntity callEntity, CreateCallRequestStep2 createCallRequest, UserEntity user) {
|
||||
validateUpdate(callEntity);
|
||||
setIfUpdated(callEntity::getThreshold, callEntity::setThreshold, createCallRequest.getThreshold());
|
||||
@@ -648,6 +660,7 @@ public class CallDao {
|
||||
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<Long> callIds = calls.stream().map(CallEntity::getId).collect(Collectors.toList());
|
||||
|
||||
@@ -657,16 +670,19 @@ public class CallDao {
|
||||
.map(call -> {
|
||||
CallDetailsResponseBean responseBean = convertToCallDetailsResponseBean(call);
|
||||
String key = user.getId() + "_" + call.getId();
|
||||
boolean isPreferred = preferredCallsMap.containsKey(key);
|
||||
responseBean.setPreferred(isPreferred);
|
||||
|
||||
BeneficiaryPreferredCallEntity preferredCall = preferredCallsMap.get(key);
|
||||
Long preferredId = (preferredCall != null && !preferredCall.getIsDeleted()) ? preferredCall.getId() : null;
|
||||
responseBean.setPreferredCallId(preferredId);
|
||||
|
||||
return responseBean;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
public Map<String, BeneficiaryPreferredCallEntity> getBeneficiaryPreferredCallsForUser(UserEntity user, List<Long> callIds) {
|
||||
|
||||
public Map<String, BeneficiaryPreferredCallEntity> getBeneficiaryPreferredCallsForUser(UserEntity user, List<Long> callIds) {
|
||||
List<BeneficiaryPreferredCallEntity> beneficiaryPreferredCalls = beneficiaryPreferredCallRepository
|
||||
.findByUserIdAndCallIdIn(user.getId(), callIds);
|
||||
.findByUserIdAndCallIdInAndIsDeletedFalse(user.getId(), callIds);
|
||||
|
||||
return beneficiaryPreferredCalls.stream()
|
||||
.collect(Collectors.toMap(
|
||||
|
||||
Reference in New Issue
Block a user