Updated code with communication and notification.

This commit is contained in:
piyuskag
2024-10-27 21:33:18 +05:30
59 changed files with 2479 additions and 153 deletions

View File

@@ -0,0 +1,61 @@
package net.gepafin.tendermanagement.service.impl;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.dao.ApplicationAmendmentRequestDao;
import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequest;
import net.gepafin.tendermanagement.model.request.ApplicationAmendmentRequestBean;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentRequestResponse;
import net.gepafin.tendermanagement.service.ApplicationAmendmentRequestService;
import net.gepafin.tendermanagement.util.Validator;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Service
public class ApplicationAmendmentRequestServiceImpl implements ApplicationAmendmentRequestService {
@Autowired
private Validator validator;
@Autowired
private ApplicationAmendmentRequestDao applicationAmendmentRequestDao;
@Override
public List<ApplicationAmendmentRequestResponse> getApplicationDataForAmendment(HttpServletRequest request, Long applicationId) {
UserEntity user= validator.validateUser(request);
return applicationAmendmentRequestDao.getApplicationDataForAmendment(request,applicationId);
}
@Override
public ApplicationAmendmentRequestResponse createApplicationAmendmentRequest(HttpServletRequest request, Long applicationEvaluationId , ApplicationAmendmentRequest applicationAmendmentRequest) {
UserEntity user= validator.validateUser(request);
return applicationAmendmentRequestDao.createApplicationAmendmentRequest(applicationEvaluationId,applicationAmendmentRequest);
}
@Override
public void deleteApplicationAmendmentRequest(HttpServletRequest request, Long id) {
applicationAmendmentRequestDao.deleteById(id);
}
@Override
public ApplicationAmendmentRequestResponse getApplicationAmendmentRequestById(HttpServletRequest request,Long id) {
return applicationAmendmentRequestDao.getApplicationAmendmentRequestById(id);
}
@Override
public List<ApplicationAmendmentRequestResponse> getAllApplicationAmendmentRequest(HttpServletRequest request) {
return applicationAmendmentRequestDao.getAllApplicationAmendmentRequest();
}
@Override
public ApplicationAmendmentRequestResponse updateApplicationAmendment(HttpServletRequest request, Long id, ApplicationAmendmentRequestBean applicationAmendmentRequestBean) {
UserEntity updatedByUser= validator.validateUser(request);
return applicationAmendmentRequestDao.updateApplicationAmendment(id,applicationAmendmentRequestBean);
}
}

View File

@@ -0,0 +1,87 @@
package net.gepafin.tendermanagement.service.impl;
import jakarta.servlet.http.HttpServletRequest;
import net.gepafin.tendermanagement.config.Translator;
import net.gepafin.tendermanagement.constants.GepafinConstant;
import net.gepafin.tendermanagement.dao.ApplicationEvaluationDao;
import net.gepafin.tendermanagement.entities.AssignedApplicationsEntity;
import net.gepafin.tendermanagement.entities.UserEntity;
import net.gepafin.tendermanagement.enums.ApplicationEvaluationStatusTypeEnum;
import net.gepafin.tendermanagement.enums.ApplicationStatusTypeEnum;
import net.gepafin.tendermanagement.model.request.ApplicationEvaluationRequest;
import net.gepafin.tendermanagement.model.request.UpdateApplicationEvaluationRequest;
import net.gepafin.tendermanagement.model.response.ApplicationEvaluationResponse;
import net.gepafin.tendermanagement.model.response.ApplicationResponse;
import net.gepafin.tendermanagement.repositories.AssignedApplicationsRepository;
import net.gepafin.tendermanagement.service.ApplicationEvaluationService;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Optional;
@Service
public class ApplicationEvaluationServiceImpl implements ApplicationEvaluationService {
@Autowired
private ApplicationEvaluationDao applicationEvaluationDao;
@Autowired
private Validator validator;
@Autowired
private AssignedApplicationsRepository assignedApplicationsRepository;
@Override
@Transactional(rollbackFor = Exception.class)
public ApplicationEvaluationResponse createOrUpdateApplicationEvaluation(HttpServletRequest request, ApplicationEvaluationRequest req,Long assignedApplicationsId) {
AssignedApplicationsEntity assignedApplication = assignedApplicationsRepository.findByIdAndIsDeletedFalse(assignedApplicationsId).orElseThrow(()->
new ResourceNotFoundException(Status.NOT_FOUND,Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_MSG)));
UserEntity user=validator.validatePreInstructor(request,assignedApplication.getUserId());
return applicationEvaluationDao.createOrUpdateApplicationEvaluation(user,req,assignedApplication.getApplication().getId());
}
@Override
@Transactional(readOnly = true)
public ApplicationEvaluationResponse getApplicationEvaluationByApplicationId(
HttpServletRequest request, Long applicationId, Long assignedApplicationId) {
Optional<AssignedApplicationsEntity> assignedApplicationsOptional =
assignedApplicationsRepository.findByApplicationIdOrId(applicationId, assignedApplicationId);
AssignedApplicationsEntity assignedApplications = assignedApplicationsOptional
.orElseThrow(() -> new CustomValidationException(
Status.BAD_REQUEST,
Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_WITH_ID_MSG)
));
UserEntity user = validator.validatePreInstructor(request, assignedApplications.getUserId());
return applicationEvaluationDao.getApplicationEvaluationByApplicationId(
user,
assignedApplications.getApplication().getId(),
assignedApplications.getId()
);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteApplicationEvaluation(HttpServletRequest request,Long id) {
validator.getUserIdFromToken(request);
applicationEvaluationDao.deleteById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public ApplicationEvaluationResponse updateApplicationEvaluationStatus(HttpServletRequest request, Long applicationId, ApplicationEvaluationStatusTypeEnum status) {
AssignedApplicationsEntity assignedApplications = assignedApplicationsRepository.findByApplicationIdAndIsDeletedFalse(applicationId).orElse(null);
if(assignedApplications==null){
throw new CustomValidationException(Status.BAD_REQUEST, Translator.toLocale(GepafinConstant.ASSIGNED_APPLICATION_NOT_FOUND_WITH_ID_MSG));
}
validator.validatePreInstructor(request, assignedApplications.getUserId());
return applicationEvaluationDao.updateApplicationEvaluationStatus(applicationId, status);
}
}

View File

@@ -56,8 +56,8 @@ public class ApplicationServiceImpl implements ApplicationService {
}
@Override
public ApplicationEntity validateApplication(Long id) {
return applicationDao.validateApplication(id);
public ApplicationEntity validateApplication(Long applicationId) {
return applicationDao.validateApplication(applicationId);
}
@Override

View File

@@ -1,36 +0,0 @@
package net.gepafin.tendermanagement.service.impl;
import net.gepafin.tendermanagement.dao.CommunicationAmendmentDao;
import net.gepafin.tendermanagement.model.request.CommunicationRequestBean;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
import net.gepafin.tendermanagement.service.CommunicationAmendmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class CommunicationAmendmentServiceImpl implements CommunicationAmendmentService {
@Autowired
CommunicationAmendmentDao communicationAmendmentDao;
@Override
public CommunicationResponseBean addCommentToAmendmentRequest(CommunicationRequestBean communicationRequestBean, Long amendmentId) {
return communicationAmendmentDao.addCommentToAmendmentRequest(communicationRequestBean,amendmentId);
}
@Override
public String deleteCommunicationAmendmentComment(Long amendmentId, Long commentId) {
return communicationAmendmentDao.deleteCommunicationAmendmentComment(amendmentId, commentId);
}
@Override
public CommunicationResponseBean updateCommunicationAmendment(CommunicationRequestBean communicationRequestBean, Long amendmentId, Long commentId) {
return communicationAmendmentDao.updateCommunicationAmendment(communicationRequestBean, amendmentId, commentId);
}
@Override
public ApplicationAmendmentResponse getAmendmentComments(Long id) {
return communicationAmendmentDao.getAmendmentComments(id);
}
}

View File

@@ -0,0 +1,37 @@
package net.gepafin.tendermanagement.service.impl;
import net.gepafin.tendermanagement.dao.CommunicationDao;
import net.gepafin.tendermanagement.model.request.CommunicationRequestBean;
import net.gepafin.tendermanagement.model.response.ApplicationAmendmentResponse;
import net.gepafin.tendermanagement.model.response.CommunicationResponseBean;
import net.gepafin.tendermanagement.service.CommunicationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class CommunicationServiceImpl implements CommunicationService {
@Autowired
CommunicationDao communicationDao;
@Override
public CommunicationResponseBean addCommentToAmendmentRequest(CommunicationRequestBean communicationRequestBean, Long amendmentId) {
return communicationDao.addCommentToAmendmentRequest(communicationRequestBean, amendmentId);
}
@Override
public String deleteComment(Long amendmentId, Long commentId) {
return communicationDao.deleteComment(amendmentId, commentId);
}
@Override
public CommunicationResponseBean updateAmendmentComment(CommunicationRequestBean communicationRequestBean, Long amendmentId, Long commentId) {
return communicationDao.updateAmendmentComment(communicationRequestBean, amendmentId, commentId);
}
@Override
public ApplicationAmendmentResponse getAmendmentComments(Long id) {
return communicationDao.getAmendmentComments(id);
}
}