Commit c0930f07 authored by jay pratap singh's avatar jay pratap singh
Browse files

changes in student enrolment enpoints

parent 178666da
1 merge request!8adding code for pending verifications of enrolments
Showing with 36 additions and 13 deletions
+36 -13
package com.tarento.upsmf.examsAndAdmissions;
import org.springframework.context.annotation.Configuration;
import org.springframework.format.FormatterRegistry;
import org.springframework.format.datetime.standard.DateTimeFormatterRegistrar;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class DateTimeFormatConfiguration implements WebMvcConfigurer {
@Override
public void addFormatters(FormatterRegistry registry) {
DateTimeFormatterRegistrar registrar = new DateTimeFormatterRegistrar();
registrar.setUseIsoFormat(true);
registrar.registerFormatters(registry);
}
}
......@@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
import javax.validation.Valid;
import java.io.IOException;
import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
......@@ -90,14 +91,15 @@ public class StudentController {
}
@PutMapping("/{studentId}/verify")
public ResponseEntity<Student> verifyStudent(@PathVariable Long studentId, @RequestParam("status") VerificationStatus status, @RequestParam("remarks") String remarks) {
public ResponseEntity<Student> verifyStudent(@PathVariable Long studentId, @RequestParam("status") VerificationStatus status, @RequestParam("remarks") String remarks,@RequestParam("verificationDate") LocalDate verificationDate) {
Student student = studentService.findById(studentId);
student.setVerificationStatus(status);
student.setAdminRemarks(remarks);
student.setVerificationDate(verificationDate);
studentService.save(student);
return ResponseEntity.ok(student);
}
@GetMapping("/pending-verification")
@GetMapping("/pendingVerification")
public ResponseEntity<List<Student>> getStudentsPendingVerification() {
List<Student> students = studentService.findByVerificationStatus(VerificationStatus.PENDING);
return ResponseEntity.ok(students);
......
......@@ -2,6 +2,7 @@ package com.tarento.upsmf.examsAndAdmissions.model.dto;
import lombok.*;
import org.springframework.web.multipart.MultipartFile;
import java.time.LocalDate;
@Getter
@Setter
......@@ -15,12 +16,12 @@ public class StudentDto {
private String courseName;
private String session;
private String examBatch;
private String admissionDate;
private LocalDate admissionDate;
private String firstName;
private String surname;
private String motherName;
private String fatherName;
private String dateOfBirth;
private LocalDate dateOfBirth;
private String gender;
private String caste;
private String category;
......@@ -40,11 +41,11 @@ public class StudentDto {
private String intermediateRollNo;
private String intermediateYearOfPassing;
private String adminRemarks;
private LocalDate enrollmentDate;
private LocalDate verificationDate;
private MultipartFile highSchoolMarksheet;
private MultipartFile highSchoolCertificate;
private MultipartFile intermediateMarksheet;
private MultipartFile intermediateCertificate;
}
......@@ -11,7 +11,7 @@ import java.util.List;
@Repository
public interface StudentRepository extends JpaRepository<Student, Long> {
List<Student> findByVerificationStatus(VerificationStatus status);
List<Student> findByVerificationDateBeforeAndVerificationStatusNot(LocalDate date, VerificationStatus status);
List<Student> findByEnrollmentDateBeforeAndVerificationStatus(LocalDate date, VerificationStatus status);
List<Student> findByVerificationDateBeforeAndVerificationStatus(LocalDate date, VerificationStatus status);
......
......@@ -22,6 +22,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.UUID;
......@@ -133,20 +134,22 @@ public class StudentService {
}
public List<Student> updateStudentStatusToClosed() {
LocalDate cutoffDate = LocalDate.now().minusDays(14);
List<Student> studentsToClose = studentRepository.findByVerificationDateBeforeAndVerificationStatusNot(cutoffDate, VerificationStatus.CLOSED);
List<Student> rejectedStudents = studentRepository.findByVerificationDateBeforeAndVerificationStatus(cutoffDate, VerificationStatus.REJECTED);
logger.info("Students found to close: " + studentsToClose.size());
logger.info("Rejected students found to potentially close: " + rejectedStudents.size());
for (Student student : studentsToClose) {
List<Student> studentsToUpdate = new ArrayList<>();
for (Student student : rejectedStudents) {
student.setVerificationStatus(VerificationStatus.CLOSED);
studentsToUpdate.add(student);
}
return studentRepository.saveAll(studentsToClose);
return studentRepository.saveAll(studentsToUpdate);
}
public List<Student> getStudentsPendingForMoreThan21Days() {
LocalDate twentyOneDaysAgo = LocalDate.now().minusDays(21);
return studentRepository.findByVerificationDateBeforeAndVerificationStatus(twentyOneDaysAgo, VerificationStatus.PENDING);
return studentRepository.findByEnrollmentDateBeforeAndVerificationStatus(twentyOneDaysAgo, VerificationStatus.PENDING);
}
private void deleteFile(String filePath) {
......
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