Commit 0b31c496 authored by Radheshhathwar's avatar Radheshhathwar
Browse files

CHanged request params for result api

1 merge request!170CHanged request params for result api
Showing with 9 additions and 4 deletions
+9 -4
......@@ -48,8 +48,8 @@ public class StudentResultController {
}
@GetMapping("/results")
public ResponseEntity<ResponseDto> viewResults(@RequestParam String enrolmentNumber, @RequestParam Long examCycleId) {
return new ResponseEntity<>(studentResultService.findByEnrollmentNumberAndDateOfBirth(enrolmentNumber, examCycleId), HttpStatus.OK);
public ResponseEntity<ResponseDto> viewResults(@RequestParam Long StudentId, @RequestParam Long examCycleId) {
return new ResponseEntity<>(studentResultService.findByStudentIdAndExamCycleId(StudentId, examCycleId), HttpStatus.OK);
}
@PostMapping("/requestRetotalling")
......
......@@ -3,6 +3,8 @@ package com.tarento.upsmf.examsAndAdmissions.repository;
import com.tarento.upsmf.examsAndAdmissions.model.Student;
import com.tarento.upsmf.examsAndAdmissions.enums.VerificationStatus;
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 java.time.LocalDate;
......@@ -18,4 +20,6 @@ public interface StudentRepository extends JpaRepository<Student, Long> {
Optional<Student> findByEnrollmentNumber(String enrollmentNumber);
Optional<Student> findByKeycloakId(String keycloakId);
@Query("SELECT s.enrollmentNumber FROM Student s WHERE s.id = :studentId")
String getEnrollmentNumberById(@Param("studentId") Long studentId);
}
......@@ -406,11 +406,12 @@ public class StudentResultService {
return response;
}
public ResponseDto findByEnrollmentNumberAndDateOfBirth(String enrollmentNumber, Long examCycleId) {
public ResponseDto findByStudentIdAndExamCycleId(Long studentId, Long examCycleId) {
ResponseDto response = new ResponseDto(Constants.API_FIND_BY_ENROLLMENT_NUMBER_AND_DOB);
// List<StudentResult> studentResultList = studentResultRepository.findByStudent_EnrollmentNumberAndExamCycle_IdAndPublished(enrollmentNumber, examCycleId, true);
String examCycleName = examCycleRepository.getExamCycleNameById(examCycleId);
String enrollmentNumber = studentRepository.getEnrollmentNumberById(studentId);
List<StudentResult> studentResultList = studentResultRepository.findByStudent_EnrollmentNumberAndExamCycleNameAndPublished(enrollmentNumber, examCycleName, true);
if (!studentResultList.isEmpty()) {
......@@ -420,7 +421,7 @@ public class StudentResultService {
response.put(Constants.RESPONSE, studentResultDTO);
response.setResponseCode(HttpStatus.OK);
} else {
ResponseDto.setErrorResponse(response, "RESULT_NOT_FOUND", "No result found for the given enrollment number and date of birth.", HttpStatus.NOT_FOUND);
ResponseDto.setErrorResponse(response, "RESULT_NOT_FOUND", "No result found for the given enrollment number and examCycle.", HttpStatus.NOT_FOUND);
}
return response;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment