From 464f8471c35b4410624df3fc8e394a94301f75ce Mon Sep 17 00:00:00 2001 From: Agit Rubar Demir <61833677+agitrubard@users.noreply.github.com> Date: Thu, 28 Apr 2022 23:03:31 +0300 Subject: [PATCH] Save Student Lesson Notes Fixes (#97) * getStudentLessonRegistrationDetailByStudentId Method Has Been Created in StudentLessonRegistrationService * getStudentLessonRegistrationDetailByStudentId Method Has Been Created in StudentLessonRegistrationController & GET Endpoints Have Been Updated * midtermNoteState, finalNoteState and resitNoteState Fields Have Been Added to generateSaveEntity Method * midtermNoteState, finalNoteState and resitNoteState Fields Have Been Added to saveStudentLessonNote Method SQL Query Parameters --- .../StudentLessonRegistrationController.java | 16 +++++++++------- ...dentLessonRegistrationControllerEndpoint.java | 4 ++-- .../StudentLessonRegistrationService.java | 2 +- .../StudentLessonRegistrationServiceImpl.java | 9 ++++++--- .../StudentLessonNoteInfoConverter.java | 3 +++ .../impl/StudentLessonNoteRepositoryImpl.java | 3 +++ 6 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/graduationproject/studentinformationsystem/university/lesson/student/registration/controller/StudentLessonRegistrationController.java b/src/main/java/com/graduationproject/studentinformationsystem/university/lesson/student/registration/controller/StudentLessonRegistrationController.java index 7df9207..23d9358 100644 --- a/src/main/java/com/graduationproject/studentinformationsystem/university/lesson/student/registration/controller/StudentLessonRegistrationController.java +++ b/src/main/java/com/graduationproject/studentinformationsystem/university/lesson/student/registration/controller/StudentLessonRegistrationController.java @@ -23,6 +23,7 @@ import static com.graduationproject.studentinformationsystem.common.config.SisSwaggerConfiguration.STUDENT_LESSON_REGISTRATION_API_TAG; import static com.graduationproject.studentinformationsystem.common.util.controller.endpoint.SisControllerEndpoint.Path.STUDENT_LESSON_REGISTRATION; +import static com.graduationproject.studentinformationsystem.common.util.controller.response.SisResponseUtil.failResponse; import static com.graduationproject.studentinformationsystem.common.util.controller.response.SisResponseUtil.successResponse; @RestController @@ -43,8 +44,8 @@ public ResponseEntity return successResponse(registrationResponses); } - @GetMapping(StudentLessonRegistrationControllerEndpoint.DETAIL_BY_REGISTRATION_ID) - @ApiOperation(value = "Get Student Lesson Registration Detail By Registration ID") + @GetMapping(StudentLessonRegistrationControllerEndpoint.BY_REGISTRATION_ID) + @ApiOperation(value = "Get Student Lesson Registration By Registration ID") public ResponseEntity> getStudentLessonRegistrationDetailByRegistrationId( @PathVariable final String registrationId) throws SisNotExistException { @@ -53,14 +54,15 @@ public ResponseEntity> getStudentLessonRegistrationIdByStudentId( + @GetMapping(StudentLessonRegistrationControllerEndpoint.BY_STUDENT_ID) + @ApiOperation(value = "Get Student Lesson Registrations Detail By Student ID") + public ResponseEntity> getStudentLessonRegistrationDetailByStudentId( @PathVariable @StudentID final Long studentId) throws SisNotExistException { - final String registrationId = studentLessonRegistrationService.getStudentLessonRegistrationIdByStudentId(studentId); - return successResponse(registrationId); + final StudentLessonRegistrationDetailResponse registrationDetailResponse = studentLessonRegistrationService + .getStudentLessonRegistrationDetailByStudentId(studentId); + return successResponse(registrationDetailResponse); } @PostMapping(StudentLessonRegistrationControllerEndpoint.SAVE) diff --git a/src/main/java/com/graduationproject/studentinformationsystem/university/lesson/student/registration/controller/endpoint/StudentLessonRegistrationControllerEndpoint.java b/src/main/java/com/graduationproject/studentinformationsystem/university/lesson/student/registration/controller/endpoint/StudentLessonRegistrationControllerEndpoint.java index 8808688..24a7cc0 100644 --- a/src/main/java/com/graduationproject/studentinformationsystem/university/lesson/student/registration/controller/endpoint/StudentLessonRegistrationControllerEndpoint.java +++ b/src/main/java/com/graduationproject/studentinformationsystem/university/lesson/student/registration/controller/endpoint/StudentLessonRegistrationControllerEndpoint.java @@ -5,8 +5,8 @@ public class StudentLessonRegistrationControllerEndpoint { private StudentLessonRegistrationControllerEndpoint() { } - public static final String DETAIL_BY_REGISTRATION_ID = "/detail/{registrationId}"; - public static final String ID_BY_STUDENT_ID = "/id/{studentId}"; + public static final String BY_REGISTRATION_ID = "/{registrationId}"; + public static final String BY_STUDENT_ID = "/{studentId}"; public static final String SAVE = "/save"; public static final String APPROVE = "/approve"; public static final String REJECT = "/reject"; diff --git a/src/main/java/com/graduationproject/studentinformationsystem/university/lesson/student/registration/service/StudentLessonRegistrationService.java b/src/main/java/com/graduationproject/studentinformationsystem/university/lesson/student/registration/service/StudentLessonRegistrationService.java index edcf4a7..4eaad3f 100644 --- a/src/main/java/com/graduationproject/studentinformationsystem/university/lesson/student/registration/service/StudentLessonRegistrationService.java +++ b/src/main/java/com/graduationproject/studentinformationsystem/university/lesson/student/registration/service/StudentLessonRegistrationService.java @@ -18,7 +18,7 @@ public interface StudentLessonRegistrationService { StudentLessonRegistrationDetailResponse getStudentLessonRegistrationDetailByRegistrationId(String registrationId) throws SisNotExistException; - String getStudentLessonRegistrationIdByStudentId(Long studentId) + StudentLessonRegistrationDetailResponse getStudentLessonRegistrationDetailByStudentId(Long studentId) throws SisNotExistException; StudentLessonRegistrationDetailResponse saveStudentLessonRegistration(StudentLessonRegistrationSaveRequest saveRequest) diff --git a/src/main/java/com/graduationproject/studentinformationsystem/university/lesson/student/registration/service/impl/StudentLessonRegistrationServiceImpl.java b/src/main/java/com/graduationproject/studentinformationsystem/university/lesson/student/registration/service/impl/StudentLessonRegistrationServiceImpl.java index a212dda..322ddf4 100644 --- a/src/main/java/com/graduationproject/studentinformationsystem/university/lesson/student/registration/service/impl/StudentLessonRegistrationServiceImpl.java +++ b/src/main/java/com/graduationproject/studentinformationsystem/university/lesson/student/registration/service/impl/StudentLessonRegistrationServiceImpl.java @@ -58,15 +58,18 @@ public StudentLessonRegistrationDetailResponse getStudentLessonRegistrationDetai } @Override - public String getStudentLessonRegistrationIdByStudentId(final Long studentId) throws SisNotExistException { + public StudentLessonRegistrationDetailResponse getStudentLessonRegistrationDetailByStudentId(final Long studentId) + throws SisNotExistException { ifStudentIsNotExistThrowNotExistException(studentId); final String registrationId = studentLessonRegistrationRepository.getRegistrationId(studentId); - ifStudentLessonRegistrationIsNotExistThrowNotExistException(registrationId); - return registrationId; + final StudentLessonRegistrationEntity registrationEntity = studentLessonRegistrationRepository + .getStudentLessonRegistrationByRegistrationId(registrationId); + + return studentLessonRegistrationInfoConverter.entityToResponse(registrationEntity); } @Override diff --git a/src/main/java/com/graduationproject/studentinformationsystem/university/note/model/dto/converter/StudentLessonNoteInfoConverter.java b/src/main/java/com/graduationproject/studentinformationsystem/university/note/model/dto/converter/StudentLessonNoteInfoConverter.java index da8597e..9de85a0 100644 --- a/src/main/java/com/graduationproject/studentinformationsystem/university/note/model/dto/converter/StudentLessonNoteInfoConverter.java +++ b/src/main/java/com/graduationproject/studentinformationsystem/university/note/model/dto/converter/StudentLessonNoteInfoConverter.java @@ -38,6 +38,9 @@ public StudentLessonNoteSaveEntity generateSaveEntity(final StudentLessonNoteSav .teacherId(saveRequest.getTeacherId()) .studentId(saveRequest.getStudentId()) .lessonId(saveRequest.getLessonId()) + .midtermNoteState(StudentLessonNoteState.NOT_ENTERED) + .finalNoteState(StudentLessonNoteState.NOT_ENTERED) + .resitNoteState(StudentLessonNoteState.NOT_ENTERED) .status(StudentLessonNoteStatus.UNFINALISED) .createdUserId(operationInfoRequest.getUserId()) .createdDate(new Date()) diff --git a/src/main/java/com/graduationproject/studentinformationsystem/university/note/repository/impl/StudentLessonNoteRepositoryImpl.java b/src/main/java/com/graduationproject/studentinformationsystem/university/note/repository/impl/StudentLessonNoteRepositoryImpl.java index adceb4c..7b47948 100644 --- a/src/main/java/com/graduationproject/studentinformationsystem/university/note/repository/impl/StudentLessonNoteRepositoryImpl.java +++ b/src/main/java/com/graduationproject/studentinformationsystem/university/note/repository/impl/StudentLessonNoteRepositoryImpl.java @@ -99,6 +99,9 @@ public void saveStudentLessonNote(final StudentLessonNoteSaveEntity saveEntity) .addParameter(TEACHER_ID.getModelName(), saveEntity.getTeacherId()) .addParameter(STUDENT_ID.getModelName(), saveEntity.getStudentId()) .addParameter(LESSON_ID.getModelName(), saveEntity.getLessonId()) + .addParameter(MIDTERM_NOTE_STATE.getModelName(), saveEntity.getMidtermNoteState()) + .addParameter(FINAL_NOTE_STATE.getModelName(), saveEntity.getFinalNoteState()) + .addParameter(RESIT_NOTE_STATE.getModelName(), saveEntity.getResitNoteState()) .addParameter(STATUS.getModelName(), saveEntity.getStatus()) .addParameter(CREATED_DATE.getModelName(), saveEntity.getCreatedDate()) .addParameter(CREATED_USER_ID.getModelName(), saveEntity.getCreatedUserId())