Merge pull request #91 from Kitzanos/fixed-preferred-call-issue
Added validation in preferred call
This commit is contained in:
@@ -290,5 +290,6 @@ public class GepafinConstant {
|
||||
public static final String REMINDER_EMAIL_SENT_SUCCESS_MSG = "reminder.email.sent.success.msg";
|
||||
public static final String ENCRYPT_INIT_VECTOR = "IG8*(*@&)*#biVVD";
|
||||
public static final String ENCRYPT_KEY = "U2VjdXJlRW5jcnlwdEtleQ==";
|
||||
public static final String DUPLICATE_BENEFICIARY_CALL = "beneficiary.call.duplicate";
|
||||
}
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
|
||||
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
|
||||
import net.gepafin.tendermanagement.repositories.BeneficiaryPreferredCallRepository;
|
||||
import net.gepafin.tendermanagement.util.Validator;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.slf4j.Logger;
|
||||
@@ -20,6 +21,7 @@ import org.springframework.stereotype.Component;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -35,10 +37,19 @@ public class BeneficiaryPreferredCallDao {
|
||||
private Validator validator;
|
||||
|
||||
|
||||
public BeneficiaryPreferredCallResponseBean createBeneficiaryPreferredCall(HttpServletRequest httpServletRequest, BeneficiaryPreferredCallReq request,UserEntity user) {
|
||||
public BeneficiaryPreferredCallResponseBean createBeneficiaryPreferredCall(HttpServletRequest httpServletRequest, BeneficiaryPreferredCallReq request, UserEntity user) {
|
||||
log.info("Creating new beneficiary preferred call with details: {}", request);
|
||||
validator.validateUserWithCompany(httpServletRequest, request.getCompanyId());
|
||||
BeneficiaryPreferredCallEntity entity = convertRequestToEntity(request,user);
|
||||
|
||||
Optional<BeneficiaryPreferredCallEntity> existingCall = beneficiaryPreferredCallRepository
|
||||
.findByUserIdAndCallIdAndCompanyIdAndIsDeletedFalse(user.getId(), request.getCallId(), request.getCompanyId());
|
||||
|
||||
if (existingCall.isPresent()) {
|
||||
log.warn("Duplicate beneficiary preferred call detected: {}", existingCall.get());
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.DUPLICATE_BENEFICIARY_CALL));
|
||||
}
|
||||
|
||||
BeneficiaryPreferredCallEntity entity = convertRequestToEntity(request, user);
|
||||
entity = beneficiaryPreferredCallRepository.save(entity);
|
||||
log.info("Beneficiary preferred call created with ID: {}", entity.getId());
|
||||
return convertEntityToResponse(entity);
|
||||
@@ -53,6 +64,7 @@ public class BeneficiaryPreferredCallDao {
|
||||
entity.setCallId(request.getCallId());
|
||||
entity.setUserId(userEntity.getId());
|
||||
entity.setCompanyId(request.getCompanyId());
|
||||
entity.setIsDeleted( false);
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,4 +19,6 @@ public interface BeneficiaryPreferredCallRepository extends JpaRepository<Benefi
|
||||
public List<BeneficiaryPreferredCallEntity> findByUserIdAndCallIdInAndIsDeletedFalse(Long userId, List<Long> callIds);
|
||||
|
||||
Optional<BeneficiaryPreferredCallEntity> findByIdAndIsDeletedFalse(Long id);
|
||||
Optional<BeneficiaryPreferredCallEntity> findByUserIdAndCallIdAndCompanyIdAndIsDeletedFalse(Long userId, Long callId, Long companyId);
|
||||
|
||||
}
|
||||
|
||||
@@ -306,3 +306,4 @@ comment.not.associate.with.amendment = Comment Not Associated with Amendment Req
|
||||
amendment.found.success = Amendment Request Found Successfully.
|
||||
invalid.amendment.for.comment = Invalid Amendment Request for the Given Comment.
|
||||
DD_MM_YYYY_HH_MM = dd_MM_yyyy HH:mm
|
||||
beneficiary.call.duplicate = A preferred call with this call ID and company ID already exists for this user.
|
||||
@@ -301,3 +301,4 @@ DD_MM_YYYY_HH_MM = dd_MM_yyyy HH:mm
|
||||
create.application.data.amendment.msg =Emendamento alla domanda inviato con successo
|
||||
beneficiary.email.not.found.msg=L'indirizzo email per il beneficiario non è stato trovato. Si prega di assicurarsi che il beneficiario abbia un indirizzo email valido.
|
||||
reminder.email.sent.success.msg=Email di promemoria inviata con successo!
|
||||
beneficiary.call.duplicate = Una chiamata preferita con questo ID di chiamata e ID azienda esiste già per questo utente.
|
||||
Reference in New Issue
Block a user