Merge pull request #218 from Kitzanos/feature/GEPAFINBE-170

GEPAFINBE-170 (Added companyId in next-prev API)
This commit is contained in:
Rinaldo
2025-02-18 09:07:32 +01:00
committed by GitHub
7 changed files with 27 additions and 11 deletions

View File

@@ -1720,5 +1720,11 @@ public class ApplicationDao {
// Step 4: Evaluate the mathematical expression
return Utils.evaluateExpression(expression);
}
public ApplicationEntity validateApplicationWithCompany(Long id,Long companyId) {
ApplicationEntity application=applicationRepository.findByIdAndCompanyIdAndIsDeletedFalse(id,companyId);
if (application==null){
throw new CustomValidationException(Status.VALIDATION_ERROR,Translator.toLocale(GepafinConstant.PERMISSION_DENIED));
}
return application;
}
}

View File

@@ -248,7 +248,7 @@ public class FlowFormDao {
//
// return applicationFormEntities.isEmpty() ? null : applicationFormEntities.get(0).getForm().getId();
// }
public NextOrPreviousFormResponse getNextOrPreviousForm(ApplicationEntity applicationEntity, Long formId,
public NextOrPreviousFormResponse getNextOrPreviousForm(ApplicationEntity applicationEntity,Long companyId, Long formId,
FormActionEnum action) {
Long calculatedFormId = null;
FormEntity formEntity = null;

View File

@@ -162,4 +162,6 @@ public interface ApplicationRepository extends JpaRepository<ApplicationEntity,
List<ApplicationEntity> findByUserIdAndUserWithCompany_IdAndCall_IdAndIsDeletedFalseAndStatusNot(
Long userId, Long userWithCompanyId, Long callId, String status
);
ApplicationEntity findByIdAndCompanyIdAndIsDeletedFalse(Long id,Long companyId);
}

View File

@@ -29,7 +29,7 @@ public interface ApplicationService {
public ApplicationResponse createApplication(HttpServletRequest request, Long companyId, ApplicationRequest applicationRequest, Long callId);
public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId, Long formId, FormActionEnum action);
public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId,Long companyId, Long formId, FormActionEnum action);
public ApplicationResponse updateApplicationStatus(HttpServletRequest request, Long applicationId, ApplicationStatusTypeEnum status);
@@ -45,4 +45,5 @@ public interface ApplicationService {
PageableResponseBean<List<ApplicationResponse>> getAllApplicationByPagination(HttpServletRequest request, Long callId, Long companyId, ApplicationPageableRequestBean applicationPageableRequestBean);
public ApplicationEntity validateApplicationWithCompany(Long applicationId,Long companyId);
}

View File

@@ -74,11 +74,12 @@ public class ApplicationServiceImpl implements ApplicationService {
}
@Override
public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId, Long formId,
FormActionEnum action) {
ApplicationEntity applicationEntity = validateApplication(applicationId);
validator.validateUserWithCompany(request, applicationEntity.getCompanyId());
return flowFormDao.getNextOrPreviousForm(applicationEntity, formId, action);
public NextOrPreviousFormResponse getNextOrPreviousForm(HttpServletRequest request, Long applicationId, Long companyId, Long formId,
FormActionEnum action) {
validator.validateUserWithCompany(request, companyId);
validateApplication(applicationId);
ApplicationEntity applicationEntity = validateApplicationWithCompany(applicationId, companyId);
return flowFormDao.getNextOrPreviousForm(applicationEntity, companyId, formId, action);
}
@Override
@@ -135,4 +136,9 @@ public class ApplicationServiceImpl implements ApplicationService {
return applicationDao.getAllApplicationByPagination(userEntity,callId,companyId,applicationPageableRequestBean);
}
@Override
@Transactional(rollbackFor = Exception.class)
public ApplicationEntity validateApplicationWithCompany(Long applicationId,Long companyId) {
return applicationDao.validateApplicationWithCompany(applicationId,companyId);
}
}

View File

@@ -114,6 +114,7 @@ public interface ApplicationApi {
@GetMapping(value = "/{applicationId}/form/next-previous", produces = "application/json")
ResponseEntity<Response<NextOrPreviousFormResponse>> getNextOrPreviousForm(HttpServletRequest request,
@Parameter(description = "The applicaltion id", required = true) @PathVariable("applicationId") Long applicationId,
@Parameter(description = "The company id", required = true) @RequestParam("companyId") Long companyId,
@Parameter(description = "The form id", required = false) @RequestParam(value = "formId", required = false) Long formId,
@RequestParam(value = "action", required = false) FormActionEnum action);

View File

@@ -116,13 +116,13 @@ public class ApplicationApiController implements ApplicationApi {
}
@Override
public ResponseEntity<Response<NextOrPreviousFormResponse>> getNextOrPreviousForm(HttpServletRequest request, Long applicationId,
public ResponseEntity<Response<NextOrPreviousFormResponse>> getNextOrPreviousForm(HttpServletRequest request, Long applicationId,Long companyId,
Long formId, FormActionEnum action) {
/** This code is responsible for creating user action logs for the "get next or previous form" operation. **/
loggingUtil.logUserAction(UserActionRequest.builder().request(request).actionType(UserActionLogsEnum.VIEW).actionContext(UserActionContextEnum.GET_NEXT_PREVIOUS_FORM).build());
NextOrPreviousFormResponse data = applicationService.getNextOrPreviousForm(request, applicationId, formId, action);
NextOrPreviousFormResponse data = applicationService.getNextOrPreviousForm(request, applicationId,companyId, formId, action);
log.info("Get Next Or Previous Form ");
return ResponseEntity.status(HttpStatus.OK)
.body(new Response<>(data, Status.SUCCESS, Translator.toLocale(GepafinConstant.GET_APPLICATION_SUCCESS_MSG)));