-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Student Lesson API and Registration API | SIS-112 (#61)
* longListToString and longArrayToLongList Methods Have Been Added to SisUtil Class * StudentLessonMapping Class Have Been Created * Student Lesson Entity Classes Have Been Created * StudentLessonException Class Have Been Created * Student Lesson Response Classes Have Been Created * Student Lesson Request Classes Have Been Created * Student Lesson Converter Class Has Been Created * StudentOutService Classes Have Been Created * Student Lesson Repository Classes Have Been Created * Student Lesson Service Classes Have Been Created * Student Lesson Controller Classes Have Been Created * StudentLessonRegistrationMapping Class Has Been Created * StudentLessonRegistrationException Class Has Been Created * StudentLessonRegistrationStatus Enum Class Has Been Created * StudentLessonRegistrationEntity Class Has Been Created * Student Lesson Registration Request Classes Have Been Created * Student Lesson Registration Response Classes Have Been Created * StudentLessonRegistrationInfoConverter Class Has Been Created * Student Lesson Registration Repository Classes Have Been Created * Student Lesson Registration Service Classes Have Been Created * Student Lesson Registration Controller Classes Have Been Created * STUDENT_LESSON_API_TAG and STUDENT_LESSON_REGISTRATION_API_TAG Have Been Added to SisSwaggerConfiguration Class * STUDENT_LESSON and STUDENT_LESSON_REGISTRATION Endpoints Have Been Added to SisControllerEndpoint Class
- Loading branch information
1 parent
13baa03
commit 417d151
Showing
44 changed files
with
1,749 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...nformationsystem/university/lesson/student/common/controller/StudentLessonController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package com.graduationproject.studentinformationsystem.university.lesson.student.common.controller; | ||
|
||
import com.graduationproject.studentinformationsystem.common.util.controller.response.SisApiResponse; | ||
import com.graduationproject.studentinformationsystem.common.util.controller.response.SisBaseApiResponse; | ||
import com.graduationproject.studentinformationsystem.common.util.exception.SisAlreadyException; | ||
import com.graduationproject.studentinformationsystem.common.util.exception.SisNotExistException; | ||
import com.graduationproject.studentinformationsystem.common.util.validation.id.StudentID; | ||
import com.graduationproject.studentinformationsystem.university.lesson.student.common.controller.endpoint.StudentLessonControllerEndpoint; | ||
import com.graduationproject.studentinformationsystem.university.lesson.student.common.model.dto.response.StudentLessonsResponse; | ||
import com.graduationproject.studentinformationsystem.university.lesson.student.common.service.StudentLessonService; | ||
import io.swagger.annotations.Api; | ||
import io.swagger.annotations.ApiOperation; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import static com.graduationproject.studentinformationsystem.common.config.SisSwaggerConfiguration.STUDENT_LESSON_API_TAG; | ||
import static com.graduationproject.studentinformationsystem.common.util.controller.endpoint.SisControllerEndpoint.Path.STUDENT_LESSON; | ||
import static com.graduationproject.studentinformationsystem.common.util.controller.response.SisResponseUtil.successResponse; | ||
|
||
@RestController | ||
@RequestMapping(STUDENT_LESSON) | ||
@Api(tags = STUDENT_LESSON_API_TAG) | ||
@RequiredArgsConstructor | ||
public class StudentLessonController { | ||
|
||
private final StudentLessonService lessonService; | ||
|
||
@GetMapping(StudentLessonControllerEndpoint.GET_BY_STUDENT_ID) | ||
@ApiOperation(value = "Get Student All Lessons By Student ID") | ||
public ResponseEntity<SisBaseApiResponse<StudentLessonsResponse>> getStudentLessonsById( | ||
@PathVariable @StudentID final Long studentId) | ||
throws SisNotExistException { | ||
|
||
final StudentLessonsResponse lessonsResponse = lessonService.getStudentLessonsById(studentId); | ||
return successResponse(lessonsResponse); | ||
} | ||
|
||
@DeleteMapping(StudentLessonControllerEndpoint.DELETE_BY_STUDENT_ID) | ||
@ApiOperation(value = "Delete Student All Lessons By Student ID") | ||
public ResponseEntity<SisApiResponse> deleteStudentLessons( | ||
@PathVariable @StudentID final Long studentId) | ||
throws SisAlreadyException, SisNotExistException { | ||
|
||
lessonService.deleteStudentLessons(studentId); | ||
return successResponse(); | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...university/lesson/student/common/controller/endpoint/StudentLessonControllerEndpoint.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.graduationproject.studentinformationsystem.university.lesson.student.common.controller.endpoint; | ||
|
||
public class StudentLessonControllerEndpoint { | ||
|
||
private StudentLessonControllerEndpoint() { | ||
} | ||
|
||
private static final String STUDENT_ID = "/{studentId}"; | ||
public static final String GET_BY_STUDENT_ID = "/get" + STUDENT_ID; | ||
public static final String DELETE_BY_STUDENT_ID = "/delete" + STUDENT_ID; | ||
} |
76 changes: 76 additions & 0 deletions
76
...stem/university/lesson/student/common/model/dto/converter/StudentLessonInfoConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package com.graduationproject.studentinformationsystem.university.lesson.student.common.model.dto.converter; | ||
|
||
import com.graduationproject.studentinformationsystem.common.util.SisUtil; | ||
import com.graduationproject.studentinformationsystem.university.lesson.common.model.dto.response.LessonResponse; | ||
import com.graduationproject.studentinformationsystem.university.lesson.common.service.LessonOutService; | ||
import com.graduationproject.studentinformationsystem.university.lesson.student.common.model.dto.response.StudentLessonResponse; | ||
import com.graduationproject.studentinformationsystem.university.lesson.student.common.model.dto.response.StudentLessonsResponse; | ||
import com.graduationproject.studentinformationsystem.university.lesson.student.common.model.entity.StudentLessonEntity; | ||
import com.graduationproject.studentinformationsystem.university.lesson.student.common.model.entity.StudentLessonSaveEntity; | ||
import com.graduationproject.studentinformationsystem.university.student.model.dto.response.StudentInfoResponse; | ||
import com.graduationproject.studentinformationsystem.university.student.service.StudentOutService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Date; | ||
import java.util.List; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class StudentLessonInfoConverter { | ||
|
||
private final StudentOutService studentOutService; | ||
private final LessonOutService lessonOutService; | ||
|
||
public StudentLessonSaveEntity generateSaveEntity(final Long studentId, | ||
final Long lessonId, | ||
final Long operationUserId) { | ||
|
||
return StudentLessonSaveEntity.builder() | ||
.studentId(studentId) | ||
.lessonId(lessonId) | ||
.createdUserId(operationUserId) | ||
.createdDate(new Date()).build(); | ||
} | ||
|
||
public StudentLessonResponse entityToResponse(final StudentLessonEntity studentLessonEntity) { | ||
|
||
final StudentInfoResponse studentInfoResponse = getStudentInfoResponse(studentLessonEntity.getStudentId()); | ||
final LessonResponse lessonResponse = getLessonResponse(studentLessonEntity.getLessonId()); | ||
|
||
return StudentLessonResponse.builder() | ||
.createdUserId(studentLessonEntity.getCreatedUserId()) | ||
.createdDate(SisUtil.getFormattedDateTime(studentLessonEntity.getCreatedDate())) | ||
.studentInfoResponse(studentInfoResponse) | ||
.lessonResponse(lessonResponse).build(); | ||
} | ||
|
||
public StudentLessonsResponse entitiesToResponse(final List<StudentLessonEntity> studentLessonEntities) { | ||
if (studentLessonEntities.isEmpty()) { | ||
return null; | ||
} | ||
|
||
final StudentInfoResponse studentInfoResponse = getStudentInfoResponse(studentLessonEntities.get(0).getStudentId()); | ||
final List<LessonResponse> lessonResponses = new ArrayList<>(); | ||
|
||
studentLessonEntities.forEach(studentLessonEntity -> { | ||
final LessonResponse lessonResponse = getLessonResponse(studentLessonEntity.getLessonId()); | ||
lessonResponses.add(lessonResponse); | ||
}); | ||
|
||
return StudentLessonsResponse.builder() | ||
.createdUserId(studentLessonEntities.get(0).getCreatedUserId()) | ||
.createdDate(SisUtil.getFormattedDateTime(studentLessonEntities.get(0).getCreatedDate())) | ||
.lessonsResponses(lessonResponses) | ||
.studentInfoResponse(studentInfoResponse).build(); | ||
} | ||
|
||
private StudentInfoResponse getStudentInfoResponse(Long studentId) { | ||
return studentOutService.getStudentInfoResponse(studentId); | ||
} | ||
|
||
private LessonResponse getLessonResponse(Long lessonId) { | ||
return lessonOutService.getLessonResponse(lessonId); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
...system/university/lesson/student/common/model/dto/request/StudentLessonDeleteRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.graduationproject.studentinformationsystem.university.lesson.student.common.model.dto.request; | ||
|
||
import lombok.Getter; | ||
|
||
import javax.validation.Valid; | ||
import javax.validation.constraints.NotNull; | ||
import java.io.Serial; | ||
import java.io.Serializable; | ||
|
||
@Getter | ||
public class StudentLessonDeleteRequest implements Serializable { | ||
|
||
@Serial | ||
private static final long serialVersionUID = 8186474487495643349L; | ||
|
||
@Valid | ||
@NotNull | ||
private StudentLessonInfoRequest studentLessonInfoRequest; | ||
} |
24 changes: 24 additions & 0 deletions
24
...onsystem/university/lesson/student/common/model/dto/request/StudentLessonInfoRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.graduationproject.studentinformationsystem.university.lesson.student.common.model.dto.request; | ||
|
||
import com.graduationproject.studentinformationsystem.common.util.validation.id.LessonID; | ||
import com.graduationproject.studentinformationsystem.common.util.validation.id.StudentID; | ||
import lombok.Getter; | ||
|
||
import javax.validation.constraints.NotNull; | ||
import java.io.Serial; | ||
import java.io.Serializable; | ||
|
||
@Getter | ||
public class StudentLessonInfoRequest implements Serializable { | ||
|
||
@Serial | ||
private static final long serialVersionUID = -3737062791585675014L; | ||
|
||
@NotNull | ||
@StudentID | ||
private Long studentId; | ||
|
||
@NotNull | ||
@LessonID | ||
private Long lessonId; | ||
} |
24 changes: 24 additions & 0 deletions
24
...onsystem/university/lesson/student/common/model/dto/request/StudentLessonSaveRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package com.graduationproject.studentinformationsystem.university.lesson.student.common.model.dto.request; | ||
|
||
import com.graduationproject.studentinformationsystem.common.model.dto.request.SisOperationInfoRequest; | ||
import lombok.Getter; | ||
|
||
import javax.validation.Valid; | ||
import javax.validation.constraints.NotNull; | ||
import java.io.Serial; | ||
import java.io.Serializable; | ||
|
||
@Getter | ||
public class StudentLessonSaveRequest implements Serializable { | ||
|
||
@Serial | ||
private static final long serialVersionUID = -7325837862878819492L; | ||
|
||
@Valid | ||
@NotNull | ||
private StudentLessonInfoRequest studentLessonInfoRequest; | ||
|
||
@Valid | ||
@NotNull | ||
private SisOperationInfoRequest operationInfoRequest; | ||
} |
17 changes: 17 additions & 0 deletions
17
...tionsystem/university/lesson/student/common/model/dto/response/StudentLessonResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.graduationproject.studentinformationsystem.university.lesson.student.common.model.dto.response; | ||
|
||
import com.graduationproject.studentinformationsystem.university.lesson.common.model.dto.response.LessonResponse; | ||
import com.graduationproject.studentinformationsystem.university.student.model.dto.response.StudentInfoResponse; | ||
import lombok.Getter; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
@Getter | ||
@SuperBuilder | ||
public class StudentLessonResponse { | ||
|
||
private Long createdUserId; | ||
private String createdDate; | ||
|
||
private StudentInfoResponse studentInfoResponse; | ||
private LessonResponse lessonResponse; | ||
} |
19 changes: 19 additions & 0 deletions
19
...ionsystem/university/lesson/student/common/model/dto/response/StudentLessonsResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.graduationproject.studentinformationsystem.university.lesson.student.common.model.dto.response; | ||
|
||
import com.graduationproject.studentinformationsystem.university.lesson.common.model.dto.response.LessonResponse; | ||
import com.graduationproject.studentinformationsystem.university.student.model.dto.response.StudentInfoResponse; | ||
import lombok.Getter; | ||
import lombok.experimental.SuperBuilder; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@SuperBuilder | ||
public class StudentLessonsResponse { | ||
|
||
private Long createdUserId; | ||
private String createdDate; | ||
|
||
private StudentInfoResponse studentInfoResponse; | ||
private List<LessonResponse> lessonsResponses; | ||
} |
12 changes: 12 additions & 0 deletions
12
...mationsystem/university/lesson/student/common/model/entity/StudentLessonDeleteEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.graduationproject.studentinformationsystem.university.lesson.student.common.model.entity; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@Builder | ||
public class StudentLessonDeleteEntity { | ||
|
||
private Long studentId; | ||
private Long lessonId; | ||
} |
16 changes: 16 additions & 0 deletions
16
...tinformationsystem/university/lesson/student/common/model/entity/StudentLessonEntity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package com.graduationproject.studentinformationsystem.university.lesson.student.common.model.entity; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
import java.util.Date; | ||
|
||
@Getter | ||
@Builder | ||
public class StudentLessonEntity { | ||
|
||
private Long studentId; | ||
private Long lessonId; | ||
private Long createdUserId; | ||
private Date createdDate; | ||
} |
Oops, something went wrong.