resolved conflicts
This commit is contained in:
@@ -54,7 +54,7 @@ public class SecurityConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
MvcRequestMatcher.Builder mvc(HandlerMappingIntrospector introspector) {
|
public MvcRequestMatcher.Builder mvc(HandlerMappingIntrospector introspector) {
|
||||||
return new MvcRequestMatcher.Builder(introspector);
|
return new MvcRequestMatcher.Builder(introspector);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -87,6 +87,7 @@ public class SecurityConfig {
|
|||||||
return new CorsFilter(source);
|
return new CorsFilter(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public SecurityFilterChain securityFilterChain(HttpSecurity http, MvcRequestMatcher.Builder mvc) throws Exception {
|
public SecurityFilterChain securityFilterChain(HttpSecurity http, MvcRequestMatcher.Builder mvc) throws Exception {
|
||||||
http
|
http
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public class TokenProvider {
|
|||||||
|
|
||||||
public static final String INVALID_USER = "invalid_user";
|
public static final String INVALID_USER = "invalid_user";
|
||||||
static final String AUTH_SECRET = "X-Api-Secret";
|
static final String AUTH_SECRET = "X-Api-Secret";
|
||||||
|
private final Set<String> invalidatedTokens = new HashSet<>();
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
@@ -113,6 +114,10 @@ public class TokenProvider {
|
|||||||
|
|
||||||
public boolean validateToken(String authToken) {
|
public boolean validateToken(String authToken) {
|
||||||
try {
|
try {
|
||||||
|
if (isTokenInvalid(authToken)) {
|
||||||
|
log.warn("Token is invalidated.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Jwts.parserBuilder()
|
Jwts.parserBuilder()
|
||||||
.setSigningKey(key)
|
.setSigningKey(key)
|
||||||
.build()
|
.build()
|
||||||
@@ -124,6 +129,15 @@ public class TokenProvider {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void invalidateToken(String token) {
|
||||||
|
invalidatedTokens.add(token);
|
||||||
|
log.info("Token invalidated: {}", token);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTokenInvalid(String token) {
|
||||||
|
return invalidatedTokens.contains(token);
|
||||||
|
}
|
||||||
public Map<String, Object> getUserInfoAndUserIdFromToken(HttpServletRequest request) {
|
public Map<String, Object> getUserInfoAndUserIdFromToken(HttpServletRequest request) {
|
||||||
Map<String, Object> userInfo = new HashMap<>();
|
Map<String, Object> userInfo = new HashMap<>();
|
||||||
String authSecretHeader=request.getHeader(AUTH_SECRET);
|
String authSecretHeader=request.getHeader(AUTH_SECRET);
|
||||||
@@ -196,4 +210,12 @@ public class TokenProvider {
|
|||||||
Claims claims = Jwts.parser().setSigningKey(key).parseClaimsJws(token).getBody();
|
Claims claims = Jwts.parser().setSigningKey(key).parseClaimsJws(token).getBody();
|
||||||
return claims.getSubject();
|
return claims.getSubject();
|
||||||
}
|
}
|
||||||
|
public String extractTokenFromRequest(HttpServletRequest request) {
|
||||||
|
String bearerToken = request.getHeader("Authorization");
|
||||||
|
if (bearerToken != null && bearerToken.startsWith("Bearer ")) {
|
||||||
|
return bearerToken.substring(7); // Remove "Bearer " prefix
|
||||||
|
}
|
||||||
|
return null; // Return null if token is not found or not in Bearer format
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,5 +49,31 @@ public class GepafinConstant {
|
|||||||
public static final String CALL_NOT_FOUND = "call.not.found";
|
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 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 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";
|
||||||
|
public static final String FAQ_FETCHED_SUCCESSFULLY = "faq.fetched.successfully";
|
||||||
|
public static final String FAQ_UPDATED_SUCCESSFULLY = "faq.updated.successfully";
|
||||||
|
public static final String FAQ_DELETED_SUCCESSFULLY = "faq.deleted.successfully";
|
||||||
|
public static final String LOOKUP_DATA_NOT_FOUND = "lookupdata.not.found";
|
||||||
|
public static final String LOOKUP_DATA_CREATED_SUCCESSFULLY = "lookupdata.created.successfully";
|
||||||
|
public static final String LOOKUP_DATA_FETCHED_SUCCESSFULLY = "lookupdata.fetched.successfully";
|
||||||
|
public static final String LOOKUP_DATA_UPDATED_SUCCESSFULLY = "lookupdata.updated.successfully";
|
||||||
|
public static final String LOOKUP_DATA_DELETED_SUCCESSFULLY = "lookupdata.deleted.successfully";
|
||||||
|
public static final String DOCUMENT_UPDATED_SUCCESSFULLY = "document.updated.successfully";
|
||||||
|
public static final String DOCUMENT_FETCHED_SUCCESSFULLY = "document.fetched.successfully";
|
||||||
|
public static final String RESET_PASSWORD_INITIATED = "password.reset.initiated";
|
||||||
|
public static final String PASSWORD_RESET_SUCCESS = "password.reset.success";
|
||||||
|
public static final String INVALID_TOKEN_MSG = "invalid.token.msg";
|
||||||
|
public static final String CURRENT_PASSWORD_INCORRECT = "current.password.incorrect";
|
||||||
|
|
||||||
|
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";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,6 +157,21 @@ public class CallDao {
|
|||||||
}
|
}
|
||||||
return criteriaEntity;
|
return criteriaEntity;
|
||||||
}
|
}
|
||||||
|
// public List<EvaluationCriteriaEntity> convertListOfEvaluationCriteriaReqToEvaluationCriteriaEntities(List<EvaluationCriteriaReq> criteriaReqList, CallEntity callEntity) {
|
||||||
|
// List<EvaluationCriteriaEntity> evaluationCriteriaEntities = criteriaReqList.stream().map(req -> convertToEvaluationCriteriaEntity(req, callEntity)).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());
|
||||||
|
// criteriaEntity.setCall(callEntity);
|
||||||
|
// return criteriaEntity;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
public List<DocumentEntity> convertToDocumentEntities(List<DocumentReq> documentReqList, CallEntity callEntity,
|
public List<DocumentEntity> convertToDocumentEntities(List<DocumentReq> documentReqList, CallEntity callEntity,
|
||||||
@@ -202,11 +217,211 @@ public class CallDao {
|
|||||||
return faqEntities;
|
return faqEntities;
|
||||||
}
|
}
|
||||||
|
|
||||||
private FaqEntity convertToFaqEntity(FaqReq faqReq, CallEntity callEntity, Long userId) {
|
// 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());
|
||||||
|
// faqRepository.saveAll(faqEntities);
|
||||||
|
// return faqEntities;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public FaqEntity convertToFaqEntity(FaqReq faqReq, CallEntity callEntity, Long userId) {
|
||||||
|
// FaqEntity faqEntity = new FaqEntity();
|
||||||
|
// validateFaqEntity(faqReq.getQuestion());
|
||||||
|
// UserEntity userEntity = userService.validateUser(userId);
|
||||||
|
// faqEntity.setUser(userEntity);
|
||||||
|
// faqEntity.setIsVisible(true);
|
||||||
|
// if(faqReq.getIsVisible()!=null){
|
||||||
|
// faqEntity.setIsVisible(faqReq.getIsVisible());
|
||||||
|
// }
|
||||||
|
// faqEntity.setQuestionShort(faqReq.getQuestionShort());
|
||||||
|
// faqEntity.setQuestion(faqReq.getQuestion());
|
||||||
|
// if(faqReq.getResponse()!=null ||faqReq.getResponseShort()!=null){
|
||||||
|
// faqEntity.setResponseDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||||
|
// }
|
||||||
|
// 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));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void validateDocumentEntity(Long documentId,String name) {
|
||||||
|
// if(documentId==null){
|
||||||
|
// 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) {
|
||||||
|
// 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));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public void validateCallEntity(CreateCallRequestStep1 createCallRequest) {
|
||||||
|
// if (createCallRequest.getRegionId() == null) {
|
||||||
|
// 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.getStartDate().toLocalDate().isBefore(LocalDate.now()) || createCallRequest.getEndDate().toLocalDate().isBefore(LocalDate.now())) {
|
||||||
|
// throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_DATE_MSG));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// public CreateCallResponseBean convertToCallResponseBean(CallEntity callEntity) {
|
||||||
|
// CreateCallResponseBean createCallResponseBean = new CreateCallResponseBean();
|
||||||
|
// createCallResponseBean.setId(callEntity.getId());
|
||||||
|
// createCallResponseBean.setName(callEntity.getName());
|
||||||
|
// createCallResponseBean.setDates(List.of(callEntity.getStartDate(), callEntity.getEndDate()));
|
||||||
|
// createCallResponseBean.setDescriptionShort(callEntity.getDescriptionShort());
|
||||||
|
// createCallResponseBean.setDescriptionLong(callEntity.getDescriptionLong());
|
||||||
|
// createCallResponseBean.setStatus(CallTypeEnum.valueOf(callEntity.getStatus()));
|
||||||
|
// createCallResponseBean.setRegionId(callEntity.getRegion().getId());
|
||||||
|
// createCallResponseBean.setAmount(callEntity.getAmount());
|
||||||
|
// createCallResponseBean.setAmountMax(callEntity.getAmountMax());
|
||||||
|
// createCallResponseBean.setContactInfo(callEntity.getContactInfo());
|
||||||
|
// createCallResponseBean.setSubmissionMethod(callEntity.getSubmissionMethod());
|
||||||
|
// createCallResponseBean.setThreshold(callEntity.getThreshold());
|
||||||
|
// createCallResponseBean.setDocumentationReqested(callEntity.getDocumentationRequested());
|
||||||
|
// createCallResponseBean.setPriorityArea(callEntity.getPriorityArea());
|
||||||
|
// 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.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());
|
||||||
|
// responseBean.setName(entity.getFileName());
|
||||||
|
// responseBean.setDescription(entity.getDescription());
|
||||||
|
// responseBean.setFilePath(entity.getFilePath());
|
||||||
|
// responseBean.setCreatedDate(entity.getCreatedDate());
|
||||||
|
// responseBean.setUpdatedDate(entity.getUpdatedDate());
|
||||||
|
// return responseBean;
|
||||||
|
// }
|
||||||
|
// public FaqResponseBean convertToFaqResponseBean(FaqEntity entity) {
|
||||||
|
// FaqResponseBean responseBean = new FaqResponseBean();
|
||||||
|
// responseBean.setId(entity.getId());
|
||||||
|
// responseBean.setQuestionShort(entity.getQuestionShort());
|
||||||
|
// responseBean.setResponseShort(entity.getResponseShort());
|
||||||
|
// responseBean.setResponse(entity.getResponse());
|
||||||
|
// responseBean.setQuestion(entity.getQuestion());
|
||||||
|
// responseBean.setUserId(entity.getUser().getId());
|
||||||
|
// responseBean.setIsVisible(entity.getIsVisible());
|
||||||
|
// responseBean.setCreatedDate(entity.getCreatedDate());
|
||||||
|
// responseBean.setUpdatedDate(entity.getUpdatedDate());
|
||||||
|
// return responseBean;
|
||||||
|
// }
|
||||||
|
// public CreateCallResponseBean assembleCreateCallResponseBean(
|
||||||
|
// CallEntity callEntity,
|
||||||
|
// List<EvaluationCriteriaEntity> evaluationCriteriaEntities,
|
||||||
|
// List<DocumentEntity> documentEntities,
|
||||||
|
// List<FaqEntity> faqEntities,List<DocumentEntity> images) {
|
||||||
|
//
|
||||||
|
// CreateCallResponseBean callResponseBean = convertToCallResponseBean(callEntity);
|
||||||
|
//
|
||||||
|
// List<EvaluationCriteriaResponseBean> evaluationCriteriaResponseBeans = evaluationCriteriaEntities.stream()
|
||||||
|
// .map(this::convertToEvaluationCriteriaResponseBean)
|
||||||
|
// .collect(Collectors.toList());
|
||||||
|
//
|
||||||
|
// List<DocumentResponseBean> documentResponseBeans = documentEntities.stream()
|
||||||
|
// .map(this::convertToDocumentResponseBean)
|
||||||
|
// .collect(Collectors.toList());
|
||||||
|
//
|
||||||
|
// List<FaqResponseBean> faqResponseBeans = faqEntities.stream()
|
||||||
|
// .map(this::convertToFaqResponseBean)
|
||||||
|
// .collect(Collectors.toList());
|
||||||
|
//
|
||||||
|
// List<DocumentResponseBean> imagesResponseBean = images.stream()
|
||||||
|
// .map(this::convertToDocumentResponseBean)
|
||||||
|
// .collect(Collectors.toList());
|
||||||
|
// CreateCallResponseBean 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);
|
||||||
|
//
|
||||||
|
// return createCallTargetAudienceCheckList(callEntity, 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);
|
||||||
|
// lookUpDataResponses.add(convertToLookUpDataResponseBean(callTargetAudienceChecklistEntity));
|
||||||
|
// }
|
||||||
|
// return lookUpDataResponses;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// 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.findById(req.getLookUpDataId())
|
||||||
|
// .orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.LOOK_UP_DATA_NOT_VALID_MSG)));
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// 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());
|
||||||
|
// return lookUpDataResponse;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// public CreateCallResponseBean createCallStep2(CreateCallRequestStep2 createCallRequest, Long userId) {
|
||||||
|
// CreateCallResponseBean createCallResponseBean = null;
|
||||||
|
// CallEntity callEntity = callRepository.findById(createCallRequest.getCallId())
|
||||||
|
// .orElseThrow(() -> new CustomValidationException(Status.VALIDATION_ERROR,
|
||||||
|
// Translator.toLocale(GepafinConstant.NAME_NOT_EMPTY_MSG)));
|
||||||
|
|
||||||
|
public FaqEntity convertToFaqEntity(FaqReq faqReq, CallEntity callEntity, Long userId) {
|
||||||
FaqEntity faqEntity = new FaqEntity();
|
FaqEntity faqEntity = new FaqEntity();
|
||||||
validateFaqEntity(faqReq.getQuestion());
|
validateFaqEntity(faqReq.getQuestion());
|
||||||
UserEntity userEntity = userService.validateUser(userId);
|
UserEntity userEntity = userService.validateUser(userId);
|
||||||
|
|
||||||
faqEntity.setUser(userEntity);
|
faqEntity.setUser(userEntity);
|
||||||
faqEntity.setIsVisible(true);
|
faqEntity.setIsVisible(true);
|
||||||
if (faqReq.getIsVisible() != null) {
|
if (faqReq.getIsVisible() != null) {
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
package net.gepafin.tendermanagement.dao;
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
@@ -13,14 +12,20 @@ import org.springframework.web.multipart.MultipartFile;
|
|||||||
|
|
||||||
import net.gepafin.tendermanagement.config.Translator;
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
|
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||||
import net.gepafin.tendermanagement.entities.DocumentEntity;
|
import net.gepafin.tendermanagement.entities.DocumentEntity;
|
||||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.repositories.CallRepository;
|
||||||
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
import net.gepafin.tendermanagement.repositories.DocumentRepository;
|
||||||
import net.gepafin.tendermanagement.service.AmazonS3Service;
|
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.ResourceNotFoundException;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
public class DocumentDao {
|
public class DocumentDao {
|
||||||
|
|
||||||
@@ -33,22 +38,24 @@ public class DocumentDao {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private CallDao callDao;
|
private CallDao callDao;
|
||||||
|
|
||||||
public List<DocumentResponseBean> uploadFiles(List<MultipartFile> files, DocumentTypeEnum fileType) {
|
@Autowired
|
||||||
List<DocumentEntity> documentEntities = new ArrayList<>();
|
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)));
|
||||||
for (MultipartFile file : files) {
|
for (MultipartFile file : files) {
|
||||||
try {
|
try {
|
||||||
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
uploadFileOnAmazonS3 result = uploadFileOnAmazonS3(file);
|
||||||
String fileName = StringUtils.cleanPath(file.getOriginalFilename());
|
if(result!=null) {
|
||||||
String firstNameContain = fileName.substring(0, fileName.lastIndexOf('.'));
|
|
||||||
fileName = (firstNameContain + "." + extension);
|
|
||||||
String filepath = amazonS3Service.upload(fileName,file);
|
|
||||||
DocumentEntity documentEntity = new DocumentEntity();
|
DocumentEntity documentEntity = new DocumentEntity();
|
||||||
documentEntity.setFileName(fileName);
|
documentEntity.setFileName(result.fileName());
|
||||||
|
documentEntity.setCall(callEntity);
|
||||||
documentEntity.setType(fileType.getValue());
|
documentEntity.setType(fileType.getValue());
|
||||||
documentEntity.setFilePath(filepath);
|
documentEntity.setFilePath(result.filepath());
|
||||||
documentEntity.setIsDeleted(false);
|
documentEntity.setIsDeleted(false);
|
||||||
documentEntities.add(documentEntity);
|
documentEntities.add(documentEntity);
|
||||||
|
}
|
||||||
} catch (IOException e) {}
|
} catch (IOException e) {}
|
||||||
}
|
}
|
||||||
documentRepository.saveAll(documentEntities);
|
documentRepository.saveAll(documentEntities);
|
||||||
@@ -57,13 +64,62 @@ public class DocumentDao {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteFile(Long documentId) {
|
private uploadFileOnAmazonS3 uploadFileOnAmazonS3(MultipartFile file) throws IOException {
|
||||||
DocumentEntity documentEntity = documentRepository.findById(documentId)
|
String extension = FilenameUtils.getExtension(file.getOriginalFilename());
|
||||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
String fileName = StringUtils.cleanPath(file.getOriginalFilename());
|
||||||
Translator.toLocale(GepafinConstant.DOCUMENT_NOT_FOUND)));
|
String firstNameContain = fileName.substring(0, fileName.lastIndexOf('.'));
|
||||||
|
fileName = (firstNameContain + "." + extension);
|
||||||
documentEntity.setIsDeleted(true);
|
String filepath = amazonS3Service.upload(fileName, file);
|
||||||
documentRepository.save(documentEntity);
|
uploadFileOnAmazonS3 result = new uploadFileOnAmazonS3(fileName, filepath);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private record uploadFileOnAmazonS3(String fileName, String filepath) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteFile(Long documentId){
|
||||||
|
DocumentEntity documentEntity = getDocumentEntity(documentId);
|
||||||
|
String fileName= Utils.extractFileName(documentEntity.getFilePath());
|
||||||
|
deleteFileOnAmazonS3(fileName);
|
||||||
|
documentRepository.delete(documentEntity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private DocumentEntity deleteFileOnAmazonS3(String fileName) {
|
||||||
|
try {
|
||||||
|
amazonS3Service.delete(fileName);
|
||||||
|
}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));
|
||||||
|
}
|
||||||
|
return documentEntity.orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DocumentResponseBean updateDocument(Long documentId, MultipartFile file, DocumentTypeEnum documentTypeEnum){
|
||||||
|
DocumentEntity documentEntity = getDocumentEntity(documentId);
|
||||||
|
String fileName= Utils.extractFileName(documentEntity.getFilePath());
|
||||||
|
deleteFileOnAmazonS3(fileName);
|
||||||
|
uploadFileOnAmazonS3 result= null;
|
||||||
|
try {
|
||||||
|
result = uploadFileOnAmazonS3(file);
|
||||||
|
} catch (IOException e) {}
|
||||||
|
if(result!=null){
|
||||||
|
documentEntity.setFilePath(result.filepath);
|
||||||
|
documentEntity.setFileName(result.fileName);
|
||||||
|
documentEntity.setType(documentTypeEnum.getValue());
|
||||||
|
documentRepository.save(documentEntity);
|
||||||
|
}
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
return callDao.convertToDocumentResponseBean(documentEntity.orElse(null));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
@@ -0,0 +1,80 @@
|
|||||||
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
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;
|
||||||
|
import org.springframework.dao.EmptyResultDataAccessException;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class EvaluationCriteriaDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EvaluationCriteriaRepository evaluationCriteriaRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CallRepository callRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LookUpDataRepository lookUpDataRepository;
|
||||||
|
|
||||||
|
public EvaluationCriteriaResponseBean createEvaluationCriteria(EvaluationCriteriaRequest evaluationCriteriaRequest) {
|
||||||
|
EvaluationCriteriaEntity entity = convertEvaluationCriteriaRequestToEvaluationCriteriaEntity(evaluationCriteriaRequest);
|
||||||
|
return convertEvaluationCriteriaEntityEvaluationCriteriaToResponseBean(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private EvaluationCriteriaEntity convertEvaluationCriteriaRequestToEvaluationCriteriaEntity(EvaluationCriteriaRequest evaluationCriteriaRequest) {
|
||||||
|
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.setLookupData(looDataEntity);
|
||||||
|
entity.setScore(evaluationCriteriaRequest.getScore());
|
||||||
|
entity = evaluationCriteriaRepository.save(entity);
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EvaluationCriteriaResponseBean getEvaluationCriteriaById(Long 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 = evaluationCriteriaRepository.findById(id)
|
||||||
|
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_NOT_FOUND)));
|
||||||
|
entity = convertEvaluationCriteriaRequestToEvaluationCriteriaEntity(request);
|
||||||
|
return convertEvaluationCriteriaEntityEvaluationCriteriaToResponseBean(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteEvaluationCriteria(Long id) {
|
||||||
|
try {
|
||||||
|
evaluationCriteriaRepository.deleteById(id);
|
||||||
|
} catch (EmptyResultDataAccessException e) {
|
||||||
|
throw new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_NOT_FOUND));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private EvaluationCriteriaResponseBean convertEvaluationCriteriaEntityEvaluationCriteriaToResponseBean(EvaluationCriteriaEntity entity) {
|
||||||
|
EvaluationCriteriaResponseBean response = new EvaluationCriteriaResponseBean();
|
||||||
|
response.setId(entity.getId());
|
||||||
|
response.setScore(entity.getScore());
|
||||||
|
response.setCreatedDate(entity.getCreatedDate());
|
||||||
|
response.setUpdatedDate(entity.getUpdatedDate());
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
101
src/main/java/net/gepafin/tendermanagement/dao/FaqDao.java
Normal file
101
src/main/java/net/gepafin/tendermanagement/dao/FaqDao.java
Normal file
@@ -0,0 +1,101 @@
|
|||||||
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
|
import net.gepafin.tendermanagement.entities.CallEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.FaqEntity;
|
||||||
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
|
import net.gepafin.tendermanagement.model.request.FaqReq;
|
||||||
|
import net.gepafin.tendermanagement.model.response.FaqResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.repositories.CallRepository;
|
||||||
|
import net.gepafin.tendermanagement.repositories.FaqRepository;
|
||||||
|
import net.gepafin.tendermanagement.repositories.UserRepository;
|
||||||
|
import net.gepafin.tendermanagement.util.DateTimeUtil;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.ResourceNotFoundException;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class FaqDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FaqRepository faqRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private UserRepository userRepository;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CallDao callDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private CallRepository callRepository;
|
||||||
|
|
||||||
|
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)));
|
||||||
|
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)));
|
||||||
|
}
|
||||||
|
|
||||||
|
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)));
|
||||||
|
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)));
|
||||||
|
faqRepository.deleteById(entity.getId());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private FaqResponseBean convertFaqEntityToResponseBean(FaqEntity entity) {
|
||||||
|
FaqResponseBean response = new FaqResponseBean();
|
||||||
|
response.setId(entity.getId());
|
||||||
|
response.setUserId(entity.getUser().getId());
|
||||||
|
response.setIsVisible(entity.getIsVisible());
|
||||||
|
response.setUpdatedDate(entity.getUpdatedDate());
|
||||||
|
response.setCreatedDate(entity.getCreatedDate());
|
||||||
|
response.setQuestionShort(entity.getQuestionShort());
|
||||||
|
response.setQuestion(entity.getQuestion());
|
||||||
|
response.setResponseShort(entity.getResponseShort());
|
||||||
|
response.setResponse(entity.getResponse());
|
||||||
|
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)));
|
||||||
|
faqEntity.setUser(userEntity);
|
||||||
|
faqEntity.setIsVisible(true);
|
||||||
|
if (faqReq.getIsVisible() != null) {
|
||||||
|
faqEntity.setIsVisible(faqReq.getIsVisible());
|
||||||
|
}
|
||||||
|
faqEntity.setQuestionShort(faqReq.getQuestionShort());
|
||||||
|
faqEntity.setQuestion(faqReq.getQuestion());
|
||||||
|
if (faqReq.getResponse() != null || faqReq.getResponseShort() != null) {
|
||||||
|
faqEntity.setResponseDate(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||||
|
}
|
||||||
|
faqEntity.setResponseShort(faqReq.getResponseShort());
|
||||||
|
faqEntity.setResponse(faqReq.getResponse());
|
||||||
|
faqEntity.setCall(callEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.entities.LookUpDataEntity;
|
||||||
|
import net.gepafin.tendermanagement.model.request.LookUpDataRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.LookUpDataResponseBean;
|
||||||
|
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 net.gepafin.tendermanagement.config.Translator;
|
||||||
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class LookUpDataDao {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LookUpDataRepository lookUpDataRepository;
|
||||||
|
|
||||||
|
public LookUpDataResponseBean createLookUpData(LookUpDataRequest lookUpDataReq) {
|
||||||
|
LookUpDataEntity entity = convertLookUpDataReqToLookUpDataEntity(lookUpDataReq);
|
||||||
|
return convertLookUpDataEntityToResponseBean(entity);
|
||||||
|
}
|
||||||
|
private LookUpDataEntity convertLookUpDataReqToLookUpDataEntity(LookUpDataRequest lookUpDataReq) {
|
||||||
|
LookUpDataEntity entity = new LookUpDataEntity();
|
||||||
|
entity.setTitle(lookUpDataReq.getTitle());
|
||||||
|
entity.setType(lookUpDataReq.getType().getValue());
|
||||||
|
entity.setValue(lookUpDataReq.getValue());
|
||||||
|
lookUpDataRepository.save(entity);
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LookUpDataResponseBean getLookUpDataById(Long id) {
|
||||||
|
return lookUpDataRepository.findById(id)
|
||||||
|
.map(this::convertLookUpDataEntityToResponseBean)
|
||||||
|
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.LOOKUP_DATA_NOT_FOUND)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public LookUpDataResponseBean updateLookUpData(Long id, LookUpDataRequest lookUpDataReq) {
|
||||||
|
LookUpDataEntity entity = lookUpDataRepository.findById(id)
|
||||||
|
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.LOOKUP_DATA_NOT_FOUND)));
|
||||||
|
entity.setTitle(lookUpDataReq.getTitle());
|
||||||
|
entity.setType(lookUpDataReq.getType().getValue());
|
||||||
|
entity.setValue(lookUpDataReq.getValue());
|
||||||
|
lookUpDataRepository.save(entity);
|
||||||
|
return convertLookUpDataEntityToResponseBean(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteLookUpData(Long id) {
|
||||||
|
LookUpDataEntity entity = lookUpDataRepository.findById(id)
|
||||||
|
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.LOOKUP_DATA_NOT_FOUND)));
|
||||||
|
lookUpDataRepository.deleteById(entity.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private LookUpDataResponseBean convertLookUpDataEntityToResponseBean(LookUpDataEntity entity) {
|
||||||
|
LookUpDataResponseBean response = new LookUpDataResponseBean();
|
||||||
|
response.setId(entity.getId());
|
||||||
|
response.setTitle(entity.getTitle());
|
||||||
|
response.setType(LookUpDataEntity.LookUpDataTypeEnum.valueOf(entity.getType()));
|
||||||
|
response.setValue(entity.getValue());
|
||||||
|
response.setCreatedDate(entity.getCreatedDate());
|
||||||
|
response.setUpdatedDate(entity.getUpdatedDate());
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
package net.gepafin.tendermanagement.dao;
|
package net.gepafin.tendermanagement.dao;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import net.gepafin.tendermanagement.config.Translator;
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.entities.RoleEntity;
|
import net.gepafin.tendermanagement.entities.RoleEntity;
|
||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.LoginReq;
|
import net.gepafin.tendermanagement.model.request.*;
|
||||||
import net.gepafin.tendermanagement.model.request.UpdateUserReq;
|
|
||||||
import net.gepafin.tendermanagement.model.request.UserReq;
|
|
||||||
import net.gepafin.tendermanagement.model.response.RoleResponseBean;
|
import net.gepafin.tendermanagement.model.response.RoleResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||||
@@ -21,6 +21,8 @@ import org.slf4j.LoggerFactory;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
import java.util.Base64;
|
||||||
|
|
||||||
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
import static net.gepafin.tendermanagement.util.Utils.setIfUpdated;
|
||||||
|
|
||||||
@@ -151,4 +153,82 @@ public class UserDao {
|
|||||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
||||||
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG)));
|
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG)));
|
||||||
}
|
}
|
||||||
|
public String generateSecureToken() {
|
||||||
|
SecureRandom secureRandom = new SecureRandom();
|
||||||
|
byte[] tokenBytes = new byte[24];
|
||||||
|
secureRandom.nextBytes(tokenBytes);
|
||||||
|
String token = Base64.getUrlEncoder().withoutPadding().encodeToString(tokenBytes);
|
||||||
|
log.debug("Generated secure token: {}", token);
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String initiatePasswordReset(InitiatePasswordResetReq resetReq) {
|
||||||
|
UserEntity user = userRepository.findByEmail(resetReq.getEmail());
|
||||||
|
if (user == null) {
|
||||||
|
log.info("Password reset attempt for non-existent user: {}", resetReq.getEmail());
|
||||||
|
throw new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG));
|
||||||
|
}
|
||||||
|
String token = generateSecureToken();
|
||||||
|
user.setResetPasswordToken(token);
|
||||||
|
userRepository.save(user);
|
||||||
|
log.info("Password reset token generated for user: {}", resetReq.getEmail());
|
||||||
|
return token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean resetPassword(ResetPasswordReq resetPasswordReq) {
|
||||||
|
UserEntity user = userRepository.findByEmail(resetPasswordReq.getEmail());
|
||||||
|
if (user == null) {
|
||||||
|
log.info("Password reset attempt for non-existent user: {}", resetPasswordReq.getEmail());
|
||||||
|
throw new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG));
|
||||||
|
}
|
||||||
|
if (!resetPasswordReq.getNewPassword().equals(resetPasswordReq.getConfirmPassword())) {
|
||||||
|
log.info("User creation failed: Passwords do not match for email {}", user.getEmail());
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.PASSWORD_DOESNT_MATCH));
|
||||||
|
}
|
||||||
|
String dbToken = user.getResetPasswordToken();
|
||||||
|
|
||||||
|
if (dbToken == null || !dbToken.equals(resetPasswordReq.getToken())) {
|
||||||
|
log.info("Invalid password reset token for user: {}", resetPasswordReq.getEmail());
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.INVALID_TOKEN_MSG));
|
||||||
|
}
|
||||||
|
|
||||||
|
user.setPassword(passwordEncoder.encode(resetPasswordReq.getNewPassword()));
|
||||||
|
user.setResetPasswordToken(null);
|
||||||
|
userRepository.save(user);
|
||||||
|
log.info("Password successfully reset for user: {}", resetPasswordReq.getEmail());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean changePassword(ChangePasswordRequest request) {
|
||||||
|
UserEntity user = userRepository.findByEmail(request.getEmail());
|
||||||
|
if (user == null) {
|
||||||
|
log.info("Password reset attempt for non-existent user: {}", request.getEmail());
|
||||||
|
throw new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG));
|
||||||
|
}
|
||||||
|
if (!passwordEncoder.matches(request.getPassword(), user.getPassword())) {
|
||||||
|
throw new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.CURRENT_PASSWORD_INCORRECT));
|
||||||
|
}
|
||||||
|
if (!request.getNewPassword().equals(request.getConfirmPassword())) {
|
||||||
|
log.info("User creation failed: Passwords do not match for email {}", user.getEmail());
|
||||||
|
throw new CustomValidationException(Status.VALIDATION_ERROR, Translator.toLocale(GepafinConstant.PASSWORD_DOESNT_MATCH));
|
||||||
|
}
|
||||||
|
user.setPassword(passwordEncoder.encode(request.getNewPassword()));
|
||||||
|
userRepository.save(user);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public void logout(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
authService.logout(request, response);
|
||||||
|
log.info("User successfully logged out.");
|
||||||
|
}
|
||||||
|
|
||||||
|
public UserResponseBean updateUserStatus(Long userId, UserStatusEnum statusReq) {
|
||||||
|
log.info("Updating status for user with ID: {}", userId);
|
||||||
|
UserEntity userEntity = userRepository.findById(userId)
|
||||||
|
.orElseThrow(() -> new ResourceNotFoundException(Status.NOT_FOUND, Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG)));
|
||||||
|
userEntity.setStatus(statusReq.getValue());
|
||||||
|
userEntity = userRepository.save(userEntity);
|
||||||
|
log.info("User status updated to {} for user ID: {}", statusReq, userId);
|
||||||
|
return convertUserEntityToUserResponse(userEntity);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,4 +58,6 @@ public class UserEntity extends BaseEntity {
|
|||||||
@Column(name = "COUNTRY", length = 50, nullable = true)
|
@Column(name = "COUNTRY", length = 50, nullable = true)
|
||||||
private String country;
|
private String country;
|
||||||
|
|
||||||
|
@Column(name = "RESET_PASSWORD_TOKEN", length = 255, nullable = true)
|
||||||
|
private String resetPasswordToken;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ChangePasswordRequest {
|
||||||
|
|
||||||
|
|
||||||
|
private String email;
|
||||||
|
|
||||||
|
private String password;
|
||||||
|
|
||||||
|
private String newPassword;
|
||||||
|
|
||||||
|
private String confirmPassword;
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
package net.gepafin.tendermanagement.model.request;
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
@Data
|
@Data
|
||||||
public class EvaluationCriteriaReq extends LookUpDataReq{
|
public class EvaluationCriteriaReq extends LookUpDataReq{
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class EvaluationCriteriaRequest extends LookUpDataReq {
|
||||||
|
|
||||||
|
private Long callId;
|
||||||
|
|
||||||
|
private Long score;
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class InitiatePasswordResetReq {
|
||||||
|
private String email;
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class LogoutReq {
|
||||||
|
private String email;
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.entities.LookUpDataEntity.LookUpDataTypeEnum;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class LookUpDataRequest {
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
private LookUpDataTypeEnum type;
|
||||||
|
private String value;
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.request;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ResetPasswordReq {
|
||||||
|
private String email;
|
||||||
|
private String token;
|
||||||
|
private String newPassword;
|
||||||
|
private String confirmPassword;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package net.gepafin.tendermanagement.model.response;
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.model.BaseBean;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class EvaluationCriteriaResponseBean extends LookUpDataResponse{
|
public class EvaluationCriteriaResponseBean extends LookUpDataResponse{
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package net.gepafin.tendermanagement.model.response;
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.model.BaseBean;
|
||||||
|
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class FaqResponseBean {
|
public class FaqResponseBean extends BaseBean {
|
||||||
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
private Long userId;
|
private Long userId;
|
||||||
|
|
||||||
@@ -24,7 +23,4 @@ public class FaqResponseBean {
|
|||||||
|
|
||||||
private LocalDateTime responseDate;
|
private LocalDateTime responseDate;
|
||||||
|
|
||||||
private LocalDateTime createdDate;
|
|
||||||
|
|
||||||
private LocalDateTime updatedDate;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
package net.gepafin.tendermanagement.model.response;
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.model.BaseBean;
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class LookUpDataResponse {
|
public class LookUpDataResponse extends BaseBean {
|
||||||
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
private Long lookUpDataId;
|
private Long lookUpDataId;
|
||||||
|
|
||||||
@@ -15,8 +12,4 @@ public class LookUpDataResponse {
|
|||||||
|
|
||||||
private String value;
|
private String value;
|
||||||
|
|
||||||
private LocalDateTime createdDate;
|
|
||||||
|
|
||||||
private LocalDateTime updatedDate;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package net.gepafin.tendermanagement.model.response;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import net.gepafin.tendermanagement.entities.LookUpDataEntity.LookUpDataTypeEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.BaseBean;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class LookUpDataResponseBean extends BaseBean {
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
private LookUpDataTypeEnum type;
|
||||||
|
}
|
||||||
@@ -4,6 +4,8 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
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 org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.entities.CallTargetAudienceChecklistEntity;
|
import net.gepafin.tendermanagement.entities.CallTargetAudienceChecklistEntity;
|
||||||
@@ -11,7 +13,8 @@ import net.gepafin.tendermanagement.entities.CallTargetAudienceChecklistEntity;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface CallTargetAudienceChecklistRepository extends JpaRepository<CallTargetAudienceChecklistEntity,Long> {
|
public interface CallTargetAudienceChecklistRepository extends JpaRepository<CallTargetAudienceChecklistEntity,Long> {
|
||||||
|
|
||||||
Optional<CallTargetAudienceChecklistEntity> findById(Long id);
|
@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 value);
|
List<CallTargetAudienceChecklistEntity> findByCallIdAndLookupDataTypeAndIsDeletedFalse(Long id, String value);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,15 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
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 org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface DocumentRepository extends JpaRepository<DocumentEntity, Long> {
|
public interface DocumentRepository extends JpaRepository<DocumentEntity, Long> {
|
||||||
|
|
||||||
Optional<DocumentEntity> findById(Long id);
|
@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);
|
List<DocumentEntity> findByCallIdAndTypeAndIsDeletedFalse(Long callId, String type);
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,14 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
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;
|
||||||
|
|
||||||
public interface EvaluationCriteriaRepository extends JpaRepository<EvaluationCriteriaEntity, Integer> {
|
@Repository
|
||||||
|
public interface EvaluationCriteriaRepository extends JpaRepository<EvaluationCriteriaEntity, Long> {
|
||||||
Optional<EvaluationCriteriaEntity> findById(Long id);
|
@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);
|
List<EvaluationCriteriaEntity> findByCallIdAndLookupDataTypeAndIsDeletedFalse(Long callId, String type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,12 +6,15 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
import org.springframework.data.jpa.repository.JpaRepository;
|
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 org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface FaqRepository extends JpaRepository<FaqEntity, Integer> {
|
public interface FaqRepository extends JpaRepository<FaqEntity, Long> {
|
||||||
|
|
||||||
Optional<FaqEntity> findById(Long id);
|
@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);
|
List<FaqEntity> findByCallIdAndIsDeletedFalse(Long callId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,4 +8,5 @@ import java.util.Optional;
|
|||||||
public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
public interface UserRepository extends JpaRepository<UserEntity, Long> {
|
||||||
Optional<UserEntity> findByEmailIgnoreCase(String email);
|
Optional<UserEntity> findByEmailIgnoreCase(String email);
|
||||||
boolean existsByEmailIgnoreCase(String email);
|
boolean existsByEmailIgnoreCase(String email);
|
||||||
|
UserEntity findByEmail(String email);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package net.gepafin.tendermanagement.service;
|
package net.gepafin.tendermanagement.service;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
@@ -8,7 +9,11 @@ import java.util.List;
|
|||||||
|
|
||||||
public interface DocumentService {
|
public interface DocumentService {
|
||||||
|
|
||||||
public List<DocumentResponseBean> uploadFile(List<MultipartFile> files, DocumentTypeEnum fileType);
|
public List<DocumentResponseBean> uploadFile(List<MultipartFile> files,Long callId, DocumentTypeEnum fileType);
|
||||||
|
|
||||||
public void deleteFile(Long documentId);
|
public void deleteFile(Long documentId);
|
||||||
|
|
||||||
|
public DocumentResponseBean updateDocument(HttpServletRequest httpServletRequest, Long documentId, MultipartFile file, DocumentTypeEnum documentTypeEnum);
|
||||||
|
|
||||||
|
public DocumentResponseBean getDocument(HttpServletRequest httpServletRequest,Long documentId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package net.gepafin.tendermanagement.service;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.request.EvaluationCriteriaRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.EvaluationCriteriaResponseBean;
|
||||||
|
|
||||||
|
public interface EvaluationCriteriaService {
|
||||||
|
|
||||||
|
public EvaluationCriteriaResponseBean createEvaluationCriteria(HttpServletRequest request,EvaluationCriteriaRequest evaluationCriteriaRequest);
|
||||||
|
|
||||||
|
public EvaluationCriteriaResponseBean getEvaluationCriteria(HttpServletRequest request,Long id);
|
||||||
|
|
||||||
|
public EvaluationCriteriaResponseBean updateEvaluationCriteria(HttpServletRequest request,Long id, EvaluationCriteriaRequest evaluationCriteriaRequest);
|
||||||
|
|
||||||
|
public void deleteEvaluationCriteria(HttpServletRequest request,Long id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package net.gepafin.tendermanagement.service;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.request.FaqReq;
|
||||||
|
import net.gepafin.tendermanagement.model.response.FaqResponseBean;
|
||||||
|
|
||||||
|
public interface FaqService {
|
||||||
|
|
||||||
|
FaqResponseBean createFaq(HttpServletRequest request,Long callId, FaqReq faqRequest);
|
||||||
|
|
||||||
|
FaqResponseBean getFaqById(HttpServletRequest request, Long id);
|
||||||
|
|
||||||
|
FaqResponseBean updateFaq(HttpServletRequest request, Long id, FaqReq faqRequest);
|
||||||
|
|
||||||
|
void deleteFaq(HttpServletRequest request, Long id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package net.gepafin.tendermanagement.service;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.model.request.LookUpDataRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.LookUpDataResponseBean;
|
||||||
|
|
||||||
|
public interface LookUpDataService {
|
||||||
|
|
||||||
|
LookUpDataResponseBean createLookUpData(LookUpDataRequest lookUpDataReq);
|
||||||
|
|
||||||
|
LookUpDataResponseBean getLookUpDataById(Long id);
|
||||||
|
|
||||||
|
LookUpDataResponseBean updateLookUpData(Long id, LookUpDataRequest lookUpDataReq);
|
||||||
|
|
||||||
|
void deleteLookUpData(Long id);
|
||||||
|
}
|
||||||
@@ -4,6 +4,10 @@ import net.gepafin.tendermanagement.entities.UserEntity;
|
|||||||
import net.gepafin.tendermanagement.model.request.LoginReq;
|
import net.gepafin.tendermanagement.model.request.LoginReq;
|
||||||
import net.gepafin.tendermanagement.model.request.UpdateUserReq;
|
import net.gepafin.tendermanagement.model.request.UpdateUserReq;
|
||||||
import net.gepafin.tendermanagement.model.request.UserReq;
|
import net.gepafin.tendermanagement.model.request.UserReq;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||||
|
import net.gepafin.tendermanagement.model.request.*;
|
||||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||||
|
|
||||||
@@ -19,4 +23,14 @@ public interface UserService {
|
|||||||
JWTToken login(LoginReq loginReq);
|
JWTToken login(LoginReq loginReq);
|
||||||
|
|
||||||
UserEntity validateUser(Long userId);
|
UserEntity validateUser(Long userId);
|
||||||
|
|
||||||
|
String initiatePasswordReset(InitiatePasswordResetReq resetReq);
|
||||||
|
|
||||||
|
Boolean resetPassword(ResetPasswordReq resetPasswordReq);
|
||||||
|
|
||||||
|
Boolean changePassword(ChangePasswordRequest request);
|
||||||
|
|
||||||
|
void logoutUser(HttpServletRequest request, HttpServletResponse response);
|
||||||
|
|
||||||
|
UserResponseBean updateUserStatus(Long userId, UserStatusEnum statusReq);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package net.gepafin.tendermanagement.service.impl;
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import net.gepafin.tendermanagement.config.Translator;
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
import net.gepafin.tendermanagement.config.jwt.TokenProvider;
|
import net.gepafin.tendermanagement.config.jwt.TokenProvider;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
@@ -7,6 +9,7 @@ import net.gepafin.tendermanagement.dao.RoleDao;
|
|||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.LoginReq;
|
import net.gepafin.tendermanagement.model.request.LoginReq;
|
||||||
|
import net.gepafin.tendermanagement.model.request.LogoutReq;
|
||||||
import net.gepafin.tendermanagement.model.response.LoginResponse;
|
import net.gepafin.tendermanagement.model.response.LoginResponse;
|
||||||
import net.gepafin.tendermanagement.model.response.RoleResponseBean;
|
import net.gepafin.tendermanagement.model.response.RoleResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||||
@@ -21,7 +24,9 @@ import org.springframework.security.authentication.AuthenticationManager;
|
|||||||
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
|
||||||
import org.springframework.security.core.Authentication;
|
import org.springframework.security.core.Authentication;
|
||||||
import org.springframework.security.core.context.SecurityContextHolder;
|
import org.springframework.security.core.context.SecurityContextHolder;
|
||||||
|
import org.springframework.security.web.authentication.logout.SecurityContextLogoutHandler;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -54,7 +59,7 @@ public class AuthenticationService {
|
|||||||
UserEntity user = userRepository.findByEmailIgnoreCase(loginReq.getEmail()).orElseThrow(()-> new CustomValidationException(Status.NOT_FOUND,
|
UserEntity user = userRepository.findByEmailIgnoreCase(loginReq.getEmail()).orElseThrow(()-> new CustomValidationException(Status.NOT_FOUND,
|
||||||
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG)));
|
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG)));
|
||||||
if (Boolean.FALSE.equals(UserStatusEnum.ACTIVE.getValue().equals(user.getStatus()))) {
|
if (Boolean.FALSE.equals(UserStatusEnum.ACTIVE.getValue().equals(user.getStatus()))) {
|
||||||
new CustomValidationException(Status.NOT_FOUND,
|
throw new CustomValidationException(Status.NOT_FOUND,
|
||||||
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG));
|
Translator.toLocale(GepafinConstant.USER_NOT_FOUND_MSG));
|
||||||
}
|
}
|
||||||
user.setLastLogin(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
user.setLastLogin(DateTimeUtil.DateServerToUTC(LocalDateTime.now()));
|
||||||
@@ -89,5 +94,15 @@ public class AuthenticationService {
|
|||||||
loginResponse.setUpdatedDate(user.getUpdatedDate());
|
loginResponse.setUpdatedDate(user.getUpdatedDate());
|
||||||
return loginResponse;
|
return loginResponse;
|
||||||
}
|
}
|
||||||
|
public void logout(HttpServletRequest request, HttpServletResponse response)
|
||||||
|
{ Authentication auth = SecurityContextHolder.getContext().getAuthentication();
|
||||||
|
if (auth != null) {
|
||||||
|
String token = tokenProvider.extractTokenFromRequest(request);
|
||||||
|
tokenProvider.invalidateToken(token);
|
||||||
|
new SecurityContextLogoutHandler().logout(request, response, auth);
|
||||||
|
}
|
||||||
|
SecurityContextHolder.getContext().setAuthentication(null);
|
||||||
|
SecurityContextHolder.clearContext();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,28 +2,41 @@ package net.gepafin.tendermanagement.service.impl;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.dao.DocumentDao;
|
import net.gepafin.tendermanagement.dao.DocumentDao;
|
||||||
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
import net.gepafin.tendermanagement.enums.DocumentTypeEnum;
|
||||||
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
import net.gepafin.tendermanagement.model.response.DocumentResponseBean;
|
||||||
import net.gepafin.tendermanagement.service.DocumentService;
|
import net.gepafin.tendermanagement.service.DocumentService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class DocumentServiceImpl implements DocumentService {
|
public class DocumentServiceImpl implements DocumentService {
|
||||||
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DocumentDao fileDao;
|
private DocumentDao documentDao;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<DocumentResponseBean> uploadFile(List<MultipartFile> files, DocumentTypeEnum fileType) {
|
public List<DocumentResponseBean> uploadFile(List<MultipartFile> files,Long callId,DocumentTypeEnum fileType) {
|
||||||
return fileDao.uploadFiles(files,fileType);
|
return documentDao.uploadFiles(files,callId,fileType);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void deleteFile(Long documentId){
|
public void deleteFile(Long documentId){
|
||||||
fileDao.deleteFile(documentId);
|
documentDao.deleteFile(documentId);
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DocumentResponseBean updateDocument(HttpServletRequest httpServletRequest, Long documentId, MultipartFile file, DocumentTypeEnum documentTypeEnum) {
|
||||||
|
return documentDao.updateDocument(documentId,file,documentTypeEnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DocumentResponseBean getDocument(HttpServletRequest httpServletRequest, Long documentId) {
|
||||||
|
return documentDao.getDocument(documentId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.dao.EvaluationCriteriaDao;
|
||||||
|
import net.gepafin.tendermanagement.model.request.EvaluationCriteriaRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.EvaluationCriteriaResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.service.EvaluationCriteriaService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class EvaluationCriteriaServiceImpl implements EvaluationCriteriaService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EvaluationCriteriaDao evaluationCriteriaDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EvaluationCriteriaResponseBean createEvaluationCriteria(HttpServletRequest request,EvaluationCriteriaRequest evaluationCriteriaRequest) {
|
||||||
|
return evaluationCriteriaDao.createEvaluationCriteria(evaluationCriteriaRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EvaluationCriteriaResponseBean getEvaluationCriteria(HttpServletRequest request,Long id) {
|
||||||
|
return evaluationCriteriaDao.getEvaluationCriteriaById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EvaluationCriteriaResponseBean updateEvaluationCriteria(HttpServletRequest request,Long id, EvaluationCriteriaRequest evaluationCriteriaRequest) {
|
||||||
|
return evaluationCriteriaDao.updateEvaluationCriteria(id,evaluationCriteriaRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteEvaluationCriteria(HttpServletRequest request,Long id) {
|
||||||
|
evaluationCriteriaDao.deleteEvaluationCriteria(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import net.gepafin.tendermanagement.config.jwt.TokenProvider;
|
||||||
|
import net.gepafin.tendermanagement.dao.FaqDao;
|
||||||
|
import net.gepafin.tendermanagement.model.request.FaqReq;
|
||||||
|
import net.gepafin.tendermanagement.model.response.FaqResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.service.FaqService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class FaqServiceImpl implements FaqService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FaqDao faqDao;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private TokenProvider tokenProvider;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FaqResponseBean createFaq(HttpServletRequest request,Long callId, FaqReq faqRequest) {
|
||||||
|
Map<String, Object> userInfo= tokenProvider.getUserInfoAndUserIdFromToken(request);
|
||||||
|
return faqDao.createFaq(faqRequest,Long.parseLong(userInfo.get("userId").toString()),callId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FaqResponseBean getFaqById(HttpServletRequest request, Long id) {
|
||||||
|
return faqDao.getFaqById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FaqResponseBean updateFaq(HttpServletRequest request, Long id, FaqReq faqRequest) {
|
||||||
|
Map<String, Object> userInfo= tokenProvider.getUserInfoAndUserIdFromToken(request);
|
||||||
|
return faqDao.updateFaq(id, faqRequest,Long.parseLong(userInfo.get("userId").toString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteFaq(HttpServletRequest request, Long id) {
|
||||||
|
faqDao.deleteFaq(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
package net.gepafin.tendermanagement.service.impl;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.dao.LookUpDataDao;
|
||||||
|
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;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class LookUpDataServiceImpl implements LookUpDataService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LookUpDataDao lookUpDataDao;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LookUpDataResponseBean createLookUpData(LookUpDataRequest lookUpDataReq) {
|
||||||
|
return lookUpDataDao.createLookUpData(lookUpDataReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LookUpDataResponseBean getLookUpDataById(Long id) {
|
||||||
|
return lookUpDataDao.getLookUpDataById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public LookUpDataResponseBean updateLookUpData(Long id, LookUpDataRequest lookUpDataReq) {
|
||||||
|
return lookUpDataDao.updateLookUpData(id, lookUpDataReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteLookUpData(Long id) {
|
||||||
|
lookUpDataDao.deleteLookUpData(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,14 @@
|
|||||||
package net.gepafin.tendermanagement.service.impl;
|
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.dao.UserDao;
|
||||||
import net.gepafin.tendermanagement.entities.UserEntity;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
import net.gepafin.tendermanagement.model.request.LoginReq;
|
import net.gepafin.tendermanagement.model.request.LoginReq;
|
||||||
import net.gepafin.tendermanagement.model.request.UpdateUserReq;
|
import net.gepafin.tendermanagement.model.request.UpdateUserReq;
|
||||||
import net.gepafin.tendermanagement.model.request.UserReq;
|
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.UserResponseBean;
|
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||||
import net.gepafin.tendermanagement.service.UserService;
|
import net.gepafin.tendermanagement.service.UserService;
|
||||||
@@ -54,4 +58,27 @@ public class UserServiceImpl implements UserService {
|
|||||||
return userDao.validateUser(userId);
|
return userDao.validateUser(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String initiatePasswordReset(InitiatePasswordResetReq resetReq) {
|
||||||
|
return userDao.initiatePasswordReset(resetReq);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean resetPassword(ResetPasswordReq resetPasswordReq) {
|
||||||
|
return userDao.resetPassword(resetPasswordReq);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Boolean changePassword(ChangePasswordRequest request){
|
||||||
|
return userDao.changePassword(request);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void logoutUser(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
userDao.logout(request,response);
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public UserResponseBean updateUserStatus(Long userId, UserStatusEnum statusReq) {
|
||||||
|
return userDao.updateUserStatus(userId, statusReq);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package net.gepafin.tendermanagement.web.rest.api;
|
package net.gepafin.tendermanagement.web.rest.api;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
import io.swagger.v3.oas.annotations.media.Content;
|
import io.swagger.v3.oas.annotations.media.Content;
|
||||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
@@ -27,14 +28,12 @@ public interface DocumentApi {
|
|||||||
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
@ApiResponse(responseCode = "401", description = "Unauthorized", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
@ExampleObject(value = ErrorConstants.UNAUTHORIZED_ERROR_EXAMPLE) })),
|
||||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))})
|
||||||
})
|
@PostMapping(value = "/uploadFile/call/{callId}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
@PostMapping(value = "/uploadFile", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
default ResponseEntity<Response<List<DocumentResponseBean>>> uploadFile(HttpServletRequest httpServletRequest, @Parameter(description = "call id", required = true) @PathVariable Long callId, @RequestParam("file") List<MultipartFile> files, @RequestParam("documentType") DocumentTypeEnum documentTypeEnum) {
|
||||||
default ResponseEntity<Response<List<DocumentResponseBean>>> uploadFile(HttpServletRequest httpServletRequest,
|
|
||||||
@RequestParam("file") List<MultipartFile> files,
|
|
||||||
@RequestParam("documentType") DocumentTypeEnum documentTypeEnum) {
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "API to delete a file by document id",
|
@Operation(summary = "API to delete a file by document id",
|
||||||
responses = {
|
responses = {
|
||||||
@ApiResponse(responseCode = "200", description = "File deleted successfully"),
|
@ApiResponse(responseCode = "200", description = "File deleted successfully"),
|
||||||
@@ -50,4 +49,30 @@ public interface DocumentApi {
|
|||||||
@RequestParam( "id") Long id) {
|
@RequestParam( "id") Long id) {
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
}
|
}
|
||||||
|
@Operation(summary = "Api to update document",
|
||||||
|
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 = "/{id}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
|
default ResponseEntity<Response<DocumentResponseBean>> updateDocument(HttpServletRequest httpServletRequest, @Parameter(description = "document id", required = true) @PathVariable Long documentId, @RequestParam("file") MultipartFile file, @RequestParam("documentType") DocumentTypeEnum documentTypeEnum) {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
}
|
||||||
|
@Operation(summary = "API to get document 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) }))
|
||||||
|
})
|
||||||
|
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
ResponseEntity<Response<DocumentResponseBean>> getDocumentById(HttpServletRequest request,
|
||||||
|
@Parameter(description = "document id", required = true)
|
||||||
|
@PathVariable Long id);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,78 @@
|
|||||||
|
package net.gepafin.tendermanagement.web.rest.api;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
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 jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import net.gepafin.tendermanagement.model.request.EvaluationCriteriaRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.EvaluationCriteriaResponseBean;
|
||||||
|
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.*;
|
||||||
|
|
||||||
|
public interface EvaluationCriteriaApi {
|
||||||
|
|
||||||
|
|
||||||
|
@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 = {
|
||||||
|
@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 = "/criteria", 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",
|
||||||
|
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) }))
|
||||||
|
})
|
||||||
|
@GetMapping(value = "/criteria/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
ResponseEntity<Response<EvaluationCriteriaResponseBean>> getEvaluationCriteriaById(HttpServletRequest request,
|
||||||
|
@Parameter(description = "evaluation criteria id", required = true)
|
||||||
|
@PathVariable Long id);
|
||||||
|
|
||||||
|
@Operation(summary = "API to update evaluation criteria",
|
||||||
|
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 = "/criteria/{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,
|
||||||
|
@Parameter(description = "Evaluation criteria request object", required = true)
|
||||||
|
@Valid @RequestBody EvaluationCriteriaRequest evaluationCriteriaRequest);
|
||||||
|
|
||||||
|
@Operation(summary = "API to delete evaluation criteria",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(responseCode = "204", description = "No Content"),
|
||||||
|
@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) }))
|
||||||
|
})
|
||||||
|
@DeleteMapping(value = "/criteria/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
ResponseEntity<Void> deleteEvaluationCriteria(HttpServletRequest request,
|
||||||
|
@Parameter(description = "evaluation criteria id", required = true)
|
||||||
|
@PathVariable Long id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package net.gepafin.tendermanagement.web.rest.api;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
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.model.request.FaqReq;
|
||||||
|
import net.gepafin.tendermanagement.model.response.FaqResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
public interface FaqApi {
|
||||||
|
|
||||||
|
@Operation(summary = "API to create FAQ",
|
||||||
|
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 = "401", description = "Unauthorized", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Unauthorized\" }"))),
|
||||||
|
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Not Found\" }")))
|
||||||
|
})
|
||||||
|
@PostMapping(value = "/call/{callId}", consumes = "application/json", produces = "application/json")
|
||||||
|
ResponseEntity<Response<FaqResponseBean>> createFaq(HttpServletRequest request, @Parameter(description = "evaluation criteria id", required = true)
|
||||||
|
@PathVariable Long id, @Valid @RequestBody FaqReq faqRequest);
|
||||||
|
|
||||||
|
@Operation(summary = "API to get FAQ 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\" }")))
|
||||||
|
})
|
||||||
|
@GetMapping(value = "/{id}", produces = "application/json")
|
||||||
|
ResponseEntity<Response<FaqResponseBean>> getFaqById(HttpServletRequest request,
|
||||||
|
@PathVariable Long id);
|
||||||
|
|
||||||
|
@Operation(summary = "API to update FAQ",
|
||||||
|
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 = "400", description = "Bad Request", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Bad Request\" }")))
|
||||||
|
})
|
||||||
|
@PutMapping(value = "/{id}", consumes = "application/json", produces = "application/json")
|
||||||
|
ResponseEntity<Response<FaqResponseBean>> updateFaq(HttpServletRequest request,
|
||||||
|
@PathVariable Long id,
|
||||||
|
@Valid @RequestBody FaqReq faqRequest);
|
||||||
|
|
||||||
|
@Operation(summary = "API to delete FAQ",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(responseCode = "204", description = "No Content"),
|
||||||
|
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Not Found\" }")))
|
||||||
|
})
|
||||||
|
@DeleteMapping(value = "/{id}")
|
||||||
|
ResponseEntity<Response<Void>> deleteFaq(HttpServletRequest request,
|
||||||
|
@PathVariable Long id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package net.gepafin.tendermanagement.web.rest.api;
|
||||||
|
|
||||||
|
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.model.request.LookUpDataRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.LookUpDataResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
|
public interface LookUpDataApi {
|
||||||
|
|
||||||
|
@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\" }")))
|
||||||
|
})
|
||||||
|
@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",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "OK"),
|
||||||
|
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Not Found\" }")))
|
||||||
|
})
|
||||||
|
@GetMapping(value = "/{id}", produces = "application/json")
|
||||||
|
ResponseEntity<Response<LookUpDataResponseBean>> getLookUpDataById(HttpServletRequest request, @PathVariable Long id);
|
||||||
|
|
||||||
|
@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\" }")))
|
||||||
|
})
|
||||||
|
@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",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(responseCode = "204", description = "No Content"),
|
||||||
|
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = "application/json", examples = @ExampleObject(value = "{ \"error\": \"Not Found\" }")))
|
||||||
|
})
|
||||||
|
@DeleteMapping(value = "/{id}")
|
||||||
|
ResponseEntity<Response<Void>> deleteLookUpData(HttpServletRequest request, @PathVariable Long id);
|
||||||
|
}
|
||||||
@@ -5,10 +5,12 @@ import io.swagger.v3.oas.annotations.Operation;
|
|||||||
import io.swagger.v3.oas.annotations.media.Content;
|
import io.swagger.v3.oas.annotations.media.Content;
|
||||||
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
import io.swagger.v3.oas.annotations.media.ExampleObject;
|
||||||
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
import io.swagger.v3.oas.annotations.responses.ApiResponse;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import net.gepafin.tendermanagement.model.request.LoginReq;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
import net.gepafin.tendermanagement.model.request.UpdateUserReq;
|
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.UserReq;
|
import net.gepafin.tendermanagement.model.request.*;
|
||||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||||
import net.gepafin.tendermanagement.model.util.Response;
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
@@ -18,10 +20,7 @@ import org.springframework.http.MediaType;
|
|||||||
import org.springframework.http.ResponseEntity;
|
import org.springframework.http.ResponseEntity;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMethod;
|
|
||||||
|
|
||||||
@Validated
|
@Validated
|
||||||
public interface UserApi {
|
public interface UserApi {
|
||||||
@@ -105,4 +104,77 @@ public interface UserApi {
|
|||||||
method = RequestMethod.POST)
|
method = RequestMethod.POST)
|
||||||
ResponseEntity<Response<JWTToken>> login(
|
ResponseEntity<Response<JWTToken>> login(
|
||||||
@Parameter(description = "Login request object", required = true) @Valid @RequestBody LoginReq loginReq);
|
@Parameter(description = "Login request object", required = true) @Valid @RequestBody LoginReq loginReq);
|
||||||
|
@Operation(summary = "Api to initiate password reset request",
|
||||||
|
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 = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
|
||||||
|
@RequestMapping(value = "/reset-password/initiate",
|
||||||
|
produces = {"application/json"},
|
||||||
|
method = RequestMethod.POST)
|
||||||
|
ResponseEntity<Response<String>> initiatePasswordReset(
|
||||||
|
@Parameter(description = "Initiate password reset request object", required = true) @Valid @RequestBody InitiatePasswordResetReq initiatePasswordResetReq);
|
||||||
|
|
||||||
|
@Operation(summary = "Api to reset password",
|
||||||
|
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 = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
|
||||||
|
@RequestMapping(value = "/reset-password",
|
||||||
|
produces = {"application/json"},
|
||||||
|
method = RequestMethod.POST)
|
||||||
|
ResponseEntity<Response<Boolean>> resetPassword(
|
||||||
|
@Parameter(description = "Reset password request object", required = true) @Valid @RequestBody ResetPasswordReq resetPasswordReq);
|
||||||
|
@Operation(summary = "Api to change user password",
|
||||||
|
responses = {
|
||||||
|
@ApiResponse(responseCode = "200", description = "Password Changed Successfully", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = "{ \"message\": \"Password changed successfully.\" }")})),
|
||||||
|
@ApiResponse(responseCode = "404", description = "Not Found", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.NOTFOUND_ERROR_EXAMPLE)})),
|
||||||
|
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||||
|
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE)}))})
|
||||||
|
@RequestMapping(value = "/change-password",
|
||||||
|
produces = {"application/json"},
|
||||||
|
method = RequestMethod.POST)
|
||||||
|
ResponseEntity<Response<Boolean>> changePassword(
|
||||||
|
@Parameter(description = "Change password request object", required = true) @Valid @RequestBody ChangePasswordRequest changePasswordRequest); @Operation(summary = "Api to logout user",
|
||||||
|
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)}))})
|
||||||
|
@RequestMapping(value = "/logout",
|
||||||
|
method = RequestMethod.POST)
|
||||||
|
ResponseEntity<Response<Void>> logoutUser(
|
||||||
|
@Parameter(description = "The request object is not needed for logout", required = false) HttpServletRequest request,
|
||||||
|
@Parameter(description = "The response object is not needed for logout", required = false) HttpServletResponse response);
|
||||||
|
@Operation(summary = "Api to update user active/deactive status",
|
||||||
|
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)}))
|
||||||
|
})
|
||||||
|
@RequestMapping(value = "/{userId}/status",
|
||||||
|
produces = {"application/json"},
|
||||||
|
method = RequestMethod.PUT)
|
||||||
|
@PreAuthorize("hasRole('ROLE_SUPER_ADMIN')")
|
||||||
|
default ResponseEntity<Response<UserResponseBean>> updateUserStatus(
|
||||||
|
@Parameter(description = "The user id", required = true) @PathVariable("userId") Long userId,
|
||||||
|
@Parameter(description = "status", required = true)@RequestParam(value = "status", required = true) UserStatusEnum status) {
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,16 +20,17 @@ import java.util.List;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("${openapi.swaggerBflowsMiddleware.base-path:/v1/document}")
|
@RequestMapping("${openapi.swaggerBflowsMiddleware.base-path:/v1/document}")
|
||||||
public class DocumentApiController implements DocumentApi {
|
public class
|
||||||
|
DocumentApiController implements DocumentApi {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private DocumentService fileService;
|
private DocumentService documentService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<List<DocumentResponseBean>>> uploadFile(HttpServletRequest httpServletRequest,
|
public ResponseEntity<Response<List<DocumentResponseBean>>> uploadFile(HttpServletRequest httpServletRequest, Long callId,
|
||||||
List<MultipartFile> files, DocumentTypeEnum fileType) {
|
List<MultipartFile> files, DocumentTypeEnum fileType) {
|
||||||
try {
|
try {
|
||||||
List<DocumentResponseBean> responseBeans=fileService.uploadFile(files,fileType);
|
List<DocumentResponseBean> responseBeans = documentService.uploadFile(files, callId, fileType);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED)
|
return ResponseEntity.status(HttpStatus.CREATED)
|
||||||
.body(new Response<List<DocumentResponseBean>>(responseBeans, Status.SUCCESS, Translator.toLocale(GepafinConstant.FILES_UPLOADED_MSG)));
|
.body(new Response<List<DocumentResponseBean>>(responseBeans, Status.SUCCESS, Translator.toLocale(GepafinConstant.FILES_UPLOADED_MSG)));
|
||||||
} catch (CustomValidationException ex) {
|
} catch (CustomValidationException ex) {
|
||||||
@@ -38,8 +39,22 @@ public class DocumentApiController implements DocumentApi {
|
|||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<Response<Void>> deleteFile(HttpServletRequest httpServletRequest, Long documentId) {
|
public ResponseEntity<Response<Void>> deleteFile(HttpServletRequest httpServletRequest, Long documentId) {
|
||||||
fileService.deleteFile(documentId);
|
documentService.deleteFile(documentId);
|
||||||
return ResponseEntity.status(HttpStatus.CREATED)
|
return ResponseEntity.status(HttpStatus.CREATED)
|
||||||
.body(new Response<Void>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.FILE_DELETED_SUCCESSFULLY_MSG)));
|
.body(new Response<Void>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.FILE_DELETED_SUCCESSFULLY_MSG)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<DocumentResponseBean>> updateDocument(HttpServletRequest httpServletRequest, Long documentId, MultipartFile file, DocumentTypeEnum documentTypeEnum) {
|
||||||
|
DocumentResponseBean responseBeans = documentService.updateDocument(httpServletRequest, documentId, file, documentTypeEnum);
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED)
|
||||||
|
.body(new Response<DocumentResponseBean>(responseBeans, Status.SUCCESS, Translator.toLocale(GepafinConstant.DOCUMENT_UPDATED_SUCCESSFULLY)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<DocumentResponseBean>> getDocumentById(HttpServletRequest request, Long id) {
|
||||||
|
DocumentResponseBean documentResponseBean= documentService.getDocument(request,id);
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED)
|
||||||
|
.body(new Response<DocumentResponseBean>(documentResponseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.DOCUMENT_FETCHED_SUCCESSFULLY)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||||
|
|
||||||
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
|
import net.gepafin.tendermanagement.model.request.EvaluationCriteriaRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.EvaluationCriteriaResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
|
import net.gepafin.tendermanagement.service.EvaluationCriteriaService;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.EvaluationCriteriaApi;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("${openapi.gepafin.base-path:/v1/evaluation}")
|
||||||
|
public class EvaluationCriteriaApiController implements EvaluationCriteriaApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private EvaluationCriteriaService service;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<EvaluationCriteriaResponseBean>> createEvaluationCriteria(HttpServletRequest request, EvaluationCriteriaRequest evaluationCriteriaRequest) {
|
||||||
|
EvaluationCriteriaResponseBean responseBean = service.createEvaluationCriteria(request,evaluationCriteriaRequest);
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED)
|
||||||
|
.body(new Response<>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_CREATED_SUCCESSFULLY)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<EvaluationCriteriaResponseBean>> getEvaluationCriteriaById(HttpServletRequest request, Long id) {
|
||||||
|
EvaluationCriteriaResponseBean responseBean = service.getEvaluationCriteria(request,id);
|
||||||
|
if (responseBean != null) {
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_FETCH_SUCCESSFULLY)));
|
||||||
|
} else {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||||
|
.body(new Response<>(null, Status.NOT_FOUND, Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_NOT_FOUND)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor=Exception.class)
|
||||||
|
public ResponseEntity<Response<EvaluationCriteriaResponseBean>> updateEvaluationCriteria(HttpServletRequest request, Long id, EvaluationCriteriaRequest evaluationCriteriaRequest) {
|
||||||
|
EvaluationCriteriaResponseBean responseBean = service.updateEvaluationCriteria(request,id, evaluationCriteriaRequest);
|
||||||
|
if (responseBean != null) {
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_UPDATED_SUCCESSFULLY)));
|
||||||
|
} else {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||||
|
.body(new Response<>(null, Status.NOT_FOUND, Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_NOT_FOUND)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Void> deleteEvaluationCriteria(HttpServletRequest request, Long id) {
|
||||||
|
service.deleteEvaluationCriteria(request,id);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.header("Message", Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_DELETED_SUCCESSFULLY))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
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.FaqReq;
|
||||||
|
import net.gepafin.tendermanagement.model.response.FaqResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
|
import net.gepafin.tendermanagement.service.FaqService;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.FaqApi;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("${openapi.gepafin.base-path:/v1/faq}")
|
||||||
|
public class FaqApiController implements FaqApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private FaqService faqService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<FaqResponseBean>> createFaq(HttpServletRequest request, Long callId,FaqReq faqRequest) {
|
||||||
|
FaqResponseBean response = faqService.createFaq(request,callId, faqRequest);
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED)
|
||||||
|
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.FAQ_CREATED_SUCCESSFULLY)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<FaqResponseBean>> getFaqById(HttpServletRequest request, Long id) {
|
||||||
|
FaqResponseBean response = faqService.getFaqById(request, id);
|
||||||
|
if (response != null) {
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.FAQ_FETCHED_SUCCESSFULLY)));
|
||||||
|
} else {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||||
|
.body(new Response<>(null, Status.NOT_FOUND, Translator.toLocale(GepafinConstant.FAQ_NOT_FOUND)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<FaqResponseBean>> updateFaq(HttpServletRequest request, Long id, FaqReq faqRequest) {
|
||||||
|
FaqResponseBean response = faqService.updateFaq(request, id, faqRequest);
|
||||||
|
if (response != null) {
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(response, Status.SUCCESS, Translator.toLocale(GepafinConstant.FAQ_UPDATED_SUCCESSFULLY)));
|
||||||
|
} else {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||||
|
.body(new Response<>(null, Status.NOT_FOUND, Translator.toLocale(GepafinConstant.FAQ_NOT_FOUND)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<Void>> deleteFaq(HttpServletRequest request, Long id) {
|
||||||
|
faqService.deleteFaq(request, id);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.FAQ_DELETED_SUCCESSFULLY)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
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.LookUpDataRequest;
|
||||||
|
import net.gepafin.tendermanagement.model.response.LookUpDataResponseBean;
|
||||||
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
|
import net.gepafin.tendermanagement.service.LookUpDataService;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.LookUpDataApi;
|
||||||
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("${openapi.gepafin.base-path:/v1/lookupdata}")
|
||||||
|
public class LookUpDataApiController implements LookUpDataApi {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private LookUpDataService lookUpDataService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<LookUpDataResponseBean>> createLookUpData(HttpServletRequest request, LookUpDataRequest lookUpDataReq) {
|
||||||
|
LookUpDataResponseBean responseBean = lookUpDataService.createLookUpData(lookUpDataReq);
|
||||||
|
return ResponseEntity.status(HttpStatus.CREATED)
|
||||||
|
.body(new Response<LookUpDataResponseBean>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOOKUP_DATA_CREATED_SUCCESSFULLY)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<LookUpDataResponseBean>> getLookUpDataById(HttpServletRequest request, Long id) {
|
||||||
|
LookUpDataResponseBean responseBean = lookUpDataService.getLookUpDataById(id);
|
||||||
|
if (responseBean != null) {
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<LookUpDataResponseBean>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOOKUP_DATA_FETCHED_SUCCESSFULLY)));
|
||||||
|
} else {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||||
|
.body(new Response<LookUpDataResponseBean>(responseBean, Status.NOT_FOUND, Translator.toLocale(GepafinConstant.LOOKUP_DATA_NOT_FOUND)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<LookUpDataResponseBean>> updateLookUpData(HttpServletRequest request, Long id, LookUpDataRequest lookUpDataReq) {
|
||||||
|
LookUpDataResponseBean responseBean = lookUpDataService.updateLookUpData(id, lookUpDataReq);
|
||||||
|
if (responseBean != null) {
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<LookUpDataResponseBean>(responseBean, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOOKUP_DATA_UPDATED_SUCCESSFULLY)));
|
||||||
|
} else {
|
||||||
|
return ResponseEntity.status(HttpStatus.NOT_FOUND)
|
||||||
|
.body(new Response<LookUpDataResponseBean>(responseBean, Status.NOT_FOUND, Translator.toLocale(GepafinConstant.LOOKUP_DATA_NOT_FOUND)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<Void>> deleteLookUpData(HttpServletRequest request, Long id) {
|
||||||
|
lookUpDataService.deleteLookUpData(id);
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOOKUP_DATA_DELETED_SUCCESSFULLY)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,17 +1,19 @@
|
|||||||
package net.gepafin.tendermanagement.web.rest.api.impl;
|
package net.gepafin.tendermanagement.web.rest.api.impl;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
import jakarta.validation.Valid;
|
import jakarta.validation.Valid;
|
||||||
import net.gepafin.tendermanagement.config.Translator;
|
import net.gepafin.tendermanagement.config.Translator;
|
||||||
|
import net.gepafin.tendermanagement.config.jwt.TokenProvider;
|
||||||
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
import net.gepafin.tendermanagement.constants.GepafinConstant;
|
||||||
import net.gepafin.tendermanagement.model.request.LoginReq;
|
import net.gepafin.tendermanagement.entities.UserEntity;
|
||||||
import net.gepafin.tendermanagement.model.request.UpdateUserReq;
|
import net.gepafin.tendermanagement.enums.UserStatusEnum;
|
||||||
import net.gepafin.tendermanagement.model.request.UserReq;
|
import net.gepafin.tendermanagement.model.request.*;
|
||||||
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
import net.gepafin.tendermanagement.model.response.UserResponseBean;
|
||||||
import net.gepafin.tendermanagement.model.util.JWTToken;
|
import net.gepafin.tendermanagement.model.util.JWTToken;
|
||||||
import net.gepafin.tendermanagement.model.util.Response;
|
import net.gepafin.tendermanagement.model.util.Response;
|
||||||
import net.gepafin.tendermanagement.service.UserService;
|
import net.gepafin.tendermanagement.service.UserService;
|
||||||
import net.gepafin.tendermanagement.web.rest.api.UserApi;
|
import net.gepafin.tendermanagement.web.rest.api.UserApi;
|
||||||
|
|
||||||
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
import net.gepafin.tendermanagement.web.rest.api.errors.Status;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@@ -27,7 +29,8 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
public class UserApiController implements UserApi {
|
public class UserApiController implements UserApi {
|
||||||
|
|
||||||
private final Logger log = LoggerFactory.getLogger(UserApiController.class);
|
private final Logger log = LoggerFactory.getLogger(UserApiController.class);
|
||||||
|
@Autowired
|
||||||
|
private TokenProvider tokenProvider;
|
||||||
@Autowired
|
@Autowired
|
||||||
private UserService userService;
|
private UserService userService;
|
||||||
|
|
||||||
@@ -74,4 +77,46 @@ public class UserApiController implements UserApi {
|
|||||||
JWTToken jwtToken = userService.login(loginReq);
|
JWTToken jwtToken = userService.login(loginReq);
|
||||||
return ResponseEntity.ok(new Response<>(jwtToken, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOGIN_SUCCESS_MSG)));
|
return ResponseEntity.ok(new Response<>(jwtToken, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOGIN_SUCCESS_MSG)));
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<Boolean>> changePassword(@Valid @RequestBody ChangePasswordRequest request) {
|
||||||
|
log.info("Change Password attempt for email: {}", request.getEmail());
|
||||||
|
userService.changePassword(request);
|
||||||
|
return ResponseEntity.ok(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.SUCCESS_PASSWORD_CHANGED)));
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<String>> initiatePasswordReset(InitiatePasswordResetReq request) {
|
||||||
|
log.info("Initiating password reset for email: {}", request.getEmail());
|
||||||
|
String resetToken = userService.initiatePasswordReset(request);
|
||||||
|
log.info("Password reset token generated for email: {}", request.getEmail());
|
||||||
|
return ResponseEntity.ok(new Response<>(resetToken, Status.SUCCESS, Translator.toLocale(GepafinConstant.RESET_PASSWORD_INITIATED)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<Boolean>> resetPassword(ResetPasswordReq request) {
|
||||||
|
log.info("Resetting password for username: {}", request.getEmail());
|
||||||
|
Boolean success = userService.resetPassword(request);
|
||||||
|
if (success) {
|
||||||
|
log.info("Password reset successfully for username: {}", request.getEmail());
|
||||||
|
} else {
|
||||||
|
log.error("Password reset failed for username: {}", request.getEmail());
|
||||||
|
}
|
||||||
|
return ResponseEntity.ok(new Response<>(success, Status.SUCCESS, Translator.toLocale(GepafinConstant.PASSWORD_RESET_SUCCESS)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<Void>> logoutUser(HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
userService.logoutUser(request, response);
|
||||||
|
|
||||||
|
log.info("User has successfully logged");
|
||||||
|
return ResponseEntity.status(HttpStatus.OK)
|
||||||
|
.body(new Response<>(null, Status.SUCCESS, Translator.toLocale(GepafinConstant.LOGOUT_SUCCESSFUL_MSG)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResponseEntity<Response<UserResponseBean>> updateUserStatus(@PathVariable Long userId, @RequestParam UserStatusEnum status) {
|
||||||
|
log.info("Update User Status for- User ID: {}, Request Body: {}", userId, status);
|
||||||
|
UserResponseBean updatedUser = userService.updateUserStatus(userId, status);
|
||||||
|
return ResponseEntity.ok(new Response<>(updatedUser, Status.SUCCESS, Translator.toLocale(GepafinConstant.UPDATE_USER_STATUS_SUCCESS_MSG)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -434,4 +434,12 @@
|
|||||||
</addColumn>
|
</addColumn>
|
||||||
</changeSet>
|
</changeSet>
|
||||||
|
|
||||||
|
<changeSet id="23-08-2024_1" author="Harish Bagora">
|
||||||
|
<addColumn tableName="gepafin_user">
|
||||||
|
<column name="reset_password_token" type="VARCHAR(255)">
|
||||||
|
<constraints nullable="true"/>
|
||||||
|
</column>
|
||||||
|
</addColumn>
|
||||||
|
</changeSet>
|
||||||
|
|
||||||
</databaseChangeLog>
|
</databaseChangeLog>
|
||||||
|
|||||||
@@ -47,8 +47,8 @@ call.created.successfully=Call created successfully.
|
|||||||
call.invalid.date=Invalid start or end date.
|
call.invalid.date=Invalid start or end date.
|
||||||
call.update.successfully=Call updated successfully.
|
call.update.successfully=Call updated successfully.
|
||||||
call.fetch.success=Call details fetched successfully.
|
call.fetch.success=Call details fetched successfully.
|
||||||
|
|
||||||
call.not.found=Call not found.
|
call.not.found=Call not found.
|
||||||
|
score.not.null=Score cannot be null or cannot be zero.
|
||||||
|
|
||||||
# Login-related messages
|
# Login-related messages
|
||||||
login.successfully=Login successfully.
|
login.successfully=Login successfully.
|
||||||
@@ -61,7 +61,41 @@ invalid_signature=Invalid token.
|
|||||||
invalid_login=Invalid username or password.
|
invalid_login=Invalid username or password.
|
||||||
req_validation_er=Request Validation Error
|
req_validation_er=Request Validation Error
|
||||||
|
|
||||||
|
#EvaluationCriteria-related messages
|
||||||
|
evaluation.criteria.not.found=EvaluationCriteria not found.
|
||||||
|
evaluation.criteria.created.successfully=EvaluationCriteria created successfully.
|
||||||
|
evaluation.criteria.fetch.successfully=EvaluationCriteria fetched successfully.
|
||||||
|
evaluation.criteria.updated.successfully=EvaluationCriteria updated successfully.
|
||||||
|
evaluation.criteria.deleted.successfully=EvaluationCriteria deleted successfully.
|
||||||
|
# Password reset messages
|
||||||
|
password.reset.initiated=Password reset initiated.
|
||||||
|
password.reset.success=Password has been successfully reset.
|
||||||
|
#Change Password
|
||||||
|
invalid.token.msg=The token provided is invalid or expired. Please request a new token.
|
||||||
|
current.password.incorrect = Current password is incorrect.
|
||||||
|
success.password.changed=Password changed successfully.
|
||||||
|
#Logout
|
||||||
|
logout.successful.msg=Logout successful. You have been logged out successfully.
|
||||||
|
#Update user Active or Deactive status
|
||||||
|
update.user.status.success=User status has been successfully updated.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#Faq-related messages
|
||||||
|
faq.not.found=Faq not found.
|
||||||
|
faq.created.successfully=Faq created successfully.
|
||||||
|
faq.fetched.successfully=Faq fetched successfully.
|
||||||
|
faq.updated.successfully=Faq updated successfully.
|
||||||
|
faq.deleted.successfully=Faq deleted successfully.
|
||||||
|
|
||||||
|
#LookUpData-related message
|
||||||
|
lookupdata.not.found=LookUpData not found.
|
||||||
|
lookupdata.created.successfully=LookUpData created successfully.
|
||||||
|
lookupdata.fetched.successfully=LookUpData fetched successfully.
|
||||||
|
lookupdata.updated.successfully=LookUpData updated successfully.
|
||||||
|
lookupdata.deleted.successfully=LookUpData deleted successfully.
|
||||||
|
|
||||||
|
#Document-related message
|
||||||
|
document.updated.successfully=Document updated successfully.
|
||||||
|
document.fetched.successfully=Document fetched successfully.
|
||||||
@@ -47,6 +47,7 @@ call.invalid.date=Data di inizio o fine non valida.
|
|||||||
call.update.successfully=Chiamata aggiornata con successo.
|
call.update.successfully=Chiamata aggiornata con successo.
|
||||||
call.fetch.success=Dettagli della chiamata recuperati con successo.
|
call.fetch.success=Dettagli della chiamata recuperati con successo.
|
||||||
call.not.found=Chiamata non trovata.
|
call.not.found=Chiamata non trovata.
|
||||||
|
score.not.null=Il punteggio non pu<70> essere nullo o zero.
|
||||||
|
|
||||||
# Login-related messages
|
# Login-related messages
|
||||||
login.successfully=Accesso effettuato con successo.
|
login.successfully=Accesso effettuato con successo.
|
||||||
@@ -58,3 +59,38 @@ common_message=qualcosa é andato storto. Per favore riprova
|
|||||||
invalid_signature=Gettone non valido.
|
invalid_signature=Gettone non valido.
|
||||||
invalid_login=Nome utente o password errati
|
invalid_login=Nome utente o password errati
|
||||||
req_validation_er=Errore di convalida
|
req_validation_er=Errore di convalida
|
||||||
|
|
||||||
|
#EvaluationCriteria-related messages
|
||||||
|
evaluation.criteria.not.found=EvaluationCriteria non trovato.
|
||||||
|
evaluation.criteria.created.successfully=EvaluationCriteria creato con successo.
|
||||||
|
evaluation.criteria.fetch.successfully=Recupero EvaluationCriteria riuscito.
|
||||||
|
evaluation.criteria.updated.successfully=EvaluationCriteria aggiornato con successo.
|
||||||
|
evaluation.criteria.deleted.successfully=EvaluationCriteria eliminato con successo.
|
||||||
|
|
||||||
|
#faq-related messages
|
||||||
|
faq.not.found=Faq non trovata.
|
||||||
|
faq.created.successfully=Faq creata con successo.
|
||||||
|
faq.fetched.successfully=Faq recuperata con successo.
|
||||||
|
faq.updated.successfully=Faq aggiornata con successo.
|
||||||
|
faq.deleted.successfully=Faq eliminata con successo.
|
||||||
|
|
||||||
|
#LookUpData-related message
|
||||||
|
lookupdata.not.found=LookUpData non trovato.
|
||||||
|
lookupdata.created.successfully=LookUpData creato correttamente.
|
||||||
|
lookupdata.fetched.successfully=LookUpData recuperato correttamente.
|
||||||
|
lookupdata.updated.successfully=LookUpData aggiornato correttamente.
|
||||||
|
lookupdata.deleted.successfully=LookUpData eliminato correttamente.
|
||||||
|
|
||||||
|
#Document-related message
|
||||||
|
document.updated.successfully=Documento aggiornato con successo.
|
||||||
|
document.fetched.successfully=Documento recuperato con successo.
|
||||||
|
# Password reset messages
|
||||||
|
password.reset.initiated=Reimpostazione della password avviata.
|
||||||
|
password.reset.success=La password <20> stata reimpostata con successo.
|
||||||
|
invalid.token.msg=Il token fornito <20> invalido o scaduto. Si prega di richiedere un nuovo token.
|
||||||
|
current.password.incorrect = La password attuale non <20> corretta.
|
||||||
|
success.password.changed=Password cambiata con successo.
|
||||||
|
logout.successful.msg=Logout riuscito. Sei stato disconnesso con successo.
|
||||||
|
|
||||||
|
update.user.status.success=Lo stato dell'utente <20> stato aggiornato con successo.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user