Added validation in preferred call

This commit is contained in:
harish
2024-11-13 17:20:30 +05:30
parent c86a4cf91c
commit 2f7ca1b42a
5 changed files with 13 additions and 0 deletions

View File

@@ -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 REMINDER_EMAIL_SENT_SUCCESS_MSG = "reminder.email.sent.success.msg";
public static final String ENCRYPT_INIT_VECTOR = "IG8*(*@&)*#biVVD"; public static final String ENCRYPT_INIT_VECTOR = "IG8*(*@&)*#biVVD";
public static final String ENCRYPT_KEY = "U2VjdXJlRW5jcnlwdEtleQ=="; public static final String ENCRYPT_KEY = "U2VjdXJlRW5jcnlwdEtleQ==";
public static final String DUPLICATE_BENEFICIARY_CALL = "beneficiary.call.duplicate";
} }

View File

@@ -10,6 +10,7 @@ import net.gepafin.tendermanagement.model.request.BeneficiaryPreferredCallReq;
import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean; import net.gepafin.tendermanagement.model.response.BeneficiaryPreferredCallResponseBean;
import net.gepafin.tendermanagement.repositories.BeneficiaryPreferredCallRepository; import net.gepafin.tendermanagement.repositories.BeneficiaryPreferredCallRepository;
import net.gepafin.tendermanagement.util.Validator; 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.ResourceNotFoundException;
import net.gepafin.tendermanagement.web.rest.api.errors.Status; import net.gepafin.tendermanagement.web.rest.api.errors.Status;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -38,6 +39,12 @@ public class BeneficiaryPreferredCallDao {
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); log.info("Creating new beneficiary preferred call with details: {}", request);
validator.validateUserWithCompany(httpServletRequest, request.getCompanyId()); validator.validateUserWithCompany(httpServletRequest, request.getCompanyId());
boolean exists = beneficiaryPreferredCallRepository
.findByUserIdAndCallIdAndCompanyIdAndIsDeletedFalse(user.getId(), request.getCallId(), request.getCompanyId())
.isPresent();
if (exists) {
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.DUPLICATE_BENEFICIARY_CALL));
}
BeneficiaryPreferredCallEntity entity = convertRequestToEntity(request,user); BeneficiaryPreferredCallEntity entity = convertRequestToEntity(request,user);
entity = beneficiaryPreferredCallRepository.save(entity); entity = beneficiaryPreferredCallRepository.save(entity);
log.info("Beneficiary preferred call created with ID: {}", entity.getId()); log.info("Beneficiary preferred call created with ID: {}", entity.getId());
@@ -53,6 +60,7 @@ public class BeneficiaryPreferredCallDao {
entity.setCallId(request.getCallId()); entity.setCallId(request.getCallId());
entity.setUserId(userEntity.getId()); entity.setUserId(userEntity.getId());
entity.setCompanyId(request.getCompanyId()); entity.setCompanyId(request.getCompanyId());
entity.setIsDeleted( false);
return entity; return entity;
} }

View File

@@ -19,4 +19,6 @@ public interface BeneficiaryPreferredCallRepository extends JpaRepository<Benefi
public List<BeneficiaryPreferredCallEntity> findByUserIdAndCallIdInAndIsDeletedFalse(Long userId, List<Long> callIds); public List<BeneficiaryPreferredCallEntity> findByUserIdAndCallIdInAndIsDeletedFalse(Long userId, List<Long> callIds);
Optional<BeneficiaryPreferredCallEntity> findByIdAndIsDeletedFalse(Long id); Optional<BeneficiaryPreferredCallEntity> findByIdAndIsDeletedFalse(Long id);
Optional<BeneficiaryPreferredCallEntity> findByUserIdAndCallIdAndCompanyIdAndIsDeletedFalse(Long userId, Long callId, Long companyId);
} }

View File

@@ -306,3 +306,4 @@ comment.not.associate.with.amendment = Comment Not Associated with Amendment Req
amendment.found.success = Amendment Request Found Successfully. amendment.found.success = Amendment Request Found Successfully.
invalid.amendment.for.comment = Invalid Amendment Request for the Given Comment. invalid.amendment.for.comment = Invalid Amendment Request for the Given Comment.
DD_MM_YYYY_HH_MM = dd_MM_yyyy HH:mm 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.

View File

@@ -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 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. 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! 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.