Added validation in amendment and change email content

This commit is contained in:
harish
2024-11-05 18:47:43 +05:30
parent dbf1a8735d
commit 472237246c
6 changed files with 87 additions and 16 deletions

View File

@@ -39,60 +39,105 @@ public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendm
@Override
public ApplicationAmendmentRequestResponse getApplicationDataForAmendment(HttpServletRequest request, Long applicationEvaluationId) {
UserEntity user= validator.validateUser(request);
return applicationAmendmentRequestDao.getApplicationDataForAmendment(request,applicationEvaluationId);
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(applicationEvaluationId);
entityOptional.ifPresent(applicationEvaluationEntity -> validator.validatePreInstructor(request, applicationEvaluationEntity.getUserId()));
return applicationAmendmentRequestDao.getApplicationDataForAmendment(applicationEvaluationId);
}
@Override
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , ApplicationAmendmentRequest applicationAmendmentRequest) {
UserEntity user= validator.validateUser(request);
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(applicationEvaluationId);
entityOptional.ifPresent(applicationEvaluationEntity -> validator.validatePreInstructor(request, applicationEvaluationEntity.getUserId()));
return applicationAmendmentRequestDao.createApplicationAmendmentRequest(applicationEvaluationId,applicationAmendmentRequest);
}
@Override
public void deleteApplicationAmendmentRequest(HttpServletRequest request, Long id) {
applicationAmendmentRequestDao.deleteById(id);
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(amendment.getApplicationEvaluationEntity().getId());
if (entityOptional.isPresent()) {
UserEntity user = validator.validatePreInstructor(request, entityOptional.get().getUserId());
applicationAmendmentRequestDao.deleteById(id);
}
}
@Override
public ApplicationAmendmentRequestResponse getApplicationAmendmentRequestById(HttpServletRequest request,Long id) {
return applicationAmendmentRequestDao.getApplicationAmendmentRequestById(id);
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(amendment.getApplicationEvaluationEntity().getId());
if (entityOptional.isPresent()) {
UserEntity user = validator.validatePreInstructor(request, entityOptional.get().getUserId());
}
return applicationAmendmentRequestDao.getApplicationAmendmentRequestById(id);
}
@Override
public List<ApplicationAmendmentRequestResponse> getAllApplicationAmendmentRequest(HttpServletRequest request,Long userId) {
UserEntity user = validator.validatePreInstructor(request, userId);
return applicationAmendmentRequestDao.getAllApplicationAmendmentRequest(request,userId);
}
@Override
public ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean) {
UserEntity updatedByUser= validator.validateUser(request);
return applicationAmendmentRequestDao.updateApplicationAmendment(id,applicationAmendmentRequestBean);
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(amendment.getApplicationEvaluationEntity().getId());
if (entityOptional.isPresent()) {
UserEntity user = validator.validatePreInstructor(request, entityOptional.get().getUserId());
}
return applicationAmendmentRequestDao.updateApplicationAmendment(id,applicationAmendmentRequestBean);
}
@Override
public ApplicationAmendmentRequestEntity validateApplicationAmendmentRequest(Long applicationAmendmentId) {
return applicationAmendmentRequestDao.validateApplicationAmendmentRequest(applicationAmendmentId);
}
@Override
public List<ApplicationAmendmentRequestResponse> getAllAmendmentRequestByBeneficiaryId(HttpServletRequest request, Long beneficiaryId) {
UserEntity user= validator.validateUser(request);
return applicationAmendmentRequestDao.getAllAmendmentRequestByBeneficiaryId(beneficiaryId);
}
@Override
public ApplicationAmendmentRequestResponse closeAmendmentRequest(HttpServletRequest request, Long id, CloseAmendmentRequest closeAmendmentRequest) {
return applicationAmendmentRequestDao.closeAmendmentRequest(id,closeAmendmentRequest);
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByIdAndIsDeletedFalse(id)
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
Translator.toLocale(GepafinConstant.APPLICATION_AMENDMENT_NOT_FOUND_MSG)));
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(amendment.getApplicationEvaluationEntity().getId());
if (entityOptional.isPresent()) {
UserEntity user = validator.validatePreInstructor(request, entityOptional.get().getUserId());
}
return applicationAmendmentRequestDao.closeAmendmentRequest(id,closeAmendmentRequest);
}
@Override
public ApplicationAmendmentRequestResponse extendResponseDays(HttpServletRequest request, Long id, Long addedDays) {
return applicationAmendmentRequestDao.extendResponseDays(id, addedDays);
UserEntity user= validator.validateUser(request);
return applicationAmendmentRequestDao.extendResponseDays(id, addedDays);
}
public ApplicationAmendmentRequestResponse getAmendmentByApplicationId(HttpServletRequest request, Long applicationId) {
UserEntity user= validator.validateUser(request);
return applicationAmendmentRequestDao.getAmendmentByApplicationId(request,applicationId);
ApplicationAmendmentRequestEntity amendment = applicationAmendmentRequestRepository.findByApplicationIdAndIsDeletedFalse(applicationId);
if(amendment!=null) {
Optional<ApplicationEvaluationEntity> entityOptional = applicationEvaluationRepository.findByIdAndIsDeletedFalse(amendment.getApplicationEvaluationEntity().getId());
if (entityOptional.isPresent()) {
UserEntity user = validator.validatePreInstructor(request, entityOptional.get().getUserId());
}}
return applicationAmendmentRequestDao.getAmendmentByApplicationId(request,applicationId);
}
@Override
public ApplicationAmendmentRequestResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationAmendmentRequestEnum status) {