updated code for faq update api
This commit is contained in:
@@ -148,7 +148,7 @@ public class CallDao {
|
||||
CallEntity callEntity, LookUpDataTypeEnum type) {
|
||||
EvaluationCriteriaEntity criteriaEntity = null;
|
||||
LookUpDataEntity lookupDataEntity = convertLookUpDataRequestIntoLookUpDataEntity(criteriaReq, type);
|
||||
if (criteriaReq.getId() == null && criteriaReq.getId().equals(0l)) {
|
||||
if (criteriaReq.getId() != null && criteriaReq.getId() > 0) {
|
||||
criteriaEntity = evaluationCriteriaRepository.findById(criteriaReq.getId())
|
||||
.orElseThrow(() -> new ResourceNotFoundException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.EVALUATION_CRITERIA_NOT_FOUND)));
|
||||
@@ -224,7 +224,7 @@ public class CallDao {
|
||||
LookUpDataEntity lookupDataEntity = convertLookUpDataRequestIntoLookUpDataEntity(faqReq, type);
|
||||
validateFaqEntity(faqReq.getQuestion());
|
||||
faqEntity.setUser(userEntity);
|
||||
faqEntity.setIsVisible(true);
|
||||
faqEntity.setIsVisible(false);
|
||||
faqEntity.setLookupData(lookupDataEntity);
|
||||
if (faqReq.getIsVisible() != null) {
|
||||
faqEntity.setIsVisible(faqReq.getIsVisible());
|
||||
@@ -249,7 +249,7 @@ public class CallDao {
|
||||
}
|
||||
|
||||
public void validateDocumentEntity(Long documentId) {
|
||||
if (documentId == null) {
|
||||
if (documentId == null || documentId < 1) {
|
||||
throw new CustomValidationException(Status.VALIDATION_ERROR,
|
||||
Translator.toLocale(GepafinConstant.DOCUMENT_ID_NOT_FOUND));
|
||||
}
|
||||
@@ -528,13 +528,13 @@ public class CallDao {
|
||||
updateCallRequest.getDocumentationRequested());
|
||||
setIfUpdated(callEntity::getConfidi, callEntity::setConfidi, updateCallRequest.getConfidi());
|
||||
updateLookUpData(callEntity, updateCallRequest.getAimedTo(), LookUpDataTypeEnum.AIMED_TO);
|
||||
updateFaq(callEntity, updateCallRequest.getFaq(), userEntity);
|
||||
updateFaq(callEntity, updateCallRequest.getFaq(), userEntity, LookUpDataTypeEnum.FAQ);
|
||||
CallResponse createCallResponseBean = getCallResponseBean(callEntity);
|
||||
createCallResponseBean.setCurrentStep(GepafinConstant.STEP_1);
|
||||
return createCallResponseBean;
|
||||
}
|
||||
|
||||
private void updateFaq(CallEntity callEntity, List<FaqReq> faqReqList, UserEntity userEntity) {
|
||||
private void updateFaq(CallEntity callEntity, List<FaqReq> faqReqList, UserEntity userEntity, LookUpDataTypeEnum type) {
|
||||
if (faqReqList == null) {
|
||||
return;
|
||||
}
|
||||
@@ -542,7 +542,7 @@ public class CallDao {
|
||||
List<Long> incomingIds = faqReqList.stream().map(FaqReq::getId).filter(Objects::nonNull).filter(id -> id > 0)
|
||||
.collect(Collectors.toList());
|
||||
existingFaqs.stream().filter(faq -> !incomingIds.contains(faq.getId())).forEach(this::softDeleteFaq);
|
||||
faqReqList.forEach(faqReq -> createOrUpdateFaq(faqReq, callEntity, userEntity));
|
||||
faqReqList.forEach(faqReq -> createOrUpdateFaq(faqReq, callEntity, userEntity, type));
|
||||
|
||||
}
|
||||
|
||||
@@ -551,8 +551,10 @@ public class CallDao {
|
||||
faqRepository.save(faqEntity);
|
||||
}
|
||||
|
||||
private void createOrUpdateFaq(FaqReq faqReq, CallEntity callEntity, UserEntity userEntity) {
|
||||
private void createOrUpdateFaq(FaqReq faqReq, CallEntity callEntity, UserEntity userEntity, LookUpDataTypeEnum type) {
|
||||
FaqEntity faqEntity = null;
|
||||
|
||||
LookUpDataEntity lookupDataEntity = convertLookUpDataRequestIntoLookUpDataEntity(faqReq, type);
|
||||
|
||||
if (isExistingFaq(faqReq)) {
|
||||
faqEntity = faqRepository.findById(faqReq.getId())
|
||||
@@ -562,10 +564,14 @@ public class CallDao {
|
||||
faqEntity = new FaqEntity();
|
||||
faqEntity.setCall(callEntity);
|
||||
faqEntity.setUser(userEntity);
|
||||
faqEntity.setLookupData(lookupDataEntity);
|
||||
faqEntity.setIsVisible(false);
|
||||
faqEntity.setIsDeleted(false);
|
||||
}
|
||||
|
||||
|
||||
if (Boolean.FALSE.equals(faqEntity.getLookupData().getId().equals(lookupDataEntity.getId()))) {
|
||||
faqEntity.setLookupData(lookupDataEntity);
|
||||
}
|
||||
setIfUpdated(faqEntity::getQuestionShort, faqEntity::setQuestionShort, faqReq.getQuestionShort());
|
||||
setIfUpdated(faqEntity::getQuestion, faqEntity::setQuestion, faqReq.getQuestion());
|
||||
setIfUpdated(faqEntity::getResponseShort, faqEntity::setResponseShort, faqReq.getResponseShort());
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface DocumentApi {
|
||||
@ApiResponse(responseCode = "400", description = "Bad Request", content = @Content(mediaType = MediaType.APPLICATION_JSON_VALUE, examples = {
|
||||
@ExampleObject(value = ErrorConstants.BADREQUEST_ERROR_EXAMPLE) }))})
|
||||
@PostMapping(value = "/uploadFile/call/{callId}", 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, @Parameter(description = "call id", required = true) @PathVariable("callId") Long callId, @RequestParam("file") List<MultipartFile> files, @RequestParam("documentType") DocumentTypeEnum documentTypeEnum) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public interface DocumentApi {
|
||||
@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) {
|
||||
default ResponseEntity<Response<DocumentResponseBean>> updateDocument(HttpServletRequest httpServletRequest, @Parameter(description = "document id", required = true) @PathVariable("id") Long documentId, @RequestParam("file") MultipartFile file, @RequestParam("documentType") DocumentTypeEnum documentTypeEnum) {
|
||||
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
|
||||
}
|
||||
@Operation(summary = "API to get document by id",
|
||||
@@ -73,6 +73,6 @@ public interface DocumentApi {
|
||||
@GetMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE)
|
||||
ResponseEntity<Response<DocumentResponseBean>> getDocumentById(HttpServletRequest request,
|
||||
@Parameter(description = "document id", required = true)
|
||||
@PathVariable Long id);
|
||||
@PathVariable("id") Long id);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user