Merge pull request #10 from Kitzanos/update-feature/GEPAFINBE-6
Updated Call API's as per discussion
This commit is contained in:
@@ -43,13 +43,18 @@ public class GepafinConstant {
|
||||
public static final String EMAIL_ALREADY_EXISTS = "email.already.exists";
|
||||
public static final String DOCUMENT_ID_NOT_FOUND="document.id.not.found";
|
||||
public static final String INVALID_DATE_MSG = "call.invalid.date";
|
||||
public static final String STEP_1 = "STEP_1";
|
||||
public static final String STEP_2 = "STEP_2";
|
||||
public static final String VALIDATE_REQUEST = "VALIDATE_REQUEST";
|
||||
public static final String CALL_UPDATE_SUCCESSFULLY_MSG = "call.update.successfully";
|
||||
public static final String CALL_NOT_FOUND = "call.not.found";
|
||||
public static final String CALL_FETCH_SUCCESS_MSG = "call.fetch.success";
|
||||
|
||||
public static final String EVALUATION_CRITERIA_NOT_FOUND = "evaluation.criteria.not.found";
|
||||
public static final String EVALUATION_CRITERIA_CREATED_SUCCESSFULLY = "evaluation.criteria.created.successfully";
|
||||
public static final String EVALUATION_CRITERIA_FETCH_SUCCESSFULLY = "evaluation.criteria.fetch.successfully";
|
||||
public static final String EVALUATION_CRITERIA_UPDATED_SUCCESSFULLY = "evaluation.criteria.updated.successfully";
|
||||
public static final String EVALUATION_CRITERIA_DELETED_SUCCESSFULLY = "evaluation.criteria.deleted.successfully";
|
||||
public static final String CALL_NOT_FOUND="call.not.found";
|
||||
public static final String SCORE_NOT_NULL_MSG="score.not.null";
|
||||
public static final String FAQ_NOT_FOUND = "faq.not.found";
|
||||
public static final String FAQ_CREATED_SUCCESSFULLY = "faq.created.successfully";
|
||||
@@ -71,5 +76,8 @@ public class GepafinConstant {
|
||||
public static final String LOGOUT_SUCCESSFUL_MSG = "logout.successful.msg";
|
||||
public static final String SUCCESS_PASSWORD_CHANGED = "success.password.changed";
|
||||
public static final String UPDATE_USER_STATUS_SUCCESS_MSG = "update.user.status.success";
|
||||
public static final String FIELD_NOT_NULL = "field.not.null";
|
||||
public static final String FIELD_NOT_EMPTY = "field.not.empty";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -4,10 +4,11 @@ import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import net.gepafin.tendermanagement.model.response.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -23,18 +24,15 @@ import net.gepafin.tendermanagement.entities.LookUpDataEntity;
|
||||
import net.gepafin.tendermanagement.entities.LookUpDataEntity.LookUpDataTypeEnum;
|
||||
import net.gepafin.tendermanagement.entities.RegionEntity;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.enums.CallTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep1;
|
||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep2;
|
||||
import net.gepafin.tendermanagement.model.request.DocumentReq;
|
||||
import net.gepafin.tendermanagement.model.request.EvaluationCriteriaReq;
|
||||
import net.gepafin.tendermanagement.model.request.FaqReq;
|
||||
import net.gepafin.tendermanagement.model.request.LookUpDataReq;
|
||||
import net.gepafin.tendermanagement.model.response.CreateCallResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.EvaluationCriteriaResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.FaqResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.LookUpDataResponse;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateCallRequestStep1;
|
||||
import net.gepafin.tendermanagement.repositories.CallRepository;
|
||||
import net.gepafin.tendermanagement.repositories.CallTargetAudienceChecklistRepository;
|
||||
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
||||
@@ -42,12 +40,15 @@ import net.gepafin.tendermanagement.repositories.EvaluationCriteriaRepository;
|
||||
import net.gepafin.tendermanagement.repositories.FaqRepository;
|
||||
import net.gepafin.tendermanagement.repositories.LookUpDataRepository;
|
||||
import net.gepafin.tendermanagement.repositories.RegionRepository;
|
||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
import net.gepafin.tendermanagement.service.impl.CallValidatorServiceImpl;
|
||||
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||
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 static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
|
||||
@Component
|
||||
public class CallDao {
|
||||
|
||||
@@ -73,34 +74,36 @@ public class CallDao {
|
||||
private CallTargetAudienceChecklistRepository callTargetAudienceChecklistRepository;
|
||||
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
private UserService userService;
|
||||
|
||||
public CreateCallResponseBean createCallStep1(CreateCallRequestStep1 createCallRequest, Long userId) {
|
||||
CreateCallResponseBean createCallResponseBean = null;
|
||||
public CallResponse createCallStep1(CreateCallRequestStep1 createCallRequest, Long userId) {
|
||||
CallEntity callEntity = convertToCallEntity(createCallRequest);
|
||||
List<FaqEntity> faqEntities = convertToFaqEntities(createCallRequest.getFaq(), callEntity, userId);
|
||||
List<LookUpDataResponse> amiedTo = convertLookUpDataEntities(createCallRequest.getAimedTo(), callEntity,
|
||||
convertToFaqEntities(createCallRequest.getFaq(), callEntity, userId);
|
||||
convertLookUpDataEntities(createCallRequest.getAimedTo(), callEntity,
|
||||
LookUpDataTypeEnum.AIMED_TO);
|
||||
createCallResponseBean = assembleCreateCallResponseBean(callEntity, Collections.emptyList(),
|
||||
Collections.emptyList(), faqEntities, Collections.emptyList());
|
||||
createCallResponseBean.setAimedTo(amiedTo);
|
||||
// createCallResponseBean = assembleCreateCallResponseBean(callEntity, Collections.emptyList(),
|
||||
// Collections.emptyList(), faqEntities, Collections.emptyList());
|
||||
// createCallResponseBean.setAimedTo(amiedTo);
|
||||
// createCallResponseBean.setCurrentStep(GepafinConstant.STEP_1);
|
||||
CallResponse createCallResponseBean = getCallResponseBean(callEntity);
|
||||
createCallResponseBean.setCurrentStep(GepafinConstant.STEP_1);
|
||||
return createCallResponseBean;
|
||||
|
||||
}
|
||||
|
||||
|
||||
public CallEntity convertToCallEntity(CreateCallRequestStep1 createCallRequest) {
|
||||
CallEntity callEntity = new CallEntity();
|
||||
validateCallEntity(createCallRequest);
|
||||
RegionEntity region = regionRepository.findById(createCallRequest.getRegionId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.REGION_NOT_FOUND)));
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.REGION_NOT_FOUND)));
|
||||
callEntity.setRegion(region);
|
||||
callEntity.setName(createCallRequest.getName());
|
||||
callEntity.setDescriptionShort(createCallRequest.getDescriptionShort());
|
||||
callEntity.setDescriptionLong(createCallRequest.getDescriptionLong());
|
||||
callEntity.setStartDate(createCallRequest.getStartDate());
|
||||
callEntity.setEndDate(createCallRequest.getEndDate());
|
||||
callEntity.setStatus(String.valueOf(createCallRequest.getStatus()));
|
||||
callEntity.setStatus(CallStatusEnum.DRAFT.getValue());
|
||||
callEntity.setAmountMax(createCallRequest.getAmountMax());
|
||||
callEntity.setAmount(createCallRequest.getAmountMax());
|
||||
callEntity.setConfidi(false);
|
||||
@@ -112,46 +115,90 @@ public class CallDao {
|
||||
return callEntity;
|
||||
}
|
||||
|
||||
public List<EvaluationCriteriaEntity> convertListOfEvaluationCriteriaReqToEvaluationCriteriaEntities(List<EvaluationCriteriaReq> criteriaReqList, CallEntity callEntity) {
|
||||
List<EvaluationCriteriaEntity> evaluationCriteriaEntities = criteriaReqList.stream().map(req -> convertToEvaluationCriteriaEntity(req, callEntity)).collect(Collectors.toList());
|
||||
public List<EvaluationCriteriaEntity> convertToEvaluationCriteriaEntities(
|
||||
List<EvaluationCriteriaReq> criteriaReqList, CallEntity callEntity, LookUpDataTypeEnum type) {
|
||||
if (criteriaReqList == null) {
|
||||
return null;
|
||||
}
|
||||
List<EvaluationCriteriaEntity> existingCriteria = evaluationCriteriaRepository.findByCallIdAndLookupDataTypeAndIsDeletedFalse(callEntity.getId(), type.getValue());
|
||||
|
||||
List<Long> incomingIds = criteriaReqList.stream().map(EvaluationCriteriaReq::getId)
|
||||
.filter(id -> id != null && id > 0).collect(Collectors.toList());
|
||||
|
||||
existingCriteria.stream().filter(criteria -> !incomingIds.contains(criteria.getId())).forEach(this::softDeleteEvaluationCriteria);
|
||||
|
||||
List<EvaluationCriteriaEntity> evaluationCriteriaEntities = criteriaReqList.stream()
|
||||
.map(req -> convertToEvaluationCriteriaEntity(req, callEntity, type)).collect(Collectors.toList());
|
||||
evaluationCriteriaRepository.saveAll(evaluationCriteriaEntities);
|
||||
return evaluationCriteriaEntities;
|
||||
}
|
||||
|
||||
private EvaluationCriteriaEntity convertToEvaluationCriteriaEntity(EvaluationCriteriaReq criteriaReq, CallEntity callEntity) {
|
||||
EvaluationCriteriaEntity criteriaEntity = new EvaluationCriteriaEntity();
|
||||
validateEvolutionCrieteriaEntity(criteriaReq.getName(),criteriaReq.getScore());
|
||||
criteriaEntity.setName(criteriaReq.getName());
|
||||
criteriaEntity.setDescription(criteriaReq.getValue());
|
||||
criteriaEntity.setScore(criteriaReq.getScore());
|
||||
private void softDeleteEvaluationCriteria(EvaluationCriteriaEntity evaluationCriteriaEntity) {
|
||||
evaluationCriteriaEntity.setIsDeleted(true);
|
||||
evaluationCriteriaRepository.save(evaluationCriteriaEntity);
|
||||
}
|
||||
|
||||
private EvaluationCriteriaEntity convertToEvaluationCriteriaEntity(EvaluationCriteriaReq criteriaReq,
|
||||
CallEntity callEntity, LookUpDataTypeEnum type) {
|
||||
EvaluationCriteriaEntity criteriaEntity = null;
|
||||
LookUpDataEntity lookupDataEntity = convertLookUpDataRequestIntoLookUpDataEntity(criteriaReq, type);
|
||||
if (criteriaReq.getId() == null && criteriaReq.getId().equals(0l)) {
|
||||
criteriaEntity = evaluationCriteriaRepository.findById(criteriaReq.getId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_NOT_FOUND)));
|
||||
} else {
|
||||
criteriaEntity = new EvaluationCriteriaEntity();
|
||||
criteriaEntity.setCall(callEntity);
|
||||
criteriaEntity.setLookupData(lookupDataEntity);
|
||||
criteriaEntity.setIsDeleted(false);
|
||||
}
|
||||
setIfUpdated(criteriaEntity::getScore, criteriaEntity::setScore, criteriaReq.getScore());
|
||||
if (Boolean.FALSE.equals(criteriaEntity.getLookupData().getId().equals(lookupDataEntity.getId()))) {
|
||||
criteriaEntity.setLookupData(lookupDataEntity);
|
||||
}
|
||||
return criteriaEntity;
|
||||
}
|
||||
|
||||
|
||||
public List<DocumentEntity> convertToDocumentEntities(List<DocumentReq> documentReqList, CallEntity callEntity) {
|
||||
List<DocumentEntity> documentEntities = documentReqList.stream().map(req -> convertToDocumentEntity(req, callEntity)).collect(Collectors.toList());
|
||||
public List<DocumentEntity> convertToDocumentEntities(List<DocumentReq> documentReqList, CallEntity callEntity,
|
||||
DocumentTypeEnum documentType) {
|
||||
if (documentReqList == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<DocumentEntity> existingDocuments = documentRepository
|
||||
.findByCallIdAndTypeAndIsDeletedFalse(callEntity.getId(), documentType.getValue());
|
||||
|
||||
List<Long> incomingIds = documentReqList.stream().map(DocumentReq::getId).filter(id -> id != null && id > 0)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
existingDocuments.stream().filter(document -> !incomingIds.contains(document.getId()))
|
||||
.forEach(this::softDeleteDocument);
|
||||
List<DocumentEntity> documentEntities = documentReqList.stream()
|
||||
.map(req -> convertToDocumentEntity(req, callEntity)).collect(Collectors.toList());
|
||||
documentRepository.saveAll(documentEntities);
|
||||
return documentEntities;
|
||||
}
|
||||
|
||||
private void softDeleteDocument(DocumentEntity documentEntity) {
|
||||
documentEntity.setIsDeleted(true);
|
||||
documentRepository.save(documentEntity);
|
||||
}
|
||||
|
||||
private DocumentEntity convertToDocumentEntity(DocumentReq documentReq, CallEntity callEntity) {
|
||||
validateDocumentEntity(documentReq.getId(),documentReq.getFileName());
|
||||
DocumentEntity documentEntity = documentRepository.findById(documentReq.getId())
|
||||
validateDocumentEntity(documentReq.getId());
|
||||
DocumentEntity documentEntity = documentRepository.findByIdAndCallIdAndIsDeletedFalse(documentReq.getId(), callEntity.getId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND)));
|
||||
// if(documentEntity==null){
|
||||
// throw ;
|
||||
// }
|
||||
// documentEntity.setFileName(documentReq.getFileName());
|
||||
// documentEntity.setFilePath(documentReq.getUrl());
|
||||
// documentEntity.setCall(callEntity);
|
||||
return documentEntity;
|
||||
}
|
||||
|
||||
|
||||
public List<FaqEntity> convertToFaqEntities(List<FaqReq> faqReqList, CallEntity callEntity, Long userId) {
|
||||
List<FaqEntity> faqEntities = faqReqList.stream().map(req -> convertToFaqEntity(req, callEntity, userId)).collect(Collectors.toList());
|
||||
if (faqReqList == null) {
|
||||
return null;
|
||||
}
|
||||
List<FaqEntity> faqEntities = faqReqList.stream().map(req -> convertToFaqEntity(req, callEntity, userId))
|
||||
.collect(Collectors.toList());
|
||||
faqRepository.saveAll(faqEntities);
|
||||
return faqEntities;
|
||||
}
|
||||
@@ -159,8 +206,7 @@ public class CallDao {
|
||||
public FaqEntity convertToFaqEntity(FaqReq faqReq, CallEntity callEntity, Long userId) {
|
||||
FaqEntity faqEntity = new FaqEntity();
|
||||
validateFaqEntity(faqReq.getQuestion());
|
||||
UserEntity userEntity= userRepository.findById(userId)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.LOOK_UP_DATA_NOT_VALID_MSG)));
|
||||
UserEntity userEntity = userService.validateUser(userId);
|
||||
faqEntity.setUser(userEntity);
|
||||
faqEntity.setIsVisible(true);
|
||||
if (faqReq.getIsVisible() != null) {
|
||||
@@ -174,54 +220,60 @@ public class CallDao {
|
||||
faqEntity.setResponseShort(faqReq.getResponseShort());
|
||||
faqEntity.setResponse(faqReq.getResponse());
|
||||
faqEntity.setCall(callEntity);
|
||||
faqEntity.setIsDeleted(false);
|
||||
return faqEntity;
|
||||
}
|
||||
|
||||
public void validateFaqEntity(String question) {
|
||||
if (!StringUtils.hasText(question)) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.QUESTION_NOT_EMPTY_MSG));
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.QUESTION_NOT_EMPTY_MSG));
|
||||
}
|
||||
}
|
||||
|
||||
public void validateDocumentEntity(Long documentId,String name) {
|
||||
public void validateDocumentEntity(Long documentId) {
|
||||
if (documentId == null) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.DOCUMENT_ID_NOT_FOUND));
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.DOCUMENT_ID_NOT_FOUND));
|
||||
}
|
||||
}
|
||||
|
||||
// if (!StringUtils.hasText(name)) {
|
||||
// throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.NAME_NOT_EMPTY_MSG));
|
||||
// }
|
||||
}
|
||||
|
||||
public void validateEvolutionCrieteriaEntity(String name,Integer score) {
|
||||
public void validateEvaluationCriteriaEntity(String name) {
|
||||
if (!StringUtils.hasText(name)) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.NAME_NOT_EMPTY_MSG));
|
||||
}
|
||||
if (score == null || score <= 0) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.SCORE_NOT_NULL_MSG));
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.NAME_NOT_EMPTY_MSG));
|
||||
}
|
||||
}
|
||||
|
||||
public void validateCallEntity(CreateCallRequestStep1 createCallRequest) {
|
||||
if (createCallRequest.getRegionId() == null) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.REGION_NOT_FOUND_MSG));
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.REGION_NOT_FOUND_MSG));
|
||||
}
|
||||
|
||||
if (createCallRequest.getAmount().compareTo(BigDecimal.ZERO) <= 0||createCallRequest.getAmountMax().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.AMOUNT_GREATER_THAN_ZERO_MSG));
|
||||
if (createCallRequest.getAmount().compareTo(BigDecimal.ZERO) <= 0
|
||||
|| createCallRequest.getAmountMax().compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.AMOUNT_GREATER_THAN_ZERO_MSG));
|
||||
}
|
||||
if (createCallRequest.getStartDate().toLocalDate().isBefore(LocalDate.now()) || createCallRequest.getEndDate().toLocalDate().isBefore(LocalDate.now())) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_DATE_MSG));
|
||||
if (createCallRequest.getStartDate().toLocalDate().isBefore(LocalDate.now())
|
||||
|| createCallRequest.getEndDate().toLocalDate().isBefore(LocalDate.now()) || createCallRequest
|
||||
.getStartDate().toLocalDate().isAfter(createCallRequest.getEndDate().toLocalDate())) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.INVALID_DATE_MSG));
|
||||
}
|
||||
|
||||
}
|
||||
public CreateCallResponseBean convertToCallResponseBean(CallEntity callEntity) {
|
||||
CreateCallResponseBean createCallResponseBean = new CreateCallResponseBean();
|
||||
|
||||
public CallResponse convertToCallResponseBean(CallEntity callEntity) {
|
||||
CallResponse createCallResponseBean = new CallResponse();
|
||||
createCallResponseBean.setId(callEntity.getId());
|
||||
createCallResponseBean.setName(callEntity.getName());
|
||||
createCallResponseBean.setDates(List.of(callEntity.getStartDate(), callEntity.getEndDate()));
|
||||
createCallResponseBean.setStartDate(callEntity.getStartDate());
|
||||
createCallResponseBean.setEndDate(callEntity.getEndDate());
|
||||
createCallResponseBean.setDescriptionShort(callEntity.getDescriptionShort());
|
||||
createCallResponseBean.setDescriptionLong(callEntity.getDescriptionLong());
|
||||
createCallResponseBean.setStatus(CallTypeEnum.valueOf(callEntity.getStatus()));
|
||||
createCallResponseBean.setStatus(CallStatusEnum.valueOf(callEntity.getStatus()));
|
||||
createCallResponseBean.setRegionId(callEntity.getRegion().getId());
|
||||
createCallResponseBean.setAmount(callEntity.getAmount());
|
||||
createCallResponseBean.setAmountMax(callEntity.getAmountMax());
|
||||
@@ -230,20 +282,24 @@ public class CallDao {
|
||||
createCallResponseBean.setThreshold(callEntity.getThreshold());
|
||||
createCallResponseBean.setDocumentationReqested(callEntity.getDocumentationRequested());
|
||||
createCallResponseBean.setPriorityArea(callEntity.getPriorityArea());
|
||||
createCallResponseBean.setConfidi(callEntity.getConfidi());
|
||||
createCallResponseBean.setCreatedDate(callEntity.getCreatedDate());
|
||||
createCallResponseBean.setUpdatedDate(callEntity.getUpdatedDate());
|
||||
return createCallResponseBean;
|
||||
}
|
||||
|
||||
public EvaluationCriteriaResponseBean convertToEvaluationCriteriaResponseBean(EvaluationCriteriaEntity entity) {
|
||||
EvaluationCriteriaResponseBean responseBean = new EvaluationCriteriaResponseBean();
|
||||
responseBean.setId(entity.getId());
|
||||
responseBean.setName(entity.getName());
|
||||
responseBean.setDescription(entity.getDescription());
|
||||
responseBean.setLookUpDataId(entity.getLookupData().getId());
|
||||
responseBean.setTitle(entity.getLookupData().getTitle());
|
||||
responseBean.setValue(entity.getLookupData().getValue());
|
||||
responseBean.setScore(entity.getScore());
|
||||
responseBean.setCreatedDate(entity.getCreatedDate());
|
||||
responseBean.setUpdatedDate(entity.getUpdatedDate());
|
||||
return responseBean;
|
||||
}
|
||||
|
||||
public DocumentResponseBean convertToDocumentResponseBean(DocumentEntity entity) {
|
||||
DocumentResponseBean responseBean = new DocumentResponseBean();
|
||||
responseBean.setId(entity.getId());
|
||||
@@ -254,6 +310,7 @@ public class CallDao {
|
||||
responseBean.setUpdatedDate(entity.getUpdatedDate());
|
||||
return responseBean;
|
||||
}
|
||||
|
||||
public FaqResponseBean convertToFaqResponseBean(FaqEntity entity) {
|
||||
FaqResponseBean responseBean = new FaqResponseBean();
|
||||
responseBean.setId(entity.getId());
|
||||
@@ -267,114 +324,308 @@ public class CallDao {
|
||||
responseBean.setUpdatedDate(entity.getUpdatedDate());
|
||||
return responseBean;
|
||||
}
|
||||
public CreateCallResponseBean assembleCreateCallResponseBean(
|
||||
CallEntity callEntity,
|
||||
List<EvaluationCriteriaEntity> evaluationCriteriaEntities,
|
||||
List<DocumentEntity> documentEntities,
|
||||
|
||||
public CallResponse assembleCreateCallResponseBean(CallEntity callEntity,
|
||||
List<EvaluationCriteriaEntity> evaluationCriteriaEntities, List<DocumentEntity> documentEntities,
|
||||
List<FaqEntity> faqEntities, List<DocumentEntity> images) {
|
||||
|
||||
CreateCallResponseBean callResponseBean = convertToCallResponseBean(callEntity);
|
||||
CallResponse callResponseBean = convertToCallResponseBean(callEntity);
|
||||
|
||||
List<EvaluationCriteriaResponseBean> evaluationCriteriaResponseBeans = evaluationCriteriaEntities.stream()
|
||||
.map(this::convertToEvaluationCriteriaResponseBean)
|
||||
.collect(Collectors.toList());
|
||||
.map(this::convertToEvaluationCriteriaResponseBean).collect(Collectors.toList());
|
||||
|
||||
List<DocumentResponseBean> documentResponseBeans = documentEntities.stream()
|
||||
.map(this::convertToDocumentResponseBean)
|
||||
.map(this::convertToDocumentResponseBean).collect(Collectors.toList());
|
||||
|
||||
List<FaqResponseBean> faqResponseBeans = faqEntities.stream().map(this::convertToFaqResponseBean)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<FaqResponseBean> faqResponseBeans = faqEntities.stream()
|
||||
.map(this::convertToFaqResponseBean)
|
||||
List<DocumentResponseBean> imagesResponseBean = images.stream().map(this::convertToDocumentResponseBean)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<DocumentResponseBean> imagesResponseBean = images.stream()
|
||||
.map(this::convertToDocumentResponseBean)
|
||||
.collect(Collectors.toList());
|
||||
CreateCallResponseBean createCallResponseBean =callResponseBean;
|
||||
CallResponse createCallResponseBean = callResponseBean;
|
||||
createCallResponseBean.setCriteria(evaluationCriteriaResponseBeans);
|
||||
createCallResponseBean.setDocs(documentResponseBeans);
|
||||
createCallResponseBean.setFaq(faqResponseBeans);
|
||||
createCallResponseBean.setImages(imagesResponseBean);
|
||||
return createCallResponseBean;
|
||||
}
|
||||
public List<LookUpDataResponse> convertLookUpDataEntities(List<LookUpDataReq> lookUpData, CallEntity callEntity, LookUpDataEntity.LookUpDataTypeEnum type) {
|
||||
List<LookUpDataEntity> lookUpDataEntities = lookUpData.stream()
|
||||
.map(req -> convertLookUpDataRequestIntoLookUpDataEntity(req, type))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
lookUpDataRepository.saveAll(lookUpDataEntities);
|
||||
public List<LookUpDataResponse> convertLookUpDataEntities(List<LookUpDataReq> lookUpData, CallEntity callEntity,
|
||||
LookUpDataEntity.LookUpDataTypeEnum type) {
|
||||
List<LookUpDataEntity> lookUpDataEntities = lookUpData.stream()
|
||||
.map(req -> convertLookUpDataRequestIntoLookUpDataEntity(req, type)).collect(Collectors.toList());
|
||||
|
||||
return createCallTargetAudienceCheckList(callEntity, lookUpDataEntities);
|
||||
}
|
||||
|
||||
private List<LookUpDataResponse> createCallTargetAudienceCheckList(CallEntity callEntity, List<LookUpDataEntity> lookUpDataEntities) {
|
||||
private List<LookUpDataResponse> createCallTargetAudienceCheckList(CallEntity callEntity,
|
||||
List<LookUpDataEntity> lookUpDataEntities) {
|
||||
List<LookUpDataResponse> lookUpDataResponses = new ArrayList<>();
|
||||
for (LookUpDataEntity lookUpDataEntity : lookUpDataEntities) {
|
||||
CallTargetAudienceChecklistEntity callTargetAudienceChecklistEntity = new CallTargetAudienceChecklistEntity();
|
||||
callTargetAudienceChecklistEntity.setIsValidated(false);
|
||||
callTargetAudienceChecklistEntity.setLookupData(lookUpDataEntity);
|
||||
callTargetAudienceChecklistEntity.setCall(callEntity);
|
||||
callTargetAudienceChecklistEntity= callTargetAudienceChecklistRepository.save(callTargetAudienceChecklistEntity);
|
||||
callTargetAudienceChecklistEntity.setIsDeleted(false);
|
||||
callTargetAudienceChecklistEntity = callTargetAudienceChecklistRepository
|
||||
.save(callTargetAudienceChecklistEntity);
|
||||
lookUpDataResponses.add(convertToLookUpDataResponseBean(callTargetAudienceChecklistEntity));
|
||||
}
|
||||
return lookUpDataResponses;
|
||||
}
|
||||
|
||||
private LookUpDataEntity convertLookUpDataRequestIntoLookUpDataEntity(LookUpDataReq req, LookUpDataEntity.LookUpDataTypeEnum type) {
|
||||
private LookUpDataEntity convertLookUpDataRequestIntoLookUpDataEntity(LookUpDataReq req,
|
||||
LookUpDataEntity.LookUpDataTypeEnum type) {
|
||||
if (req.getLookUpDataId() == null || req.getLookUpDataId().equals(0l)) {
|
||||
LookUpDataEntity newEntity = new LookUpDataEntity();
|
||||
newEntity.setValue(req.getValue());
|
||||
newEntity.setType(type.getValue());
|
||||
return newEntity;
|
||||
return lookUpDataRepository.save(newEntity);
|
||||
}
|
||||
|
||||
return lookUpDataRepository.findById(req.getLookUpDataId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.LOOK_UP_DATA_NOT_VALID_MSG)));
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.LOOK_UP_DATA_NOT_VALID_MSG)));
|
||||
}
|
||||
|
||||
public LookUpDataResponse convertToLookUpDataResponseBean(CallTargetAudienceChecklistEntity callTargetAudienceChecklistEntity) {
|
||||
public LookUpDataResponse convertToLookUpDataResponseBean(
|
||||
CallTargetAudienceChecklistEntity callTargetAudienceChecklistEntity) {
|
||||
LookUpDataResponse lookUpDataResponse = new LookUpDataResponse();
|
||||
LookUpDataEntity lookUpDataEntity = callTargetAudienceChecklistEntity.getLookupData();
|
||||
lookUpDataResponse.setId(callTargetAudienceChecklistEntity.getId());
|
||||
lookUpDataResponse.setLookUpDataId(lookUpDataEntity.getId());
|
||||
lookUpDataResponse.setValue(lookUpDataEntity.getValue());
|
||||
lookUpDataResponse.setTitle(lookUpDataEntity.getTitle());
|
||||
lookUpDataResponse.setCreatedDate(lookUpDataEntity.getCreatedDate());
|
||||
lookUpDataResponse.setUpdatedDate(lookUpDataEntity.getUpdatedDate());
|
||||
lookUpDataResponse.setCreatedDate(callTargetAudienceChecklistEntity.getCreatedDate());
|
||||
lookUpDataResponse.setUpdatedDate(callTargetAudienceChecklistEntity.getUpdatedDate());
|
||||
return lookUpDataResponse;
|
||||
}
|
||||
|
||||
|
||||
public CreateCallResponseBean createCallStep2(CreateCallRequestStep2 createCallRequest, Long userId) {
|
||||
CreateCallResponseBean createCallResponseBean = null;
|
||||
CallEntity callEntity = callRepository.findById(createCallRequest.getCallId())
|
||||
public CallEntity validateCall(Long callId) {
|
||||
return callRepository.findById(callId).orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||
}
|
||||
public CallResponse getCallById(Long callId) {
|
||||
CallEntity callEntity = callRepository.findById(callId)
|
||||
.orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.NAME_NOT_EMPTY_MSG)));
|
||||
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||
return getCallResponseBean(callEntity);
|
||||
}
|
||||
|
||||
callEntity.setThreshold(createCallRequest.getThreshold());
|
||||
List<EvaluationCriteriaEntity> evaluationCriteriaEntities = convertToEvaluationCriteriaEntities(
|
||||
createCallRequest.getCriteria(), callEntity);
|
||||
List<DocumentEntity> documentEntities = convertToDocumentEntities(createCallRequest.getDocs(), callEntity);
|
||||
List<DocumentEntity> imageEntities = convertToDocumentEntities(createCallRequest.getImages(), callEntity);
|
||||
List<LookUpDataResponse> checkList = convertLookUpDataEntities(createCallRequest.getCheckList(), callEntity,
|
||||
LookUpDataTypeEnum.CHECKLIST);
|
||||
List<FaqEntity> faqEntities = faqRepository.findByCallId(callEntity.getId());
|
||||
public CallResponse createCallStep2(Long callId, CreateCallRequestStep2 createCallRequest, Long userId) {
|
||||
CallEntity callEntity = callRepository.findById(callId)
|
||||
.orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||
|
||||
setIfUpdated(callEntity::getThreshold, callEntity::setThreshold, createCallRequest.getThreshold());
|
||||
callRepository.save(callEntity);
|
||||
convertToEvaluationCriteriaEntities(createCallRequest.getCriteria(), callEntity, LookUpDataTypeEnum.EVALUATION_CRITERIA);
|
||||
|
||||
convertToDocumentEntities(createCallRequest.getDocs(), callEntity, DocumentTypeEnum.DOCUMENT);
|
||||
|
||||
convertToDocumentEntities(createCallRequest.getImages(), callEntity, DocumentTypeEnum.IMAGES);
|
||||
|
||||
updateLookUpData(callEntity, createCallRequest.getCheckList(), LookUpDataTypeEnum.CHECKLIST);
|
||||
|
||||
// List<FaqEntity> faqEntities = faqRepository.findByCallIdAndIsDeletedFalse(callEntity.getId());
|
||||
// List<LookUpDataResponse> amiedTo = callTargetAudienceChecklistRepository
|
||||
// .findByCallIdAndLookupDataTypeAndIsDeletedFalse(callEntity.getId(), LookUpDataTypeEnum.AIMED_TO.getValue()).stream()
|
||||
// .map(this::convertToLookUpDataResponseBean).toList();
|
||||
// createCallResponseBean = assembleCreateCallResponseBean(callEntity, evaluationCriteriaEntities,
|
||||
// documentEntities, faqEntities, imageEntities);
|
||||
// createCallResponseBean.setAimedTo(amiedTo);
|
||||
// createCallResponseBean.setCheckList(checkList);
|
||||
CallResponse createCallResponseBean = getCallResponseBean(callEntity);
|
||||
createCallResponseBean.setCurrentStep(GepafinConstant.STEP_2);
|
||||
return createCallResponseBean;
|
||||
}
|
||||
|
||||
public void isValidDateRange(UpdateCallRequestStep1 updateCallRequest, CallEntity callEntity) {
|
||||
LocalDate startDate = updateCallRequest.getStartDate() != null ? updateCallRequest.getStartDate().toLocalDate()
|
||||
: null;
|
||||
LocalDate endDate = updateCallRequest.getEndDate() != null ? updateCallRequest.getEndDate().toLocalDate()
|
||||
: null;
|
||||
Boolean isValid = true;
|
||||
if (startDate != null && endDate != null && startDate.isAfter(endDate)) {
|
||||
isValid = false;
|
||||
} else if (startDate != null && endDate == null && callEntity.getEndDate() != null
|
||||
&& startDate.isAfter(callEntity.getEndDate().toLocalDate())) {
|
||||
isValid = false;
|
||||
} else if (startDate == null && endDate != null && callEntity.getStartDate() != null
|
||||
&& callEntity.getStartDate().toLocalDate().isAfter(endDate)) {
|
||||
isValid = false;
|
||||
}
|
||||
|
||||
if (Boolean.FALSE.equals(isValid)) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.INVALID_DATE_MSG));
|
||||
}
|
||||
}
|
||||
|
||||
public CallResponse updateCallStep1(Long callId, UpdateCallRequestStep1 updateCallRequest, Long userId) {
|
||||
CallEntity callEntity = validateCall(callId);
|
||||
UserEntity userEntity = userService.validateUser(userId);
|
||||
isValidDateRange(updateCallRequest, callEntity);
|
||||
setIfUpdated(callEntity::getName, callEntity::setName, updateCallRequest.getName());
|
||||
setIfUpdated(callEntity::getDescriptionShort, callEntity::setDescriptionShort,
|
||||
updateCallRequest.getDescriptionShort());
|
||||
setIfUpdated(callEntity::getDescriptionLong, callEntity::setDescriptionLong,
|
||||
updateCallRequest.getDescriptionLong());
|
||||
setIfUpdated(callEntity::getStartDate, callEntity::setStartDate, updateCallRequest.getStartDate());
|
||||
setIfUpdated(callEntity::getEndDate, callEntity::setEndDate, updateCallRequest.getEndDate());
|
||||
setIfUpdated(callEntity::getAmount, callEntity::setAmount, updateCallRequest.getAmount());
|
||||
setIfUpdated(callEntity::getAmountMax, callEntity::setAmountMax, updateCallRequest.getAmountMax());
|
||||
setIfUpdated(callEntity::getDocumentationRequested, callEntity::setDocumentationRequested,
|
||||
updateCallRequest.getDocumentationRequested());
|
||||
setIfUpdated(callEntity::getConfidi, callEntity::setConfidi, updateCallRequest.getConfidi());
|
||||
updateLookUpData(callEntity, updateCallRequest.getAimedTo(), LookUpDataTypeEnum.AIMED_TO);
|
||||
updateFaq(callEntity, updateCallRequest.getFaq(), userEntity);
|
||||
CallResponse createCallResponseBean = getCallResponseBean(callEntity);
|
||||
createCallResponseBean.setCurrentStep(GepafinConstant.STEP_1);
|
||||
return createCallResponseBean;
|
||||
}
|
||||
|
||||
private void updateFaq(CallEntity callEntity, List<FaqReq> faqReqList, UserEntity userEntity) {
|
||||
if(faqReqList==null) {
|
||||
return;
|
||||
}
|
||||
List<FaqEntity> existingFaqs = faqRepository.findByCallIdAndIsDeletedFalse(callEntity.getId());
|
||||
List<Long> incomingIds = faqReqList.stream().map(FaqReq::getId).filter(Objects::nonNull).filter(id -> id > 0)
|
||||
.collect(Collectors.toList());
|
||||
existingFaqs.stream().filter(faq -> !incomingIds.contains(faq.getId())).forEach(this::softDeleteFaq);
|
||||
faqReqList.forEach(faqReq -> createOrUpdateFaq(faqReq, callEntity, userEntity));
|
||||
|
||||
}
|
||||
|
||||
private void softDeleteFaq(FaqEntity faqEntity) {
|
||||
faqEntity.setIsDeleted(true);
|
||||
faqRepository.save(faqEntity);
|
||||
}
|
||||
|
||||
private void createOrUpdateFaq(FaqReq faqReq, CallEntity callEntity, UserEntity userEntity) {
|
||||
FaqEntity faqEntity = null;
|
||||
|
||||
if (isExistingFaq(faqReq)) {
|
||||
faqEntity = faqRepository.findById(faqReq.getId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.FAQ_NOT_FOUND)));
|
||||
} else {
|
||||
faqEntity = new FaqEntity();
|
||||
faqEntity.setCall(callEntity);
|
||||
faqEntity.setUser(userEntity);
|
||||
faqEntity.setIsDeleted(false);
|
||||
}
|
||||
|
||||
setIfUpdated(faqEntity::getQuestionShort, faqEntity::setQuestionShort, faqReq.getQuestionShort());
|
||||
setIfUpdated(faqEntity::getQuestion, faqEntity::setQuestion, faqReq.getQuestion());
|
||||
setIfUpdated(faqEntity::getResponseShort, faqEntity::setResponseShort, faqReq.getResponseShort());
|
||||
setIfUpdated(faqEntity::getResponse, faqEntity::setResponse, faqReq.getResponse());
|
||||
setIfUpdated(faqEntity::getIsVisible, faqEntity::setIsVisible, faqReq.getIsVisible());
|
||||
faqRepository.save(faqEntity);
|
||||
}
|
||||
|
||||
private boolean isExistingFaq(FaqReq faqReq) {
|
||||
return faqReq.getId() != null && faqReq.getId() > 0;
|
||||
}
|
||||
|
||||
private void updateLookUpData(CallEntity callEntity, List<LookUpDataReq> lookupDataReqList, LookUpDataTypeEnum type) {
|
||||
if (lookupDataReqList == null) {
|
||||
return;
|
||||
}
|
||||
List<CallTargetAudienceChecklistEntity> existingChecklist = callTargetAudienceChecklistRepository
|
||||
.findByCallIdAndLookupDataTypeAndIsDeletedFalse(callEntity.getId(), type.getValue());
|
||||
List<Long> incomingIds = lookupDataReqList.stream().map(LookUpDataReq::getLookUpDataId)
|
||||
.filter(id -> id != null && id > 0).collect(Collectors.toList());
|
||||
existingChecklist.stream().filter(checklist -> !incomingIds.contains(checklist.getLookupData().getId()))
|
||||
.forEach(this::softDeleteCallTargetAudienceChecklist);
|
||||
lookupDataReqList
|
||||
.forEach(lookUpDataReq -> createOrUpdateCallTargetAudienceChecklist(lookUpDataReq, callEntity, type));
|
||||
}
|
||||
|
||||
private void createOrUpdateCallTargetAudienceChecklist(LookUpDataReq lookUpDataReq, CallEntity callEntity,
|
||||
LookUpDataTypeEnum type) {
|
||||
CallTargetAudienceChecklistEntity checklistEntity = null;
|
||||
LookUpDataEntity lookupDataEntity = convertLookUpDataRequestIntoLookUpDataEntity(lookUpDataReq, type);
|
||||
if (lookUpDataReq.getId() != null && lookUpDataReq.getId() > 0) {
|
||||
checklistEntity = callTargetAudienceChecklistRepository.findById(lookUpDataReq.getId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||
|
||||
if (Boolean.FALSE.equals(checklistEntity.getLookupData().getId().equals(lookupDataEntity.getId()))) {
|
||||
checklistEntity.setLookupData(lookupDataEntity);
|
||||
}
|
||||
} else {
|
||||
checklistEntity = new CallTargetAudienceChecklistEntity();
|
||||
checklistEntity.setCall(callEntity);
|
||||
checklistEntity.setLookupData(lookupDataEntity);
|
||||
checklistEntity.setIsValidated(false);
|
||||
checklistEntity.setIsDeleted(false);
|
||||
}
|
||||
|
||||
callTargetAudienceChecklistRepository.save(checklistEntity);
|
||||
}
|
||||
|
||||
private void softDeleteCallTargetAudienceChecklist(
|
||||
CallTargetAudienceChecklistEntity callTargetAudienceChecklistEntity) {
|
||||
callTargetAudienceChecklistEntity.setIsDeleted(true);
|
||||
callTargetAudienceChecklistRepository.save(callTargetAudienceChecklistEntity);
|
||||
}
|
||||
|
||||
public CallDetailsResponseBean convertToCallDetailsResponseBean(CallEntity callEntity) {
|
||||
CallDetailsResponseBean callDetailsResponseBean = new CallDetailsResponseBean();
|
||||
callDetailsResponseBean.setId(callEntity.getId());
|
||||
callDetailsResponseBean.setName(callEntity.getName());
|
||||
callDetailsResponseBean.setDates(List.of(callEntity.getStartDate(), callEntity.getEndDate()));
|
||||
callDetailsResponseBean.setDescriptionShort(callEntity.getDescriptionShort());
|
||||
callDetailsResponseBean.setDescriptionLong(callEntity.getDescriptionLong());
|
||||
callDetailsResponseBean.setStatus(CallStatusEnum.valueOf(callEntity.getStatus()));
|
||||
callDetailsResponseBean.setRegionId(callEntity.getRegion().getId());
|
||||
callDetailsResponseBean.setAmount(callEntity.getAmount());
|
||||
callDetailsResponseBean.setAmountMax(callEntity.getAmountMax());
|
||||
callDetailsResponseBean.setContactInfo(callEntity.getContactInfo());
|
||||
callDetailsResponseBean.setSubmissionMethod(callEntity.getSubmissionMethod());
|
||||
callDetailsResponseBean.setThreshold(callEntity.getThreshold());
|
||||
callDetailsResponseBean.setDocumentationReqested(callEntity.getDocumentationRequested());
|
||||
callDetailsResponseBean.setPriorityArea(callEntity.getPriorityArea());
|
||||
callDetailsResponseBean.setCreatedDate(callEntity.getCreatedDate());
|
||||
callDetailsResponseBean.setUpdatedDate(callEntity.getUpdatedDate());
|
||||
return callDetailsResponseBean;
|
||||
}
|
||||
private CallResponse getCallResponseBean(CallEntity callEntity) {
|
||||
List<DocumentEntity> documentEntities = documentRepository.findByCallIdAndTypeAndIsDeletedFalse(callEntity.getId(),
|
||||
DocumentTypeEnum.DOCUMENT.getValue());
|
||||
List<DocumentEntity> imageEntities = documentRepository.findByCallIdAndTypeAndIsDeletedFalse(callEntity.getId(),
|
||||
DocumentTypeEnum.DOCUMENT.getValue());
|
||||
List<FaqEntity> faqEntities = faqRepository.findByCallIdAndIsDeletedFalse(callEntity.getId());
|
||||
List<LookUpDataResponse> amiedTo = callTargetAudienceChecklistRepository
|
||||
.findByCallIdAndLookupDataType(callEntity.getId(), LookUpDataTypeEnum.AIMED_TO.getValue()).stream()
|
||||
.findByCallIdAndLookupDataTypeAndIsDeletedFalse(callEntity.getId(), LookUpDataTypeEnum.AIMED_TO.getValue()).stream()
|
||||
.map(this::convertToLookUpDataResponseBean).toList();
|
||||
createCallResponseBean = assembleCreateCallResponseBean(callEntity, evaluationCriteriaEntities,
|
||||
|
||||
List<LookUpDataResponse> checkList = callTargetAudienceChecklistRepository
|
||||
.findByCallIdAndLookupDataTypeAndIsDeletedFalse(callEntity.getId(), LookUpDataTypeEnum.CHECKLIST.getValue()).stream()
|
||||
.map(this::convertToLookUpDataResponseBean).toList();
|
||||
List<EvaluationCriteriaEntity> evaluationCriteriaEntities = evaluationCriteriaRepository
|
||||
.findByCallIdAndLookupDataTypeAndIsDeletedFalse(callEntity.getId(), LookUpDataTypeEnum.EVALUATION_CRITERIA.getValue());
|
||||
|
||||
CallResponse createCallResponseBean = assembleCreateCallResponseBean(callEntity, evaluationCriteriaEntities,
|
||||
documentEntities, faqEntities, imageEntities);
|
||||
createCallResponseBean.setAimedTo(amiedTo);
|
||||
createCallResponseBean.setCheckList(checkList);
|
||||
return createCallResponseBean;
|
||||
|
||||
}
|
||||
public List<EvaluationCriteriaEntity> convertToEvaluationCriteriaEntities(List<EvaluationCriteriaReq> criteriaReqList, CallEntity callEntity) {
|
||||
List<EvaluationCriteriaEntity> evaluationCriteriaEntities = criteriaReqList.stream().map(req -> convertToEvaluationCriteriaEntity(req, callEntity)).collect(Collectors.toList());
|
||||
evaluationCriteriaRepository.saveAll(evaluationCriteriaEntities);
|
||||
return evaluationCriteriaEntities;
|
||||
}
|
||||
public List<CallDetailsResponseBean> getAllCalls() {
|
||||
return callRepository.findAll()
|
||||
.stream()
|
||||
.map(this::convertToCallDetailsResponseBean)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
|
||||
|
||||
public CallResponse validateCall(CallEntity callEntity) {
|
||||
CallResponse callResponseBean = getCallResponseBean(callEntity);
|
||||
CallValidatorServiceImpl.validateResponse(callResponseBean);
|
||||
callEntity.setStatus(CallStatusEnum.READY_TO_PUBLISH.getValue());
|
||||
callRepository.save(callEntity);
|
||||
callResponseBean.setCurrentStep(GepafinConstant.VALIDATE_REQUEST);
|
||||
return callResponseBean;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import net.gepafin.tendermanagement.service.AmazonS3Service;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -39,21 +38,14 @@ public class DocumentDao {
|
||||
@Autowired
|
||||
private CallDao callDao;
|
||||
|
||||
@Value("${aws.s3.bucket.name}")
|
||||
private String bucketName;
|
||||
|
||||
@Value("${aws.s3.url.folder}")
|
||||
private String s3Folder;
|
||||
|
||||
@Value("${aws.s3.url}")
|
||||
private String s3Url;
|
||||
|
||||
@Autowired
|
||||
private CallRepository callRepository;
|
||||
|
||||
public List<DocumentResponseBean> uploadFiles(List<MultipartFile> files, Long callId, DocumentTypeEnum fileType) {
|
||||
List<DocumentEntity> documentEntities = new ArrayList<>();
|
||||
CallEntity callEntity=callRepository.findById(callId).orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||
CallEntity callEntity = callRepository.findById(callId)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||
for (MultipartFile file : files) {
|
||||
try {
|
||||
uploadFileOnAmazonS3 result = uploadFileOnAmazonS3(file);
|
||||
@@ -63,14 +55,14 @@ public class DocumentDao {
|
||||
documentEntity.setCall(callEntity);
|
||||
documentEntity.setType(fileType.getValue());
|
||||
documentEntity.setFilePath(result.filepath());
|
||||
documentEntity.setIsDeleted(false);
|
||||
documentEntities.add(documentEntity);
|
||||
}
|
||||
} catch (IOException e) {}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
documentRepository.saveAll(documentEntities);
|
||||
return documentEntities.stream()
|
||||
.map(callDao::convertToDocumentResponseBean)
|
||||
.collect(Collectors.toList());
|
||||
return documentEntities.stream().map(callDao::convertToDocumentResponseBean).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private uploadFileOnAmazonS3 uploadFileOnAmazonS3(MultipartFile file) throws IOException {
|
||||
@@ -88,22 +80,25 @@ public class DocumentDao {
|
||||
|
||||
public void deleteFile(Long documentId) {
|
||||
DocumentEntity documentEntity = getDocumentEntity(documentId);
|
||||
String fileName= Utils.extractFileName(documentEntity.getFilePath());
|
||||
deleteFileOnAmazonS3(fileName);
|
||||
documentRepository.delete(documentEntity);
|
||||
// String fileName= Utils.extractFileName(documentEntity.getFilePath());
|
||||
// deleteFileOnAmazonS3(fileName);
|
||||
documentEntity.setIsDeleted(true);
|
||||
documentRepository.save(documentEntity);
|
||||
}
|
||||
|
||||
private DocumentEntity deleteFileOnAmazonS3(String fileName) {
|
||||
try {
|
||||
amazonS3Service.delete(fileName);
|
||||
}catch (Exception e){}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private DocumentEntity getDocumentEntity(Long documentId) {
|
||||
Optional<DocumentEntity> documentEntity = documentRepository.findById(documentId);
|
||||
if (documentEntity.isEmpty()) {
|
||||
throw new ResourceNotFoundException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND));
|
||||
throw new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND));
|
||||
}
|
||||
return documentEntity.orElse(null);
|
||||
}
|
||||
@@ -115,7 +110,8 @@ public class DocumentDao {
|
||||
uploadFileOnAmazonS3 result = null;
|
||||
try {
|
||||
result = uploadFileOnAmazonS3(file);
|
||||
} catch (IOException e) {}
|
||||
} catch (IOException e) {
|
||||
}
|
||||
if (result != null) {
|
||||
documentEntity.setFilePath(result.filepath);
|
||||
documentEntity.setFileName(result.fileName);
|
||||
@@ -124,10 +120,12 @@ public class DocumentDao {
|
||||
}
|
||||
return callDao.convertToDocumentResponseBean(documentEntity);
|
||||
}
|
||||
|
||||
public DocumentResponseBean getDocument(Long documentId) {
|
||||
Optional<DocumentEntity> documentEntity = documentRepository.findById(documentId);
|
||||
if (documentEntity.isEmpty()) {
|
||||
new ResourceNotFoundException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND));
|
||||
new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND));
|
||||
}
|
||||
return callDao.convertToDocumentResponseBean(documentEntity.orElse(null));
|
||||
}
|
||||
|
||||
@@ -4,10 +4,12 @@ import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||
import net.gepafin.tendermanagement.entities.EvaluationCriteriaEntity;
|
||||
import net.gepafin.tendermanagement.entities.LookUpDataEntity;
|
||||
import net.gepafin.tendermanagement.model.request.EvaluationCriteriaRequest;
|
||||
import net.gepafin.tendermanagement.model.response.EvaluationCriteriaResponseBean;
|
||||
import net.gepafin.tendermanagement.repositories.CallRepository;
|
||||
import net.gepafin.tendermanagement.repositories.EvaluationCriteriaRepository;
|
||||
import net.gepafin.tendermanagement.repositories.LookUpDataRepository;
|
||||
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;
|
||||
@@ -19,11 +21,14 @@ import org.springframework.stereotype.Component;
|
||||
public class EvaluationCriteriaDao {
|
||||
|
||||
@Autowired
|
||||
private EvaluationCriteriaRepository repository;
|
||||
private EvaluationCriteriaRepository evaluationCriteriaRepository;
|
||||
|
||||
@Autowired
|
||||
private CallRepository callRepository;
|
||||
|
||||
@Autowired
|
||||
private LookUpDataRepository lookUpDataRepository;
|
||||
|
||||
public EvaluationCriteriaResponseBean createEvaluationCriteria(EvaluationCriteriaRequest evaluationCriteriaRequest) {
|
||||
EvaluationCriteriaEntity entity = convertEvaluationCriteriaRequestToEvaluationCriteriaEntity(evaluationCriteriaRequest);
|
||||
return convertEvaluationCriteriaEntityEvaluationCriteriaToResponseBean(entity);
|
||||
@@ -33,22 +38,24 @@ public class EvaluationCriteriaDao {
|
||||
EvaluationCriteriaEntity entity = new EvaluationCriteriaEntity();
|
||||
CallEntity callEntity = callRepository.findById(evaluationCriteriaRequest.getCallId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||
LookUpDataEntity looDataEntity = lookUpDataRepository.findById(evaluationCriteriaRequest.getLookUpDataId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.LOOKUP_DATA_NOT_FOUND)));
|
||||
entity.setCall(callEntity);
|
||||
entity.setName(evaluationCriteriaRequest.getName());
|
||||
entity.setDescription(evaluationCriteriaRequest.getDescription());
|
||||
entity.setLookupData(looDataEntity);
|
||||
entity.setScore(evaluationCriteriaRequest.getScore());
|
||||
entity = repository.save(entity);
|
||||
entity = evaluationCriteriaRepository.save(entity);
|
||||
return entity;
|
||||
}
|
||||
|
||||
public EvaluationCriteriaResponseBean getEvaluationCriteriaById(Long id) {
|
||||
return repository.findById(id)
|
||||
return evaluationCriteriaRepository.findById(id)
|
||||
.map(this::convertEvaluationCriteriaEntityEvaluationCriteriaToResponseBean)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_NOT_FOUND)));
|
||||
}
|
||||
|
||||
public EvaluationCriteriaResponseBean updateEvaluationCriteria(Long id, EvaluationCriteriaRequest request) {
|
||||
EvaluationCriteriaEntity entity = repository.findById(id)
|
||||
EvaluationCriteriaEntity entity = evaluationCriteriaRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_NOT_FOUND)));
|
||||
entity = convertEvaluationCriteriaRequestToEvaluationCriteriaEntity(request);
|
||||
return convertEvaluationCriteriaEntityEvaluationCriteriaToResponseBean(entity);
|
||||
@@ -56,7 +63,7 @@ public class EvaluationCriteriaDao {
|
||||
|
||||
public void deleteEvaluationCriteria(Long id) {
|
||||
try {
|
||||
repository.deleteById(id);
|
||||
evaluationCriteriaRepository.deleteById(id);
|
||||
} catch (EmptyResultDataAccessException e) {
|
||||
throw new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_NOT_FOUND));
|
||||
}
|
||||
@@ -65,11 +72,12 @@ public class EvaluationCriteriaDao {
|
||||
private EvaluationCriteriaResponseBean convertEvaluationCriteriaEntityEvaluationCriteriaToResponseBean(EvaluationCriteriaEntity entity) {
|
||||
EvaluationCriteriaResponseBean response = new EvaluationCriteriaResponseBean();
|
||||
response.setId(entity.getId());
|
||||
response.setName(entity.getName());
|
||||
response.setDescription(entity.getDescription());
|
||||
response.setScore(entity.getScore());
|
||||
response.setCreatedDate(entity.getCreatedDate());
|
||||
response.setUpdatedDate(entity.getUpdatedDate());
|
||||
response.setLookUpDataId(entity.getLookupData().getId());
|
||||
response.setTitle(entity.getLookupData().getTitle());
|
||||
response.setValue(entity.getLookupData().getValue());
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||
@@ -34,29 +35,31 @@ public class FaqDao {
|
||||
|
||||
public FaqResponseBean createFaq(FaqReq faqRequest, Long userId, Long callId) {
|
||||
FaqEntity entity = new FaqEntity();
|
||||
CallEntity callEntity=callRepository.findById(callId).orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||
CallEntity callEntity = callRepository.findById(callId)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.CALL_NOT_FOUND)));
|
||||
entity = callDao.convertToFaqEntity(faqRequest, callEntity, userId);
|
||||
faqRepository.save(entity);
|
||||
return convertFaqEntityToResponseBean(entity);
|
||||
}
|
||||
|
||||
public FaqResponseBean getFaqById(Long id) {
|
||||
return faqRepository.findById(id)
|
||||
.map(this::convertFaqEntityToResponseBean)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.FAQ_NOT_FOUND)));
|
||||
return faqRepository.findById(id).map(this::convertFaqEntityToResponseBean)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.FAQ_NOT_FOUND)));
|
||||
}
|
||||
|
||||
public FaqResponseBean updateFaq(Long id, FaqReq faqRequest, Long userId) {
|
||||
FaqEntity entity = faqRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,Translator.toLocale(GepafinConstant.FAQ_NOT_FOUND)));
|
||||
FaqEntity entity = faqRepository.findById(id).orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.FAQ_NOT_FOUND)));
|
||||
updateFaqEntity(entity, faqRequest, userId, entity.getCall());
|
||||
faqRepository.save(entity);
|
||||
return convertFaqEntityToResponseBean(entity);
|
||||
}
|
||||
|
||||
public void deleteFaq(Long id) {
|
||||
FaqEntity entity = faqRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,Translator.toLocale(GepafinConstant.FAQ_NOT_FOUND)));
|
||||
FaqEntity entity = faqRepository.findById(id).orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND,
|
||||
Translator.toLocale(GepafinConstant.FAQ_NOT_FOUND)));
|
||||
faqRepository.deleteById(entity.getId());
|
||||
|
||||
}
|
||||
@@ -75,10 +78,12 @@ public class FaqDao {
|
||||
response.setResponseDate(entity.getResponseDate());
|
||||
return response;
|
||||
}
|
||||
|
||||
private void updateFaqEntity(FaqEntity faqEntity, FaqReq faqReq, Long userId, CallEntity callEntity) {
|
||||
faqEntity.setQuestion(faqReq.getQuestion());
|
||||
UserEntity userEntity = userRepository.findById(userId)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.LOOK_UP_DATA_NOT_VALID_MSG)));
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.LOOK_UP_DATA_NOT_VALID_MSG)));
|
||||
faqEntity.setUser(userEntity);
|
||||
faqEntity.setIsVisible(true);
|
||||
if (faqReq.getIsVisible() != null) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.LookUpDataEntity;
|
||||
import net.gepafin.tendermanagement.entities.LookUpDataEntity.LookUpDataTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.LookUpDataRequest;
|
||||
import net.gepafin.tendermanagement.model.response.LookUpDataResponseBean;
|
||||
import net.gepafin.tendermanagement.repositories.LookUpDataRepository;
|
||||
@@ -11,6 +12,9 @@ import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
public class LookUpDataDao {
|
||||
|
||||
@@ -62,4 +66,12 @@ public class LookUpDataDao {
|
||||
response.setUpdatedDate(entity.getUpdatedDate());
|
||||
return response;
|
||||
}
|
||||
|
||||
public List<LookUpDataResponseBean> getLookUpDataByType(LookUpDataTypeEnum type) {
|
||||
return lookUpDataRepository.findByType(type.getValue())
|
||||
.stream()
|
||||
.map(this::convertLookUpDataEntityToResponseBean)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.RegionEntity;
|
||||
import net.gepafin.tendermanagement.enums.RegionStatusEnum;
|
||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.RegionReq;
|
||||
import net.gepafin.tendermanagement.model.response.RegionResponseBean;
|
||||
import net.gepafin.tendermanagement.repositories.RegionRepository;
|
||||
@@ -19,7 +18,7 @@ import org.springframework.stereotype.Repository;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.ObjectUtils.setIfUpdated;
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
|
||||
@Repository
|
||||
public class RegionDao {
|
||||
@@ -77,7 +76,7 @@ public class RegionDao {
|
||||
|
||||
public RegionResponseBean updateRegion(Long id, RegionReq regionReq) {
|
||||
log.info("Updating region with ID: {}", id);
|
||||
RegionEntity existingRegion = getRegionById(id);
|
||||
RegionEntity existingRegion = validateRegion(id);
|
||||
log.info("Current region details: {}", existingRegion);
|
||||
log.info("New region details: {}", regionReq);
|
||||
String newStatus = regionReq.getStatus() != null ? regionReq.getStatus().getValue() : null;
|
||||
@@ -103,14 +102,19 @@ public class RegionDao {
|
||||
return Utils.convertObject(existingRegion, RegionResponseBean.class);
|
||||
}
|
||||
|
||||
public RegionEntity getRegionById(Long id) {
|
||||
public RegionEntity validateRegion(Long id) {
|
||||
log.info("Fetching region with ID: {}", id);
|
||||
RegionEntity regionEntity = regionRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.REGION_NOT_FOUND_MSG)));
|
||||
log.info("Region found: {}", regionEntity);
|
||||
return regionEntity;
|
||||
}
|
||||
|
||||
public RegionResponseBean getRegionById(Long id) {
|
||||
log.info("Fetching region with ID: {}", id);
|
||||
RegionEntity regionEntity = regionRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.REGION_NOT_FOUND_MSG)));
|
||||
return convertRegionEntityToRegionResponse(regionEntity);
|
||||
}
|
||||
public void deleteById(Long id) {
|
||||
log.info("Deleting region with ID: {}", id);
|
||||
regionRepository.findById(id)
|
||||
|
||||
@@ -2,12 +2,12 @@ package net.gepafin.tendermanagement.dao;
|
||||
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.RegionEntity;
|
||||
import net.gepafin.tendermanagement.entities.RoleEntity;
|
||||
import net.gepafin.tendermanagement.model.request.RoleReq;
|
||||
import net.gepafin.tendermanagement.model.response.RegionResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.RoleResponseBean;
|
||||
import net.gepafin.tendermanagement.repositories.RoleRepository;
|
||||
import net.gepafin.tendermanagement.service.RegionService;
|
||||
import net.gepafin.tendermanagement.util.Utils;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
@@ -19,7 +19,7 @@ import org.springframework.stereotype.Component;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.ObjectUtils.setIfUpdated;
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
|
||||
@Component
|
||||
public class RoleDao {
|
||||
@@ -28,9 +28,6 @@ public class RoleDao {
|
||||
@Autowired
|
||||
private RoleRepository roleRepository;
|
||||
|
||||
@Autowired
|
||||
private RegionService regionService;
|
||||
|
||||
@Autowired
|
||||
private RegionDao regionDao;
|
||||
|
||||
@@ -48,7 +45,8 @@ public class RoleDao {
|
||||
roleEntity.setRoleType(roleReq.getRoleType());
|
||||
roleEntity.setPermissions(roleReq.getPermissions());
|
||||
roleEntity.setDescription(roleReq.getDescription());
|
||||
roleEntity.setRegion(regionService.getRegionById(roleReq.getRegionId()));
|
||||
RegionEntity regionEntity =regionDao.validateRegion(roleReq.getRegionId());
|
||||
roleEntity.setRegion(regionEntity);
|
||||
return roleEntity;
|
||||
}
|
||||
|
||||
@@ -68,7 +66,7 @@ public class RoleDao {
|
||||
|
||||
public RoleResponseBean updateRole(Long id, RoleReq roleReq) {
|
||||
log.info("Updating role with ID: {}", id);
|
||||
RoleEntity existingRole = getRoleById(id);
|
||||
RoleEntity existingRole = validateRole(id);
|
||||
|
||||
// Log changes before update
|
||||
log.info("Current role details: {}", existingRole);
|
||||
@@ -85,14 +83,20 @@ public class RoleDao {
|
||||
return Utils.convertObject(existingRole, RoleResponseBean.class);
|
||||
}
|
||||
|
||||
public RoleEntity getRoleById(Long id) {
|
||||
public RoleEntity validateRole(Long id) {
|
||||
log.info("Fetching role with ID: {}", id);
|
||||
RoleEntity roleEntity = roleRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.ROLE_NOT_FOUND)));
|
||||
log.info("Role found: {}", roleEntity);
|
||||
return roleEntity;
|
||||
}
|
||||
|
||||
public RoleResponseBean getRoleById(Long id) {
|
||||
log.info("Fetching role with ID: {}", id);
|
||||
RoleEntity roleEntity = roleRepository.findById(id)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.ROLE_NOT_FOUND)));
|
||||
log.info("Role found: {}", roleEntity);
|
||||
return convertRoleEntityToRoleResponse(roleEntity);
|
||||
}
|
||||
public void deleteById(Long id) {
|
||||
log.info("Deleting role with ID: {}", id);
|
||||
roleRepository.findById(id)
|
||||
|
||||
@@ -12,7 +12,6 @@ import net.gepafin.tendermanagement.model.response.RoleResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||
import net.gepafin.tendermanagement.service.RoleService;
|
||||
import net.gepafin.tendermanagement.service.impl.AuthenticationService;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.CustomValidationException;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||
@@ -22,12 +21,10 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Base64;
|
||||
import java.util.Optional;
|
||||
|
||||
import static net.gepafin.tendermanagement.util.ObjectUtils.setIfUpdated;
|
||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||
|
||||
@Repository
|
||||
public class UserDao {
|
||||
@@ -40,9 +37,6 @@ public class UserDao {
|
||||
@Autowired
|
||||
private AuthenticationService authService;
|
||||
|
||||
@Autowired
|
||||
private RoleService roleService;
|
||||
|
||||
@Autowired
|
||||
private PasswordEncoder passwordEncoder;
|
||||
|
||||
@@ -85,7 +79,7 @@ public class UserDao {
|
||||
setIfUpdated(userEntity::getAddress, userEntity::setAddress, userReq.getAddress());
|
||||
setIfUpdated(userEntity::getPhoneNumber, userEntity::setPhoneNumber, userReq.getPhoneNumber());
|
||||
if (userReq.getRoleId() != null) {
|
||||
RoleEntity roleEntity = roleService.getRoleById(userReq.getRoleId());
|
||||
RoleEntity roleEntity = roleDao.validateRole(userReq.getRoleId());
|
||||
setIfUpdated(userEntity::getRoleEntity, userEntity::setRoleEntity, roleEntity);
|
||||
}
|
||||
userEntity = userRepository.save(userEntity);
|
||||
@@ -103,7 +97,7 @@ public class UserDao {
|
||||
userEntity.setOrganization(userReq.getOrganization());
|
||||
userEntity.setAddress(userReq.getAddress());
|
||||
userEntity.setPhoneNumber(userReq.getPhoneNumber());
|
||||
userEntity.setRoleEntity(roleService.getRoleById(userReq.getRoleId()));
|
||||
userEntity.setRoleEntity(roleDao.validateRole(userReq.getRoleId()));
|
||||
return userEntity;
|
||||
}
|
||||
|
||||
@@ -153,6 +147,12 @@ public class UserDao {
|
||||
log.info("Login successful for email: {}", loginReq.getEmail());
|
||||
return jwtToken;
|
||||
}
|
||||
|
||||
public UserEntity validateUser(Long userId) {
|
||||
return userRepository.findById(userId)
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG)));
|
||||
}
|
||||
public String generateSecureToken() {
|
||||
SecureRandom secureRandom = new SecureRandom();
|
||||
byte[] tokenBytes = new byte[24];
|
||||
|
||||
@@ -19,5 +19,8 @@ public class CallTargetAudienceChecklistEntity extends BaseEntity{
|
||||
@Column(name = "IS_VALIDATED")
|
||||
private Boolean isValidated;
|
||||
|
||||
@Column(name ="IS_DELETED", nullable = false)
|
||||
private Boolean isDeleted = false;
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
||||
@Entity
|
||||
@Table(name = "DOCUMENT")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class DocumentEntity extends BaseEntity{
|
||||
@Column(name = "FILE_NAME", length = 255)
|
||||
private String fileName;
|
||||
@@ -28,4 +26,8 @@ public class DocumentEntity extends BaseEntity{
|
||||
|
||||
@Column(name = "DESCRIPTION", columnDefinition = "TEXT")
|
||||
private String description;
|
||||
|
||||
@Column(name ="IS_DELETED", nullable = false)
|
||||
private Boolean isDeleted = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,30 +1,29 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
import jakarta.persistence.*;
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "EVALUATION_CRITERIA")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class EvaluationCriteriaEntity extends BaseEntity {
|
||||
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "CALL_ID", nullable = false)
|
||||
private CallEntity call;
|
||||
|
||||
@Column(name = "NAME", nullable = false, columnDefinition = "TEXT")
|
||||
private String name;
|
||||
|
||||
@Column(name = "DESCRIPTION", columnDefinition = "TEXT")
|
||||
private String description;
|
||||
@ManyToOne
|
||||
@JoinColumn(name = "LOOKUP_DATA_ID")
|
||||
private LookUpDataEntity lookupData;
|
||||
|
||||
@Column(name = "SCORE", nullable = false)
|
||||
private Integer score;
|
||||
private Long score;
|
||||
|
||||
@Column(name ="IS_DELETED", nullable = false)
|
||||
private Boolean isDeleted = false;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
package net.gepafin.tendermanagement.entities;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
import jakarta.persistence.Column;
|
||||
import jakarta.persistence.Entity;
|
||||
import jakarta.persistence.ForeignKey;
|
||||
import jakarta.persistence.JoinColumn;
|
||||
import jakarta.persistence.ManyToOne;
|
||||
import jakarta.persistence.Table;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
@Entity
|
||||
@Table(name = "FAQ")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class FaqEntity extends BaseEntity {
|
||||
|
||||
@ManyToOne
|
||||
@@ -42,5 +42,8 @@ public class FaqEntity extends BaseEntity {
|
||||
@Column(name = "RESPONSE_DATE")
|
||||
private LocalDateTime responseDate;
|
||||
|
||||
@Column(name ="IS_DELETED", nullable = false)
|
||||
private Boolean isDeleted = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -2,15 +2,16 @@ package net.gepafin.tendermanagement.enums;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonValue;
|
||||
|
||||
public enum CallTypeEnum {
|
||||
public enum CallStatusEnum {
|
||||
|
||||
DRAFT("DRAFT"),
|
||||
PUBLISH("PUBLISH"),
|
||||
EXPIRE("EXPIRE");
|
||||
EXPIRE("EXPIRED"),
|
||||
READY_TO_PUBLISH("READY_TO_PUBLISH");
|
||||
|
||||
private String value;
|
||||
|
||||
CallTypeEnum(String value) {
|
||||
CallStatusEnum(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.CallTypeEnum;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.validation.constraints.NotEmpty;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class CreateCallRequestStep1 {
|
||||
@@ -43,11 +41,8 @@ public class CreateCallRequestStep1 {
|
||||
@NotEmpty
|
||||
private String documentationRequested;
|
||||
|
||||
private Boolean Confidi;
|
||||
private Boolean confidi;
|
||||
|
||||
private List<FaqReq> faq;
|
||||
|
||||
@NotNull
|
||||
private CallTypeEnum status;
|
||||
|
||||
}
|
||||
|
||||
@@ -4,14 +4,10 @@ import java.util.List;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.CallTypeEnum;
|
||||
|
||||
@Data
|
||||
public class CreateCallRequestStep2 {
|
||||
|
||||
@NotNull
|
||||
private Long callId;
|
||||
|
||||
private Long threshold;
|
||||
|
||||
@NotNull
|
||||
@@ -24,6 +20,4 @@ public class CreateCallRequestStep2 {
|
||||
|
||||
private List<DocumentReq> images;
|
||||
|
||||
private CallTypeEnum status;
|
||||
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class EvaluationCriteriaReq {
|
||||
public class EvaluationCriteriaReq extends LookUpDataReq{
|
||||
|
||||
private String name;
|
||||
private String value;
|
||||
private Integer score;
|
||||
private Long score;
|
||||
}
|
||||
|
||||
@@ -5,13 +5,9 @@ import lombok.NoArgsConstructor;
|
||||
|
||||
@NoArgsConstructor
|
||||
@Data
|
||||
public class EvaluationCriteriaRequest {
|
||||
public class EvaluationCriteriaRequest extends LookUpDataReq {
|
||||
|
||||
private Long callId;
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private Integer score;
|
||||
private Long score;
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import lombok.Data;
|
||||
@Data
|
||||
public class FaqReq {
|
||||
|
||||
private Long id;
|
||||
private Boolean isVisible;
|
||||
private String questionShort;
|
||||
private String question;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class LookUpDataReq {
|
||||
|
||||
@NotNull
|
||||
private Long id;
|
||||
|
||||
private Long lookUpDataId;
|
||||
|
||||
private String value;
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
package net.gepafin.tendermanagement.model.request;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class UpdateCallRequestStep1 {
|
||||
|
||||
|
||||
private String name;
|
||||
|
||||
|
||||
private String descriptionShort;
|
||||
|
||||
|
||||
private String descriptionLong;
|
||||
|
||||
|
||||
private LocalDateTime startDate;
|
||||
|
||||
|
||||
private LocalDateTime endDate;
|
||||
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
|
||||
private BigDecimal amountMax;
|
||||
|
||||
|
||||
private List<LookUpDataReq> aimedTo;
|
||||
|
||||
|
||||
private String documentationRequested;
|
||||
|
||||
private Boolean confidi;
|
||||
|
||||
private List<FaqReq> faq;
|
||||
|
||||
}
|
||||
@@ -1,14 +1,13 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.CallTypeEnum;
|
||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class CreateCallResponseBean {
|
||||
public class CallDetailsResponseBean {
|
||||
|
||||
private Long id;
|
||||
|
||||
@@ -20,7 +19,7 @@ public class CreateCallResponseBean {
|
||||
|
||||
private List<LocalDateTime> dates;
|
||||
|
||||
private CallTypeEnum status;
|
||||
private CallStatusEnum status;
|
||||
|
||||
private Long regionId;
|
||||
|
||||
@@ -54,7 +53,5 @@ public class CreateCallResponseBean {
|
||||
|
||||
private List<LookUpDataResponse> checkList;
|
||||
|
||||
private String currentStep;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package net.gepafin.tendermanagement.model.response;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import lombok.Data;
|
||||
import net.gepafin.tendermanagement.enums.CallStatusEnum;
|
||||
|
||||
@Data
|
||||
public class CallResponse {
|
||||
|
||||
private Long id;
|
||||
|
||||
private String name;
|
||||
|
||||
private String descriptionShort;
|
||||
|
||||
private String descriptionLong;
|
||||
|
||||
private LocalDateTime startDate;
|
||||
|
||||
private LocalDateTime endDate;
|
||||
|
||||
private CallStatusEnum status;
|
||||
|
||||
private Long regionId;
|
||||
|
||||
private BigDecimal amount;
|
||||
|
||||
private BigDecimal amountMax;
|
||||
|
||||
private String contactInfo;
|
||||
|
||||
private String submissionMethod;
|
||||
|
||||
private Long threshold;
|
||||
|
||||
private String priorityArea;
|
||||
|
||||
private String documentationReqested;
|
||||
|
||||
private Boolean confidi;
|
||||
|
||||
private LocalDateTime createdDate;
|
||||
|
||||
private LocalDateTime updatedDate;
|
||||
|
||||
private List<LookUpDataResponse> aimedTo;
|
||||
|
||||
private List<EvaluationCriteriaResponseBean> criteria;
|
||||
|
||||
private List<DocumentResponseBean> docs;
|
||||
|
||||
private List<FaqResponseBean> faq;
|
||||
|
||||
private List<DocumentResponseBean> images;
|
||||
|
||||
private List<LookUpDataResponse> checkList;
|
||||
|
||||
private String currentStep;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,12 +5,7 @@ import net.gepafin.tendermanagement.model.BaseBean;
|
||||
|
||||
|
||||
@Data
|
||||
public class EvaluationCriteriaResponseBean extends BaseBean {
|
||||
|
||||
private String name;
|
||||
|
||||
private String description;
|
||||
|
||||
private Integer score;
|
||||
public class EvaluationCriteriaResponseBean extends LookUpDataResponse{
|
||||
|
||||
private Long score;
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.CallTargetAudienceChecklistEntity;
|
||||
@@ -10,5 +13,8 @@ import net.gepafin.tendermanagement.entities.CallTargetAudienceChecklistEntity;
|
||||
@Repository
|
||||
public interface CallTargetAudienceChecklistRepository extends JpaRepository<CallTargetAudienceChecklistEntity,Long> {
|
||||
|
||||
List<CallTargetAudienceChecklistEntity> findByCallIdAndLookupDataType(Long id, String value);
|
||||
@Query("SELECT c FROM CallTargetAudienceChecklistEntity c WHERE c.id = :id AND c.isDeleted = false")
|
||||
Optional<CallTargetAudienceChecklistEntity> findById(@Param("id") Long id);
|
||||
|
||||
List<CallTargetAudienceChecklistEntity> findByCallIdAndLookupDataTypeAndIsDeletedFalse(Long id, String type);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,23 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
import net.gepafin.tendermanagement.entities.DocumentEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface DocumentRepository extends JpaRepository<DocumentEntity, Long> {
|
||||
|
||||
@Query("SELECT d FROM DocumentEntity d WHERE d.id = :id AND d.isDeleted = false")
|
||||
Optional<DocumentEntity> findById(@Param("id") Long id);
|
||||
|
||||
List<DocumentEntity> findByCallIdAndTypeAndIsDeletedFalse(Long callId, String type);
|
||||
|
||||
Optional<DocumentEntity> findByIdAndCallIdAndIsDeletedFalse(Long id, Long callId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.EvaluationCriteriaEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface EvaluationCriteriaRepository extends JpaRepository<EvaluationCriteriaEntity, Long> {
|
||||
@Query("SELECT ec FROM EvaluationCriteriaEntity ec WHERE ec.id = :id AND ec.isDeleted = false")
|
||||
Optional<EvaluationCriteriaEntity> findById(@Param("id") Long id);
|
||||
|
||||
List<EvaluationCriteriaEntity> findByCallIdAndLookupDataTypeAndIsDeletedFalse(Long callId, String type);
|
||||
}
|
||||
|
||||
@@ -3,10 +3,18 @@ package net.gepafin.tendermanagement.repositories;
|
||||
import net.gepafin.tendermanagement.entities.FaqEntity;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.jpa.repository.Query;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
@Repository
|
||||
public interface FaqRepository extends JpaRepository<FaqEntity, Long> {
|
||||
|
||||
List<FaqEntity> findByCallId(Long callId);
|
||||
@Query("SELECT f FROM FaqEntity f WHERE f.id = :id AND f.isDeleted = false")
|
||||
Optional<FaqEntity> findById(@Param("id") Long id);
|
||||
|
||||
List<FaqEntity> findByCallIdAndIsDeletedFalse(Long callId);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,12 @@ package net.gepafin.tendermanagement.repositories;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.LookUpDataEntity;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@Repository
|
||||
public interface LookUpDataRepository extends JpaRepository<LookUpDataEntity,Long> {
|
||||
List<LookUpDataEntity> findByType(String type);
|
||||
}
|
||||
|
||||
@@ -1,14 +1,26 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep1;
|
||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep2;
|
||||
import net.gepafin.tendermanagement.model.response.CreateCallResponseBean;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateCallRequestStep1;
|
||||
import net.gepafin.tendermanagement.model.response.CallDetailsResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.CallResponse;
|
||||
|
||||
public interface CallService {
|
||||
|
||||
CreateCallResponseBean createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest);
|
||||
CallResponse createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest);
|
||||
|
||||
CreateCallResponseBean createCallStep2(HttpServletRequest request, CreateCallRequestStep2 createCallRequest);
|
||||
CallResponse createCallStep2(HttpServletRequest request, Long callId, CreateCallRequestStep2 createCallRequest);
|
||||
|
||||
CallResponse updateCallStep1(HttpServletRequest request, Long callId, UpdateCallRequestStep1 updateCallRequest);
|
||||
|
||||
CallResponse getCallById (Long callId);
|
||||
|
||||
List<CallDetailsResponseBean> getAllCalls();
|
||||
|
||||
CallResponse validateCall(Long callId);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.LookUpDataEntity.LookUpDataTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.LookUpDataRequest;
|
||||
import net.gepafin.tendermanagement.model.response.LookUpDataResponseBean;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface LookUpDataService {
|
||||
|
||||
LookUpDataResponseBean createLookUpData(LookUpDataRequest lookUpDataReq);
|
||||
@@ -12,4 +15,6 @@ public interface LookUpDataService {
|
||||
LookUpDataResponseBean updateLookUpData(Long id, LookUpDataRequest lookUpDataReq);
|
||||
|
||||
void deleteLookUpData(Long id);
|
||||
|
||||
List<LookUpDataResponseBean> getLookUpDataByType(LookUpDataTypeEnum type);
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public interface RegionService {
|
||||
|
||||
RegionResponseBean updateRegion(Long regionId, RegionReq regionReq);
|
||||
|
||||
RegionEntity getRegionById(Long regionId);
|
||||
RegionResponseBean getRegionById(Long regionId);
|
||||
|
||||
void deleteRegion(Long regionId);
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@ public interface RoleService {
|
||||
|
||||
RoleResponseBean updateRole(Long roleId, RoleReq roleReq);
|
||||
|
||||
RoleEntity getRoleById(Long roleId);
|
||||
RoleResponseBean getRoleById(Long roleId);
|
||||
|
||||
void deleteRole(Long roleId);
|
||||
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
package net.gepafin.tendermanagement.service;
|
||||
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.model.request.LoginReq;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateUserReq;
|
||||
import net.gepafin.tendermanagement.model.request.UserReq;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||
@@ -18,6 +22,7 @@ public interface UserService {
|
||||
|
||||
JWTToken login(LoginReq loginReq);
|
||||
|
||||
UserEntity validateUser(Long userId);
|
||||
|
||||
String initiatePasswordReset(InitiatePasswordResetReq resetReq);
|
||||
|
||||
|
||||
@@ -5,11 +5,15 @@ import net.gepafin.tendermanagement.config.jwt.TokenProvider;
|
||||
import net.gepafin.tendermanagement.dao.CallDao;
|
||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep1;
|
||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep2;
|
||||
import net.gepafin.tendermanagement.model.response.CreateCallResponseBean;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateCallRequestStep1;
|
||||
import net.gepafin.tendermanagement.model.response.CallDetailsResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.CallResponse;
|
||||
import net.gepafin.tendermanagement.service.CallService;
|
||||
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.Map;
|
||||
|
||||
|
||||
@@ -23,14 +27,42 @@ public class CallServiceImpl implements CallService {
|
||||
private TokenProvider tokenProvider;
|
||||
|
||||
@Override
|
||||
public CreateCallResponseBean createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CallResponse createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest) {
|
||||
Map<String, Object> userInfo= tokenProvider.getUserInfoAndUserIdFromToken(request);
|
||||
return callDao.createCallStep1(createCallRequest, Long.parseLong(userInfo.get("userId").toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public CreateCallResponseBean createCallStep2(HttpServletRequest request, CreateCallRequestStep2 createCallRequest) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CallResponse createCallStep2(HttpServletRequest request, Long callId, CreateCallRequestStep2 createCallRequest) {
|
||||
Map<String, Object> userInfo= tokenProvider.getUserInfoAndUserIdFromToken(request);
|
||||
return callDao.createCallStep2(createCallRequest, Long.parseLong(userInfo.get("userId").toString()));
|
||||
return callDao.createCallStep2(callId, createCallRequest, Long.parseLong(userInfo.get("userId").toString()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CallResponse updateCallStep1(HttpServletRequest request, Long callId,
|
||||
UpdateCallRequestStep1 updateCallRequest) {
|
||||
Map<String, Object> userInfo= tokenProvider.getUserInfoAndUserIdFromToken(request);
|
||||
return callDao.updateCallStep1(callId, updateCallRequest, Long.parseLong(userInfo.get("userId").toString()));
|
||||
}
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public CallResponse getCallById(Long callId) {
|
||||
return callDao.getCallById(callId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public List<CallDetailsResponseBean> getAllCalls() {
|
||||
return callDao.getAllCalls();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CallResponse validateCall(Long callId) {
|
||||
return callDao.validateCall(callDao.validateCall(callId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import net.gepafin.tendermanagement.model.response.CallResponse;
|
||||
import net.gepafin.tendermanagement.util.FieldValidator;
|
||||
|
||||
public class CallValidatorServiceImpl {
|
||||
|
||||
public static void validateResponse(CallResponse response) {
|
||||
FieldValidator.create()
|
||||
.notNull(response.getId(), "id")
|
||||
.notNull(response.getName(), "name")
|
||||
.notNull(response.getDescriptionShort(), "descriptionShort")
|
||||
.notNull(response.getDescriptionLong(), "descriptionLong")
|
||||
.notNull(response.getStartDate(), "startDate")
|
||||
.notNull(response.getEndDate(), "endDate")
|
||||
.notNull(response.getStatus(), "status")
|
||||
.notNull(response.getRegionId(), "regionId")
|
||||
.notNull(response.getAmount(), "amount")
|
||||
.notNull(response.getAmountMax(), "amountMax")
|
||||
.notNull(response.getThreshold(), "threshold")
|
||||
.notNull(response.getDocumentationReqested(), "documentationReqested")
|
||||
.notEmpty(response.getAimedTo(), "aimedTo")
|
||||
.notEmpty(response.getCriteria(), "criteria")
|
||||
.notEmpty(response.getDocs(), "docs")
|
||||
.notEmpty(response.getFaq(), "faq")
|
||||
.notEmpty(response.getImages(), "images")
|
||||
.notEmpty(response.getCheckList(), "checkList")
|
||||
.validate();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,12 +1,15 @@
|
||||
package net.gepafin.tendermanagement.service.impl;
|
||||
|
||||
import net.gepafin.tendermanagement.dao.LookUpDataDao;
|
||||
import net.gepafin.tendermanagement.entities.LookUpDataEntity.LookUpDataTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.LookUpDataRequest;
|
||||
import net.gepafin.tendermanagement.model.response.LookUpDataResponseBean;
|
||||
import net.gepafin.tendermanagement.service.LookUpDataService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class LookUpDataServiceImpl implements LookUpDataService {
|
||||
|
||||
@@ -32,4 +35,8 @@ public class LookUpDataServiceImpl implements LookUpDataService {
|
||||
public void deleteLookUpData(Long id) {
|
||||
lookUpDataDao.deleteLookUpData(id);
|
||||
}
|
||||
@Override
|
||||
public List<LookUpDataResponseBean> getLookUpDataByType(LookUpDataTypeEnum type) {
|
||||
return lookUpDataDao.getLookUpDataByType(type);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,8 @@ package net.gepafin.tendermanagement.service.impl;
|
||||
import java.util.List;
|
||||
|
||||
import net.gepafin.tendermanagement.dao.RegionDao;
|
||||
import net.gepafin.tendermanagement.entities.RegionEntity;
|
||||
import net.gepafin.tendermanagement.model.request.RegionReq;
|
||||
import net.gepafin.tendermanagement.model.response.RegionResponseBean;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateRegionReq;
|
||||
import net.gepafin.tendermanagement.service.RegionService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -32,7 +30,7 @@ public class RegionServiceImpl implements RegionService {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public RegionEntity getRegionById(Long regionId) {
|
||||
public RegionResponseBean getRegionById(Long regionId) {
|
||||
return regionDao.getRegionById(regionId);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package net.gepafin.tendermanagement.service.impl;
|
||||
import java.util.List;
|
||||
|
||||
import net.gepafin.tendermanagement.dao.RoleDao;
|
||||
import net.gepafin.tendermanagement.entities.RoleEntity;
|
||||
import net.gepafin.tendermanagement.model.request.RoleReq;
|
||||
import net.gepafin.tendermanagement.model.response.RoleResponseBean;
|
||||
import net.gepafin.tendermanagement.service.RoleService;
|
||||
@@ -31,7 +30,7 @@ public class RoleServiceImpl implements RoleService {
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public RoleEntity getRoleById(Long roleId) {
|
||||
public RoleResponseBean getRoleById(Long roleId) {
|
||||
return roleDao.getRoleById(roleId);
|
||||
}
|
||||
|
||||
|
||||
@@ -3,9 +3,12 @@ package net.gepafin.tendermanagement.service.impl;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import net.gepafin.tendermanagement.dao.UserDao;
|
||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||
import net.gepafin.tendermanagement.model.request.LoginReq;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateUserReq;
|
||||
import net.gepafin.tendermanagement.model.request.UserReq;
|
||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||
import net.gepafin.tendermanagement.model.request.*;
|
||||
import net.gepafin.tendermanagement.model.response.LoginResponse;
|
||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||
import net.gepafin.tendermanagement.service.UserService;
|
||||
@@ -13,7 +16,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Service
|
||||
public class UserServiceImpl implements UserService {
|
||||
@@ -51,6 +53,11 @@ public class UserServiceImpl implements UserService {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserEntity validateUser(Long userId) {
|
||||
return userDao.validateUser(userId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String initiatePasswordReset(InitiatePasswordResetReq resetReq) {
|
||||
return userDao.initiatePasswordReset(resetReq);
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package net.gepafin.tendermanagement.util;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ValidationException;
|
||||
|
||||
public class FieldValidator {
|
||||
|
||||
private final List<String> errors = new ArrayList<>();
|
||||
|
||||
public static FieldValidator create() {
|
||||
return new FieldValidator();
|
||||
}
|
||||
|
||||
public FieldValidator notNull(Object object, String fieldName) {
|
||||
if (Objects.isNull(object)) {
|
||||
errors.add(MessageFormat.format(Translator.toLocale(GepafinConstant.FIELD_NOT_NULL), fieldName));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public FieldValidator notEmpty(List<?> list, String fieldName) {
|
||||
if (list == null || list.isEmpty()) {
|
||||
errors.add(MessageFormat.format(Translator.toLocale(GepafinConstant.FIELD_NOT_EMPTY), fieldName));
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public void validate() {
|
||||
if (!errors.isEmpty()) {
|
||||
throw new ValidationException(Status.VALIDATION_ERROR, errors);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package net.gepafin.tendermanagement.util;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class ObjectUtils {
|
||||
|
||||
public static <T> void setIfNotNull(Consumer<T> setter, T value) {
|
||||
if (value != null) {
|
||||
setter.accept(value);
|
||||
}
|
||||
}
|
||||
public static <T> void setIfUpdated(Supplier<T> getter, Consumer<T> setter, T newValue) {
|
||||
T currentValue = getter.get();
|
||||
if (newValue != null && !newValue.equals(currentValue)) {
|
||||
setter.accept(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,6 +10,8 @@ import org.slf4j.LoggerFactory;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Utils {
|
||||
@@ -69,4 +71,16 @@ public class Utils {
|
||||
return new String(decode, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
public static <T> void setIfNotNull(Consumer<T> setter, T value) {
|
||||
if (value != null) {
|
||||
setter.accept(value);
|
||||
}
|
||||
}
|
||||
public static <T> void setIfUpdated(Supplier<T> getter, Consumer<T> setter, T newValue) {
|
||||
T currentValue = getter.get();
|
||||
if (newValue != null && !newValue.equals(currentValue)) {
|
||||
setter.accept(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,17 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
@@ -9,15 +21,11 @@ import jakarta.servlet.http.HttpServletRequest;
|
||||
import jakarta.validation.Valid;
|
||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep1;
|
||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep2;
|
||||
import net.gepafin.tendermanagement.model.response.CreateCallResponseBean;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateCallRequestStep1;
|
||||
import net.gepafin.tendermanagement.model.response.CallDetailsResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.CallResponse;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
@Validated
|
||||
public interface CallApi {
|
||||
@@ -34,7 +42,7 @@ public interface CallApi {
|
||||
})
|
||||
@PostMapping(value = "/step1", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
||||
public ResponseEntity<Response<CreateCallResponseBean>> createCallStep1(HttpServletRequest request,
|
||||
public ResponseEntity<Response<CallResponse>> createCallStep1(HttpServletRequest request,
|
||||
@Parameter(description = "Call request object", required = true)
|
||||
@Valid @RequestBody CreateCallRequestStep1 createCallRequest);
|
||||
|
||||
@@ -48,10 +56,69 @@ public interface CallApi {
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@PostMapping(value = "/step2", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PutMapping(value = "/step2/{callId}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
||||
public ResponseEntity<Response<CreateCallResponseBean>> createCallStep2(HttpServletRequest request,
|
||||
@Parameter(description = "Call request object", required = true)
|
||||
@Valid @RequestBody CreateCallRequestStep2 createCallRequest);
|
||||
public ResponseEntity<Response<CallResponse>> createCallStep2(HttpServletRequest request,
|
||||
@Parameter(description = "The call id", required = true) @PathVariable("callId") Long callId,
|
||||
@Parameter(description = "Call request object", required = true) @Valid @RequestBody CreateCallRequestStep2 createCallRequest);
|
||||
|
||||
@Operation(summary = "Api to update call step 1",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@PutMapping(value = "/step1/{callId}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
||||
public ResponseEntity<Response<CallResponse>> updateCallStep1(HttpServletRequest request,
|
||||
@Parameter(description = "The call id", required = true) @PathVariable("callId") Long callId,
|
||||
@Parameter(description = "Call request object", required = true) @Valid @RequestBody UpdateCallRequestStep1 updateCallRequest);
|
||||
@Operation(summary = "Api to get call by id",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@GetMapping(value = "/{callId}",
|
||||
produces = { "application/json" })
|
||||
ResponseEntity<Response<CallResponse>> getCallById(
|
||||
@Parameter(description = "The call ID", required = true) @PathVariable("callId") Long callId);
|
||||
|
||||
|
||||
@Operation(summary = "Api to get all calls",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@GetMapping(value = "",
|
||||
produces = { "application/json" })
|
||||
ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls();
|
||||
|
||||
|
||||
@Operation(summary = "Api to validate call",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@PostMapping(value = "/validate/{callId}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
||||
public ResponseEntity<Response<CallResponse>> validateCall(HttpServletRequest request,
|
||||
@Parameter(description = "The call id", required = true) @PathVariable("callId") Long callId);
|
||||
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
public interface EvaluationCriteriaApi {
|
||||
|
||||
|
||||
@Operation(summary = "API to create evaluation criteria",
|
||||
@Operation(summary = "Api to create evaluation criteria",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@@ -28,12 +28,12 @@ public interface EvaluationCriteriaApi {
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@PostMapping(value = "/criteria", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PostMapping(value = "", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Response<EvaluationCriteriaResponseBean>> createEvaluationCriteria(HttpServletRequest request,
|
||||
@Parameter(description = "Evaluation criteria request object", required = true)
|
||||
@Valid @RequestBody EvaluationCriteriaRequest createCallRequest);
|
||||
|
||||
@Operation(summary = "API to get evaluation criteria by id",
|
||||
@Operation(summary = "Api to get evaluation criteria by id",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@@ -41,7 +41,7 @@ public interface EvaluationCriteriaApi {
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@GetMapping(value = "/criteria/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Response<EvaluationCriteriaResponseBean>> getEvaluationCriteriaById(HttpServletRequest request,
|
||||
@Parameter(description = "evaluation criteria id", required = true)
|
||||
@PathVariable Long id);
|
||||
@@ -56,7 +56,7 @@ public interface EvaluationCriteriaApi {
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@PutMapping(value = "/criteria/{id}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
@PutMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Response<EvaluationCriteriaResponseBean>> updateEvaluationCriteria(HttpServletRequest request,
|
||||
@Parameter(description = "evaluation criteria id", required = true)
|
||||
@PathVariable Long id,
|
||||
@@ -71,7 +71,7 @@ public interface EvaluationCriteriaApi {
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) }))
|
||||
})
|
||||
@DeleteMapping(value = "/criteria/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
@DeleteMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Void> deleteEvaluationCriteria(HttpServletRequest request,
|
||||
@Parameter(description = "evaluation criteria id", required = true)
|
||||
@PathVariable Long id);
|
||||
|
||||
@@ -4,48 +4,78 @@ import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.media.Content;
|
||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||
import net.gepafin.tendermanagement.entities.LookUpDataEntity.LookUpDataTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.LookUpDataRequest;
|
||||
import net.gepafin.tendermanagement.model.response.LookUpDataResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.ErrorConstants;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
public interface LookUpDataApi {
|
||||
|
||||
@Operation(summary = "API to create LookUp Data",
|
||||
@Operation(summary = "Api to create LookUp Data",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "201", description = "Created"),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Bad Request\" }"))),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Not Found\" }")))
|
||||
})
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
|
||||
@PostMapping(value = "", consumes = "application/json", produces = "application/json")
|
||||
ResponseEntity<Response<LookUpDataResponseBean>> createLookUpData(HttpServletRequest request, @Valid @RequestBody LookUpDataRequest lookUpDataReq);
|
||||
|
||||
@Operation(summary = "API to get LookUp Data by id",
|
||||
@Operation(summary = "Api to get LookUp Data by id",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Not Found\" }")))
|
||||
})
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
|
||||
@GetMapping(value = "/{id}", produces = "application/json")
|
||||
ResponseEntity<Response<LookUpDataResponseBean>> getLookUpDataById(HttpServletRequest request, @PathVariable Long id);
|
||||
|
||||
@Operation(summary = "API to update LookUp Data",
|
||||
@Operation(summary = "Api to update LookUp Data",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Bad Request\" }"))),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Not Found\" }")))
|
||||
})
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
|
||||
@PutMapping(value = "/{id}", consumes = "application/json", produces = "application/json")
|
||||
ResponseEntity<Response<LookUpDataResponseBean>> updateLookUpData(HttpServletRequest request, @PathVariable Long id, @Valid @RequestBody LookUpDataRequest lookUpDataReq);
|
||||
|
||||
@Operation(summary = "API to delete LookUp Data",
|
||||
@Operation(summary = "Api to delete LookUp Data",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "204", description = "No Content"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Not Found\" }")))
|
||||
})
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
|
||||
@DeleteMapping(value = "/{id}")
|
||||
ResponseEntity<Response<Void>> deleteLookUpData(HttpServletRequest request, @PathVariable Long id);
|
||||
|
||||
@Operation(summary = "Api to get LookUp Data by type",
|
||||
responses = {
|
||||
@ApiResponse(responseCode = "200", description = "OK"),
|
||||
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE)})),
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
|
||||
@GetMapping(value = "/type", produces = "application/json")
|
||||
ResponseEntity<Response<List<LookUpDataResponseBean>>> getLookUpDataByType(HttpServletRequest request, @RequestParam LookUpDataTypeEnum type);
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public interface RegionApi {
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@GetMapping(value = "/{regionId}", produces = "application/json")
|
||||
ResponseEntity<Response<RegionEntity>> getRegionById(
|
||||
ResponseEntity<Response<RegionResponseBean>> getRegionById(
|
||||
@Parameter(description = "The region id", required = true) @PathVariable("regionId") Long regionId);
|
||||
|
||||
@Operation(summary = "Api to get all regions",
|
||||
|
||||
@@ -62,7 +62,7 @@ public interface RoleApi {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) })) })
|
||||
@GetMapping(value = "/{roleId}",
|
||||
produces = { "application/json" })
|
||||
ResponseEntity<Response<RoleEntity>> getRoleById(
|
||||
ResponseEntity<Response<RoleResponseBean>> getRoleById(
|
||||
@Parameter(description = "The role ID", required = true) @PathVariable("roleId") Long roleId);
|
||||
|
||||
@Operation(summary = "Api to get all roles",
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api.errors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ValidationException extends CustomValidationException {
|
||||
|
||||
private final Status status;
|
||||
private static final long serialVersionUID = 1L;
|
||||
private final List<String> errors;
|
||||
|
||||
public ValidationException(Status status, List<String> errors) {
|
||||
super(status, errors.toString());
|
||||
this.errors = errors;
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
public List<String> getErrors() {
|
||||
return errors;
|
||||
}
|
||||
|
||||
public Status getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,15 +1,7 @@
|
||||
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep1;
|
||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep2;
|
||||
import net.gepafin.tendermanagement.model.response.CreateCallResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.CallService;
|
||||
import net.gepafin.tendermanagement.web.rest.api.CallApi;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -17,6 +9,19 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep1;
|
||||
import net.gepafin.tendermanagement.model.request.CreateCallRequestStep2;
|
||||
import net.gepafin.tendermanagement.model.request.UpdateCallRequestStep1;
|
||||
import net.gepafin.tendermanagement.model.response.CallDetailsResponseBean;
|
||||
import net.gepafin.tendermanagement.model.response.CallResponse;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
import net.gepafin.tendermanagement.service.CallService;
|
||||
import net.gepafin.tendermanagement.web.rest.api.CallApi;
|
||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/call}")
|
||||
@@ -28,17 +33,49 @@ public class CallApiController implements CallApi {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
public ResponseEntity<Response<CreateCallResponseBean>> createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest) {
|
||||
CreateCallResponseBean createCallResponseBean = callService.createCallStep1(request, createCallRequest);
|
||||
public ResponseEntity<Response<CallResponse>> createCallStep1(HttpServletRequest request, CreateCallRequestStep1 createCallRequest) {
|
||||
CallResponse createCallResponseBean = callService.createCallStep1(request, createCallRequest);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<>(createCallResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_CREATED_SUCCESSFULLY_MSG)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
public ResponseEntity<Response<CreateCallResponseBean>> createCallStep2(HttpServletRequest request, CreateCallRequestStep2 createCallRequest) {
|
||||
CreateCallResponseBean createCallResponseBean = callService.createCallStep2(request, createCallRequest);
|
||||
public ResponseEntity<Response<CallResponse>> createCallStep2(HttpServletRequest request, Long callId, CreateCallRequestStep2 createCallRequest) {
|
||||
CallResponse createCallResponseBean = callService.createCallStep2(request, callId, createCallRequest);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<>(createCallResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_CREATED_SUCCESSFULLY_MSG)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor=Exception.class)
|
||||
public ResponseEntity<Response<CallResponse>> updateCallStep1(HttpServletRequest request, Long callId, UpdateCallRequestStep1 updateCallRequest) {
|
||||
CallResponse createCallResponseBean = callService.updateCallStep1(request, callId, updateCallRequest);
|
||||
return ResponseEntity.status(HttpStatus.CREATED)
|
||||
.body(new Response<>(createCallResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_UPDATE_SUCCESSFULLY_MSG)));
|
||||
}
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ResponseEntity<Response<CallResponse>> getCallById(Long callId) {
|
||||
CallResponse createCallResponseBean = callService.getCallById(callId);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(createCallResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_FETCH_SUCCESS_MSG)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(readOnly = true)
|
||||
public ResponseEntity<Response<List<CallDetailsResponseBean>>> getAllCalls() {
|
||||
List<CallDetailsResponseBean> calls = callService.getAllCalls();
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(calls, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_FETCH_SUCCESS_MSG)));
|
||||
|
||||
}
|
||||
@Override
|
||||
public ResponseEntity<Response<CallResponse>> validateCall(HttpServletRequest request, Long callId) {
|
||||
CallResponse call = callService.validateCall(callId);
|
||||
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(call, Status.SUCCESS, Translator.toLocale(GepafinConstant.CALL_FETCH_SUCCESS_MSG)));
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/evaluation}")
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/evaluationCriteria}")
|
||||
public class EvaluationCriteriaApiController implements EvaluationCriteriaApi {
|
||||
|
||||
@Autowired
|
||||
|
||||
@@ -3,6 +3,7 @@ package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import net.gepafin.tendermanagement.config.Translator;
|
||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||
import net.gepafin.tendermanagement.entities.LookUpDataEntity.LookUpDataTypeEnum;
|
||||
import net.gepafin.tendermanagement.model.request.LookUpDataRequest;
|
||||
import net.gepafin.tendermanagement.model.response.LookUpDataResponseBean;
|
||||
import net.gepafin.tendermanagement.model.util.Response;
|
||||
@@ -15,8 +16,10 @@ import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/lookupdata}")
|
||||
@RequestMapping("${openapi.gepafin.base-path:/v1/lookUpData}")
|
||||
public class LookUpDataApiController implements LookUpDataApi {
|
||||
|
||||
@Autowired
|
||||
@@ -59,4 +62,15 @@ public class LookUpDataApiController implements LookUpDataApi {
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOOKUP_DATA_DELETED_SUCCESSFULLY)));
|
||||
}
|
||||
@Override
|
||||
public ResponseEntity<Response<List<LookUpDataResponseBean>>> getLookUpDataByType(HttpServletRequest request, LookUpDataTypeEnum type) {
|
||||
List<LookUpDataResponseBean> responseBean = lookUpDataService.getLookUpDataByType(type);
|
||||
if (responseBean != null) {
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<List<LookUpDataResponseBean>>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOOKUP_DATA_FETCHED_SUCCESSFULLY)));
|
||||
} else {
|
||||
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||
.body(new Response<List<LookUpDataResponseBean>>(responseBean, Status.NOT_FOUND, Translator.toLocale(GepafinConstant.LOOKUP_DATA_NOT_FOUND)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,10 +52,10 @@ public class RegionApiController implements RegionApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<RegionEntity>> getRegionById(
|
||||
public ResponseEntity<Response<RegionResponseBean>> getRegionById(
|
||||
@PathVariable("regionId") Long regionId) {
|
||||
log.info("Get Region by ID - Region ID: {}", regionId);
|
||||
RegionEntity region = regionService.getRegionById(regionId);
|
||||
RegionResponseBean region = regionService.getRegionById(regionId);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(region, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_REGION_SUCCESS_MSG)));
|
||||
}
|
||||
|
||||
@@ -57,11 +57,11 @@ public class RoleApiController implements RoleApi {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseEntity<Response<RoleEntity>> getRoleById(Long roleId) {
|
||||
public ResponseEntity<Response<RoleResponseBean>> getRoleById(Long roleId) {
|
||||
log.info("Get Role by ID - Role ID: {}", roleId);
|
||||
RoleEntity roleEntity = roleService.getRoleById(roleId);
|
||||
RoleResponseBean roleResponseBean = roleService.getRoleById(roleId);
|
||||
return ResponseEntity.status(HttpStatus.OK)
|
||||
.body(new Response<>(roleEntity, Status.SUCCESS, Translator.toLocale(GepafinConstant.ROLE_FETCH_SUCCESS_MSG)));
|
||||
.body(new Response<>(roleResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.ROLE_FETCH_SUCCESS_MSG)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -395,6 +395,45 @@
|
||||
<column name="country" value="Italy"/>
|
||||
</insert>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="27-08-2024_1" author="Rajesh Khore">
|
||||
<dropColumn tableName="EVALUATION_CRITERIA"
|
||||
columnName="name" />
|
||||
<dropColumn tableName="EVALUATION_CRITERIA"
|
||||
columnName="description" />
|
||||
<addColumn tableName="EVALUATION_CRITERIA">
|
||||
<column name="lookup_data_id" type="INTEGER">
|
||||
<constraints nullable="false"
|
||||
foreignKeyName="fk_lookup_data_evaluation_criteria"
|
||||
references="lookup_data(id)" />
|
||||
</column>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
|
||||
<changeSet id="27-08-2024_2" author="Rajesh Khore">
|
||||
<addColumn tableName="FAQ">
|
||||
<column name="is_deleted" type="BOOLEAN" defaultValueBoolean="false">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
<addColumn tableName="CALL_TARGET_AUDIENCE_CHECKLIST">
|
||||
<column name="is_deleted" type="BOOLEAN" defaultValueBoolean="false">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
<addColumn tableName="EVALUATION_CRITERIA">
|
||||
<column name="is_deleted" type="BOOLEAN" defaultValueBoolean="false">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
<addColumn tableName="DOCUMENT">
|
||||
<column name="is_deleted" type="BOOLEAN" defaultValueBoolean="false">
|
||||
<constraints nullable="false"/>
|
||||
</column>
|
||||
</addColumn>
|
||||
</changeSet>
|
||||
|
||||
<changeSet id="23-08-2024_1" author="Harish Bagora">
|
||||
<addColumn tableName="gepafin_user">
|
||||
<column name="reset_password_token" type="VARCHAR(255)">
|
||||
|
||||
@@ -45,8 +45,12 @@ document.not.found=Document not found.
|
||||
document.id.not.found=Document ID not found.
|
||||
call.created.successfully=Call created successfully.
|
||||
call.invalid.date=Invalid start or end date.
|
||||
call.not.found=Call not dound.
|
||||
call.update.successfully=Call updated successfully.
|
||||
call.fetch.success=Call details fetched successfully.
|
||||
call.not.found=Call not found.
|
||||
score.not.null=Score cannot be null or cannot be zero.
|
||||
field.not.null={0} cannot be null.
|
||||
field.not.empty={0} cannot be empty.
|
||||
|
||||
# Login-related messages
|
||||
login.successfully=Login successfully.
|
||||
|
||||
@@ -44,8 +44,12 @@ file.deleted.successfully=File eliminato con successo.
|
||||
document.not.found=Documento non trovato.
|
||||
document.id.not.found=ID documento non trovato.
|
||||
call.invalid.date=Data di inizio o fine non valida.
|
||||
call.update.successfully=Chiamata aggiornata con successo.
|
||||
call.fetch.success=Dettagli della chiamata recuperati con successo.
|
||||
call.not.found=Chiamata non trovata.
|
||||
score.not.null=Il punteggio non pu� essere nullo o zero.
|
||||
field.not.null={0} non può essere nullo.
|
||||
field.not.empty=la {0} non può essere vuota.
|
||||
|
||||
# Login-related messages
|
||||
login.successfully=Accesso effettuato con successo.
|
||||
|
||||
Reference in New Issue
Block a user