Unverified Commit 3795d61b authored by Shishir Suman's avatar Shishir Suman Committed by GitHub
Browse files

Merge pull request #143 from Radheshhathwar/development

Development
Showing with 26 additions and 4 deletions
+26 -4
......@@ -6,7 +6,6 @@ import com.tarento.upsmf.examsAndAdmissions.model.ResponseDto;
import com.tarento.upsmf.examsAndAdmissions.model.dto.ExamCycleWithExamsDTO;
import com.tarento.upsmf.examsAndAdmissions.model.dto.SearchExamCycleDTO;
import com.tarento.upsmf.examsAndAdmissions.repository.CourseRepository;
import com.tarento.upsmf.examsAndAdmissions.repository.ExamEntityRepository;
import com.tarento.upsmf.examsAndAdmissions.service.ExamCycleService;
import com.tarento.upsmf.examsAndAdmissions.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -106,5 +105,15 @@ public class ExamCycleController {
return new ResponseEntity<>(response, response.getResponseCode());
}
@GetMapping("/examCyclesByCouses")
public ResponseEntity<ResponseDto> getExamCycleDetailsByInstitute(@RequestParam Long instituteId){
try {
List<ExamCycle> examDetails = service.getExamCyclesByExamCycleAndCourse(instituteId);
return FeeController.handleSuccessResponse(examDetails);
}catch (Exception e){
return FeeController.handleErrorResponse(e);
}
}
}
\ No newline at end of file
......@@ -71,7 +71,6 @@ public class FeeController {
return handleErrorResponse(e);
}
}
public static ResponseEntity<ResponseDto> handleSuccessResponse(Object response) {
ResponseParams params = new ResponseParams();
params.setStatus(HttpStatus.OK.getReasonPhrase());
......
......@@ -5,6 +5,7 @@ import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import java.util.List;
import java.util.Optional;
public interface CourseRepository extends JpaRepository<Course, Long> {
......@@ -14,4 +15,6 @@ public interface CourseRepository extends JpaRepository<Course, Long> {
Optional<Course> findByCourseNameIgnoreCase(@Param("courseName") String courseName);
Course findByInstituteId(Long id);
List<Course> findAllByInstituteId(Long instituteId);
}
......@@ -26,4 +26,6 @@ public interface ExamCycleRepository extends JpaRepository<ExamCycle, Long> {
@Query(value = "select * from exam_cycle ec where ec.course_id =:courseId and date_part('year', ec.start_date) = :startYear and date_part('year', ec.end_date) <= :endYear", nativeQuery = true)
List<ExamCycle> searchExamCycleByCourseIdAndStartYearAndEndYear(@Param("courseId") String courseId, @Param("startYear") Integer startYear, @Param("endYear") Integer endYear);
List<ExamCycle> findByCourseInAndEndDateAfter(List<Course> courses, LocalDate currentDate);
}
......@@ -23,6 +23,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.validation.ConstraintViolationException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.time.format.DateTimeFormatter;
......@@ -444,5 +445,9 @@ public class ExamCycleService {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(response);
}
}
}
\ No newline at end of file
public List<ExamCycle> getExamCyclesByExamCycleAndCourse(Long instituteId) {
List<Course> courses = courseRepository.findAllByInstituteId(instituteId);
LocalDate currentDate = LocalDate.now();
return repository.findByCourseInAndEndDateAfter(courses, currentDate);
}
}
......@@ -27,6 +27,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
......@@ -87,6 +88,9 @@ public class FeeServiceImpl implements FeeService {
@Autowired
private StudentExamRegistrationRepository studentExamRegistrationRepository;
@Autowired
private CourseRepository courseRepository;
/**
* API to save and return payment redirect URL
*
......
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