Unverified Commit 2618ceb9 authored by Shishir Suman's avatar Shishir Suman Committed by GitHub
Browse files

Merge branch 'development' into development

Showing with 281 additions and 54 deletions
+281 -54
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="examAndAdmission" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="common-util" target="11" />
<module name="examsAndAdmissions" target="1.5" />
<module name="upsmf-entity" target="11" />
<module name="upsmf-es-utils" target="11" />
</bytecodeTargetLevel>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="examAndAdmission" options="-parameters" />
<module name="upsmf-entity" options="-parameters" />
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/common-util/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/common-util/src/main/resources" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/upsmf-entity/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/upsmf-es-utils/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/upsmf-es-utils/src/main/resources" charset="UTF-8" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="cloud-store" />
<option name="name" value="cloud-store" />
<option name="url" value="https://oss.sonatype.org/content/repositories/orgsunbird-1021" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
package com.tarento.upsmf.examsAndAdmissions.controller;
import com.tarento.upsmf.examsAndAdmissions.model.ResponseDto;
import com.tarento.upsmf.examsAndAdmissions.model.dto.CourseSubjectMappingDTO;
import com.tarento.upsmf.examsAndAdmissions.service.CourseSubjectMappingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/v1/admin/courseSubjectMap")
public class CourseSubjectMappingController {
@Autowired
private CourseSubjectMappingService courseSubjectMappingService;
@PostMapping("/create")
public ResponseEntity<ResponseDto> createMapping(@RequestBody CourseSubjectMappingDTO courseSubjectMappingDTO) {
ResponseDto response = courseSubjectMappingService.create(courseSubjectMappingDTO);
return new ResponseEntity<>(response, response.getResponseCode());
}
@GetMapping("/all")
public ResponseEntity<ResponseDto> getAllMapping() {
ResponseDto response = courseSubjectMappingService.getAllMapping();
return new ResponseEntity<>(response, response.getResponseCode());
}
@GetMapping("/list")
public ResponseEntity<ResponseDto> getAllMappingByFilter(@RequestParam Long courseId) {
ResponseDto response = courseSubjectMappingService.getAllMappingByFilter(courseId);
return new ResponseEntity<>(response, response.getResponseCode());
}
@GetMapping("/{id}")
public ResponseEntity<ResponseDto> getCourseSubjectMappingById(@PathVariable Long id) {
ResponseDto response = courseSubjectMappingService.getCourseSubjectMappingById(id);
return new ResponseEntity<>(response, response.getResponseCode());
}
@DeleteMapping("/delete/{id}")
public ResponseEntity<ResponseDto> delete(@PathVariable Long id) {
ResponseDto response = courseSubjectMappingService.deleteCourseSubjectMapping(id);
return new ResponseEntity<>(response, response.getResponseCode());
}
}
......@@ -3,6 +3,7 @@ package com.tarento.upsmf.examsAndAdmissions.controller;
import com.tarento.upsmf.examsAndAdmissions.model.Exam;
import com.tarento.upsmf.examsAndAdmissions.model.ResponseDto;
import com.tarento.upsmf.examsAndAdmissions.service.ExamService;
import com.tarento.upsmf.examsAndAdmissions.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
......@@ -18,8 +19,8 @@ public class ExamController {
private ExamService examService;
@PostMapping("/create")
public ResponseEntity<?> createExam(@RequestBody Exam exam) {
ResponseDto response = examService.createExam(exam);
public ResponseEntity<?> createExam(@RequestBody Exam exam, @RequestAttribute(Constants.Parameters.USER_ID) String userId) {
ResponseDto response = examService.createExam(exam, userId);
return new ResponseEntity<>(response, response.getResponseCode());
}
@GetMapping("/list")
......@@ -41,8 +42,8 @@ public class ExamController {
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateExam(@PathVariable Long id, @RequestBody Exam exam) {
ResponseDto response = examService.updateExam(id, exam);
public ResponseEntity<?> updateExam(@PathVariable Long id, @RequestBody Exam exam, @RequestAttribute(Constants.Parameters.USER_ID) String userId) {
ResponseDto response = examService.updateExam(id, exam, userId);
return new ResponseEntity<>(response, response.getResponseCode());
}
......
......@@ -9,9 +9,11 @@ import com.tarento.upsmf.examsAndAdmissions.service.ExamCycleService;
import com.tarento.upsmf.examsAndAdmissions.util.Constants;
import org.codehaus.jettison.json.JSONArray;
import org.springframework.beans.factory.annotation.Autowired;
import com.tarento.upsmf.examsAndAdmissions.util.Constants;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import com.tarento.upsmf.examsAndAdmissions.model.dto.*;
import org.springframework.web.multipart.MultipartFile;
import java.util.HashMap;
......@@ -31,9 +33,9 @@ public class ExamCycleController {
@PostMapping("/create")
public ResponseEntity<?> createExamCycle(@RequestBody ExamCycle examCycle) {
public ResponseEntity<?> createExamCycle(@RequestBody ExamCycle examCycle, @RequestAttribute(Constants.Parameters.USER_ID) String userId) {
try {
ExamCycle createdExamCycle = service.createExamCycle(examCycle);
ExamCycle createdExamCycle = service.createExamCycle(examCycle,userId);
return new ResponseEntity<>(createdExamCycle, HttpStatus.CREATED);
} catch (Exception e) {
return new ResponseEntity<>("Failed to create ExamCycle.", HttpStatus.INTERNAL_SERVER_ERROR);
......@@ -66,9 +68,9 @@ public class ExamCycleController {
}
@PutMapping("/update/{id}")
public ResponseEntity<?> updateExamCycle(@PathVariable Long id, @RequestBody ExamCycle examCycle) {
public ResponseEntity<?> updateExamCycle(@PathVariable Long id, @RequestBody ExamCycle examCycle, @RequestAttribute(Constants.Parameters.USER_ID) String userId) {
try {
ExamCycle updatedExamCycle = service.updateExamCycle(id, examCycle);
ExamCycle updatedExamCycle = service.updateExamCycle(id, examCycle, userId);
if (updatedExamCycle == null) {
return new ResponseEntity<>("ExamCycle not found with ID: " + id, HttpStatus.NOT_FOUND);
}
......@@ -99,13 +101,13 @@ public class ExamCycleController {
}
@PostMapping("/{id}/addExam")
public ResponseEntity<?> addExamToCycle(@PathVariable Long id, @RequestBody List<Exam> exam) {
public ResponseEntity<?> addExamToCycle(@PathVariable Long id, @RequestBody List<Exam> exams, @RequestAttribute(Constants.Parameters.USER_ID) String userId) {
try {
ExamCycle examCycle = service.addExamsToCycle(id, exam);
ExamCycle examCycle = service.addExamsToCycle(id, exams, userId);
if (examCycle == null) {
return new ResponseEntity<>("ExamCycle not found with ID: " + id, HttpStatus.NOT_FOUND);
}
return new ResponseEntity<>(exam, HttpStatus.CREATED);
return new ResponseEntity<>(exams, HttpStatus.CREATED);
} catch (Exception e) {
return new ResponseEntity<>("Failed to add exam to ExamCycle with ID: " + id, HttpStatus.INTERNAL_SERVER_ERROR);
}
......@@ -122,6 +124,33 @@ public class ExamCycleController {
return new ResponseEntity<>("Failed to remove exam from ExamCycle with ID: " + id, HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@PutMapping("/{id}/publish")
public ResponseEntity<?> publishExamCycle(@PathVariable Long id) {
try {
ExamCycle publishedExamCycle = service.publishExamCycle(id);
if (publishedExamCycle == null) {
return new ResponseEntity<>("ExamCycle not found with ID: " + id, HttpStatus.NOT_FOUND);
}
return new ResponseEntity<>(publishedExamCycle, HttpStatus.OK);
} catch (Exception e) {
return new ResponseEntity<>("Failed to publish ExamCycle with ID: " + id, HttpStatus.INTERNAL_SERVER_ERROR);
}
}
@PostMapping("/createExamCycleWithExams")
public ResponseEntity<?> createExamCycleWithExams(@RequestBody ExamCycleWithExamsDTO examCycleWithExamsDTO, @RequestAttribute(Constants.Parameters.USER_ID) String userId) {
try {
// Create the ExamCycle
ExamCycle createdExamCycle = service.createExamCycle(examCycleWithExamsDTO.getExamCycle(), userId);
// Add Exams to the ExamCycle
service.addExamsToCycle(createdExamCycle.getId(), examCycleWithExamsDTO.getExams(), userId);
return ResponseEntity.ok("ExamCycle with Exams created successfully.");
} catch (Exception e) {
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR)
.body("Failed to create ExamCycle with Exams.");
}
}
@PostMapping("/bulkUpload")
public ResponseEntity<Map<String, Object>> processBulkExamUploads(@RequestParam("file") MultipartFile file, @RequestParam("fileType") String fileType) {
Map<String, Object> response = new HashMap<>();
......
......@@ -7,7 +7,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/institutes")
@RequestMapping("/api/v1/admin/institutes")
public class InstituteController {
private final InstituteService instituteService;
......
package com.tarento.upsmf.examsAndAdmissions.controller;
import com.tarento.upsmf.examsAndAdmissions.model.InstituteCourseMapping;
import com.tarento.upsmf.examsAndAdmissions.model.ResponseDto;
import com.tarento.upsmf.examsAndAdmissions.model.dto.InstituteCourseMappingDTO;
import com.tarento.upsmf.examsAndAdmissions.service.InstituteCourseMappingService;
......@@ -9,7 +8,9 @@ import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/instituteCourseMap")
@RequestMapping("/api/v1/admin/instituteCourseMap")
public class InstituteCourseMappingController {
@Autowired
......
......@@ -2,7 +2,7 @@ package com.tarento.upsmf.examsAndAdmissions.controller;
import com.tarento.upsmf.examsAndAdmissions.model.Student;
import com.tarento.upsmf.examsAndAdmissions.model.ResponseDto;
import com.tarento.upsmf.examsAndAdmissions.model.VerificationStatus;
import com.tarento.upsmf.examsAndAdmissions.enums.VerificationStatus;
import com.tarento.upsmf.examsAndAdmissions.model.dto.StudentDto;
import com.tarento.upsmf.examsAndAdmissions.service.StudentService;
import com.tarento.upsmf.examsAndAdmissions.util.Constants;
......@@ -11,12 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.validation.Valid;
import java.io.IOException;
import java.time.LocalDate;
import java.util.List;
import java.util.Optional;
......
......@@ -2,6 +2,7 @@ package com.tarento.upsmf.examsAndAdmissions.controller;
import com.tarento.upsmf.examsAndAdmissions.model.dto.StudentExamRegistrationDTO;
import com.tarento.upsmf.examsAndAdmissions.service.StudentExamRegistrationService;
import com.tarento.upsmf.examsAndAdmissions.util.Constants;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
......@@ -19,8 +20,9 @@ public class StudentExamRegistrationController {
private StudentExamRegistrationService registrationService;
@PostMapping("/register")
public ResponseEntity<?> registerStudentForExam(@RequestBody List<StudentExamRegistrationDTO> registrationDetails) {
ResponseEntity<?> registration = registrationService.registerStudentsForExams(registrationDetails);
public ResponseEntity<?> registerStudentForExam(@RequestBody List<StudentExamRegistrationDTO> registrationDetails, @RequestAttribute(Constants.Parameters.USER_ID) String userId) {
ResponseEntity<?> registration = registrationService.registerStudentsForExams(registrationDetails, userId);
return new ResponseEntity<>(registration, HttpStatus.CREATED);
}
......
package com.tarento.upsmf.examsAndAdmissions.controller;
import com.tarento.upsmf.examsAndAdmissions.model.Exam;
import com.tarento.upsmf.examsAndAdmissions.enums.RetotallingStatus;
import com.tarento.upsmf.examsAndAdmissions.model.RetotallingRequest;
import com.tarento.upsmf.examsAndAdmissions.model.Student;
import com.tarento.upsmf.examsAndAdmissions.model.StudentResult;
......@@ -20,9 +22,8 @@ import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.time.LocalDate;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.time.LocalDateTime;
@RestController
@RequestMapping("/api/v1/studentResults")
......@@ -31,7 +32,6 @@ public class StudentResultController {
@Autowired
private StudentResultService studentResultService;
@Autowired
private RetotallingService retotallingService;
@Autowired
......@@ -107,37 +107,14 @@ public class StudentResultController {
}
}
@PostMapping("/retotalling")
public ResponseEntity<String> requestRetotalling(@RequestBody RetotallingRequest retotallingRequest) {
@PostMapping("/requestRetotalling")
public ResponseEntity<?> requestRetotalling(@RequestBody RetotallingRequest request) {
try {
// Fetch the student from the database using the enrollmentNumber
Student existingStudent = studentResultService.fetchStudentByEnrollmentNumber(retotallingRequest.getStudent().getEnrollmentNumber());
if (existingStudent == null) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Student not found.");
}
// Set the fetched student to the retotallingRequest
retotallingRequest.setStudent(existingStudent);
// Check for each exam
for (Exam exam : retotallingRequest.getExams()) {
// Check if payment was successful
if (!retotallingService.isPaymentSuccessful(existingStudent.getEnrollmentNumber(), exam.getId())) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Payment not completed for exam ID: " + exam.getId() + ". Please make the payment before requesting re-totalling.");
}
// Check if a re-totalling request already exists
if (retotallingService.hasAlreadyRequestedRetotalling(existingStudent.getEnrollmentNumber(), exam.getId())) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("You have already requested re-totalling for exam ID: " + exam.getId());
}
}
// Save the re-totalling request
retotallingService.requestRetotalling(retotallingRequest);
return ResponseEntity.ok("Re-totalling request submitted successfully.");
RetotallingRequest result = retotallingService.requestRetotalling(request);
return ResponseEntity.ok(result);
} catch (RuntimeException e) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body(e.getMessage());
} catch (Exception e) {
log.error("Error processing re-totalling request", e);
return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("Failed to process re-totalling request.");
}
}
......
package com.tarento.upsmf.examsAndAdmissions.controller;
import com.tarento.upsmf.examsAndAdmissions.model.ResponseDto;
import com.tarento.upsmf.examsAndAdmissions.model.Subject;
import com.tarento.upsmf.examsAndAdmissions.service.SubjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/v1/admin/subject")
public class SubjectController {
@Autowired
private SubjectService subjectService;
@PostMapping("/create")
public ResponseEntity<ResponseDto> createSubject(@RequestBody Subject subject) {
ResponseDto response = subjectService.createSubject(subject);
return new ResponseEntity<>(response, response.getResponseCode());
}
@GetMapping("/list")
public ResponseEntity<ResponseDto> getAllSubjects() {
ResponseDto response = subjectService.getAllSubjects();
return new ResponseEntity<>(response, response.getResponseCode());
}
@GetMapping("/list/{id}")
public ResponseEntity<ResponseDto> getSubjectById(@PathVariable Long id) {
ResponseDto response = subjectService.getSubjectById(id);
return new ResponseEntity<>(response, response.getResponseCode());
}
@DeleteMapping("/delete/{id}")
public ResponseEntity<ResponseDto> deleteSubjectById(@PathVariable Long id) {
ResponseDto response = subjectService.deleteSubjectById(id);
return new ResponseEntity<>(response, response.getResponseCode());
}
}
package com.tarento.upsmf.examsAndAdmissions.enums;
public enum ExamCycleStatus {
DRAFT, PUBLISHED
}
\ No newline at end of file
package com.tarento.upsmf.examsAndAdmissions.enums;
public enum RetotallingStatus {
PENDING,
COMPLETED
}
\ No newline at end of file
package com.tarento.upsmf.examsAndAdmissions.model;
package com.tarento.upsmf.examsAndAdmissions.enums;
public enum VerificationStatus {
PENDING, VERIFIED, CLOSED, REJECTED
......
package com.tarento.upsmf.examsAndAdmissions.model;
import lombok.Data;
import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
@Entity
@Table(name = "course_subject_mapping")
@Data
public class CourseSubjectMapping implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "subject_id", referencedColumnName = "id")
private Subject subject;
@OneToOne(cascade = CascadeType.ALL, fetch = FetchType.EAGER)
@JoinColumn(name = "course_id", referencedColumnName = "id")
private Course course;
@Column(name = "created_by")
private String createdBy;
@Column(name = "created_on")
private Timestamp createdOn;
@Column(name = "modified_by")
private String modifiedBy;
@Column(name = "modified_on")
private Timestamp modifiedOn;
@Column(name = "obsolete", nullable = false, columnDefinition = "int default 0")
private Integer obsolete = 0;
}
package com.tarento.upsmf.examsAndAdmissions.model;
import com.tarento.upsmf.examsAndAdmissions.enums.VerificationStatus;
import lombok.Getter;
import lombok.Setter;
......
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