From f3ee57c423f4e5f9142787793c48449554d3ad78 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Wed, 25 Oct 2023 20:02:41 +0900 Subject: [PATCH 01/26] delete :: exception message --- .../lecture/exception/constant/LectureErrorCode.kt | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt index c5f4b1803..541642a32 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt @@ -1,12 +1,13 @@ package team.msg.domain.lecture.exception.constant enum class LectureErrorCode( - val message: String, val status: Int ){ - INVALID_LECTURE_TYPE("유효하지 않은 강의 구분입니다.", 400), + INVALID_LECTURE_TYPE(400), - LECTURE_NOT_FOUND("존재하지 않는 강의입니다.", 404), + LECTURE_NOT_FOUND(404), - ALREADY_APPROVED_LECTURE("이미 개설 신청이 승인된 강의입니다.",409) + ALREADY_APPROVED_LECTURE(409), + NOT_APPROVED_LECTURE(409), + OVER_MAX_REGISTERED_USER(409) } \ No newline at end of file From 8196a238c75362aa7ca0548b075889b9d74e3272 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Wed, 25 Oct 2023 23:24:58 +0900 Subject: [PATCH 02/26] create :: lecture exception --- .../lecture/exception/MissSignUpAbleDateException.kt | 8 ++++++++ .../lecture/exception/NotApprovedLectureException.kt | 8 ++++++++ .../lecture/exception/OverMaxRegisteredUserException.kt | 8 ++++++++ 3 files changed, 24 insertions(+) create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/MissSignUpAbleDateException.kt create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/NotApprovedLectureException.kt create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/OverMaxRegisteredUserException.kt diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/MissSignUpAbleDateException.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/MissSignUpAbleDateException.kt new file mode 100644 index 000000000..4718f9b97 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/MissSignUpAbleDateException.kt @@ -0,0 +1,8 @@ +package team.msg.domain.lecture.exception + +import team.msg.domain.lecture.exception.constant.LectureErrorCode +import team.msg.global.error.exception.BitgouelException + +class MissSignUpAbleDateException ( + message: String +) : BitgouelException(message, LectureErrorCode.MISS_SIGNUP_ABLE_DATE.status) \ No newline at end of file diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/NotApprovedLectureException.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/NotApprovedLectureException.kt new file mode 100644 index 000000000..95231d929 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/NotApprovedLectureException.kt @@ -0,0 +1,8 @@ +package team.msg.domain.lecture.exception + +import team.msg.domain.lecture.exception.constant.LectureErrorCode +import team.msg.global.error.exception.BitgouelException + +class NotApprovedLectureException( + message: String +) : BitgouelException(message, LectureErrorCode.NOT_APPROVED_LECTURE.status) \ No newline at end of file diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/OverMaxRegisteredUserException.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/OverMaxRegisteredUserException.kt new file mode 100644 index 000000000..52639cff4 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/OverMaxRegisteredUserException.kt @@ -0,0 +1,8 @@ +package team.msg.domain.lecture.exception + +import team.msg.domain.lecture.exception.constant.LectureErrorCode +import team.msg.global.error.exception.BitgouelException + +class OverMaxRegisteredUserException( + message: String +) : BitgouelException(message, LectureErrorCode.OVER_MAX_REGISTERED_USER.status) \ No newline at end of file From 6c76fdd855a3e4df4e32d7c572b32559730dacad Mon Sep 17 00:00:00 2001 From: ani2689 Date: Wed, 25 Oct 2023 23:25:26 +0900 Subject: [PATCH 03/26] add :: findByLectureId method --- .../domain/lecture/repository/RegisteredLectureRepository.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/repository/RegisteredLectureRepository.kt b/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/repository/RegisteredLectureRepository.kt index 4f2fc7802..91fc7a44d 100644 --- a/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/repository/RegisteredLectureRepository.kt +++ b/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/repository/RegisteredLectureRepository.kt @@ -4,4 +4,6 @@ import org.springframework.data.repository.CrudRepository import team.msg.domain.lecture.model.RegisteredLecture import java.util.UUID -interface RegisteredLectureRepository : CrudRepository \ No newline at end of file +interface RegisteredLectureRepository : CrudRepository{ + fun findByLectureId(lectureId: UUID): List +} \ No newline at end of file From 1e6e30931e5e096aebea1bc0a5921b045271341f Mon Sep 17 00:00:00 2001 From: ani2689 Date: Wed, 25 Oct 2023 23:29:30 +0900 Subject: [PATCH 04/26] add :: lecture error code --- .../msg/domain/lecture/exception/constant/LectureErrorCode.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt index 541642a32..8d5069b4c 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt @@ -9,5 +9,6 @@ enum class LectureErrorCode( ALREADY_APPROVED_LECTURE(409), NOT_APPROVED_LECTURE(409), - OVER_MAX_REGISTERED_USER(409) + OVER_MAX_REGISTERED_USER(409), + MISS_SIGNUP_ABLE_DATE(409) } \ No newline at end of file From 7c5d1f33a43d17aa8da4c7191e1e3e9815f4bfbb Mon Sep 17 00:00:00 2001 From: ani2689 Date: Wed, 25 Oct 2023 23:30:29 +0900 Subject: [PATCH 05/26] add :: sign up lecture --- .../msg/domain/lecture/presentation/LectureController.kt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/presentation/LectureController.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/presentation/LectureController.kt index 1ba81b7d2..327cdfa66 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/presentation/LectureController.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/presentation/LectureController.kt @@ -28,6 +28,12 @@ class LectureController( return ResponseEntity.status(HttpStatus.CREATED).build() } + @PostMapping("/{id}") + fun signUpLecture(@PathVariable id: UUID): ResponseEntity { + lectureService.signUpLecture(id) + return ResponseEntity.noContent().build() + } + @PatchMapping("/{id}/approve") fun approveLecture(@PathVariable id: UUID): ResponseEntity { lectureService.approveLecture(id) From 6f9492f5a6429b39273c017f9c2b256667230bc2 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Wed, 25 Oct 2023 23:30:34 +0900 Subject: [PATCH 06/26] add :: sign up lecture --- .../kotlin/team/msg/domain/lecture/service/LectureService.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureService.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureService.kt index c95faa2b4..2128defc2 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureService.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureService.kt @@ -5,6 +5,7 @@ import java.util.UUID interface LectureService { fun createLecture(request: CreateLectureRequest) + fun signUpLecture(id: UUID) fun approveLecture(id: UUID) fun rejectLecture(id: UUID) } \ No newline at end of file From 206ef8f8cb539e18ca4eb1fa29c93494bdba102c Mon Sep 17 00:00:00 2001 From: ani2689 Date: Wed, 25 Oct 2023 23:30:41 +0900 Subject: [PATCH 07/26] add :: sign up lecture --- .../lecture/service/LectureServiceImpl.kt | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt index 9efb1faea..b0b2d6583 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt @@ -9,14 +9,24 @@ import team.msg.domain.lecture.enum.LectureType import team.msg.domain.lecture.exception.AlreadyApprovedLectureException import team.msg.domain.lecture.exception.InvalidLectureTypeException import team.msg.domain.lecture.exception.LectureNotFoundException +import team.msg.domain.lecture.exception.MissSignUpAbleDateException +import team.msg.domain.lecture.exception.NotApprovedLectureException +import team.msg.domain.lecture.exception.OverMaxRegisteredUserException import team.msg.domain.lecture.model.Lecture +import team.msg.domain.lecture.model.RegisteredLecture import team.msg.domain.lecture.presentation.data.request.CreateLectureRequest import team.msg.domain.lecture.repository.LectureRepository +import team.msg.domain.lecture.repository.RegisteredLectureRepository +import team.msg.domain.student.exception.StudentNotFoundException +import team.msg.domain.student.repository.StudentRepository +import java.time.LocalDateTime import java.util.* @Service class LectureServiceImpl( private val lectureRepository: LectureRepository, + private val registeredLectureRepository: RegisteredLectureRepository, + private val studentRepository: StudentRepository, private val userUtil: UserUtil ) : LectureService{ @@ -50,6 +60,43 @@ class LectureServiceImpl( lectureRepository.save(lecture) } + /** + * 강의에 대해 수강신청하는 비지니스 로직입니다. + * @param UUID + */ + @Transactional(rollbackFor = [Exception::class]) + override fun signUpLecture(id: UUID) { + val user = userUtil.queryCurrentUser() + + val student = studentRepository.findByIdOrNull(user.id) ?: + throw StudentNotFoundException("학생을 찾을 수 없습니다. info : [ userId = ${user.id}, userName = ${user.name} ]") + + val lecture = queryLecture(id) + + if(lecture.approveStatus == ApproveStatus.PENDING) + throw NotApprovedLectureException("아직 승인되지 않은 강의입니다. info : [ lectureId = ${lecture.id} ]") + + if(lecture.startDate.isBefore(LocalDateTime.now())) + throw MissSignUpAbleDateException("이른 강의 신청입니다. info : [ lectureStartDate = ${lecture.startDate}, currentDate = ${LocalDateTime.now()} ]") + + if(lecture.endDate.isAfter(LocalDateTime.now())) + throw MissSignUpAbleDateException("늦은 강의 신청입니다. info : [ lectureEndDate = ${lecture.endDate}, currentDate = ${LocalDateTime.now()} ]") + + val currentSignUpLectureStudent = registeredLectureRepository.findByLectureId(lecture.id).size + + if(lecture.maxRegisteredUser == currentSignUpLectureStudent) + throw OverMaxRegisteredUserException("수강 인원이 가득 찼습니다. info : [ maxRegisteredUser = ${lecture.maxRegisteredUser}, currentSignUpLectureStudent = $currentSignUpLectureStudent ]") + + val registeredLecture = RegisteredLecture( + student = student, + lecture = lecture, + completeDate = lecture.completeDate + ) + + registeredLectureRepository.save(registeredLecture) + + } + /** * 강의 개설 신청을 수락하는 비지니스 로직입니다. * @param UUID From c8377cf539ef630b5d276a7df718445ecd9db14d Mon Sep 17 00:00:00 2001 From: ani2689 Date: Thu, 26 Oct 2023 00:08:50 +0900 Subject: [PATCH 08/26] =?UTF-8?q?update=20::=20=EC=A3=BC=EC=84=9D=20?= =?UTF-8?q?=EC=84=A4=EB=AA=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/msg/domain/lecture/service/LectureServiceImpl.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt index b0b2d6583..dea689839 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt @@ -32,7 +32,7 @@ class LectureServiceImpl( /** * 강의 개설을 처리하는 비지니스 로직입니다. - * @param CreateLectureRequest + * @param 강의를 생성하기 위해 데이터를 담은 request dto */ @Transactional(rollbackFor = [Exception::class]) override fun createLecture(request: CreateLectureRequest) { @@ -62,7 +62,7 @@ class LectureServiceImpl( /** * 강의에 대해 수강신청하는 비지니스 로직입니다. - * @param UUID + * @param 강의에 수강신청을 하기 위한 강의 id */ @Transactional(rollbackFor = [Exception::class]) override fun signUpLecture(id: UUID) { @@ -99,7 +99,7 @@ class LectureServiceImpl( /** * 강의 개설 신청을 수락하는 비지니스 로직입니다. - * @param UUID + * @param 개설을 수락할 대기 상태의 강의 id */ @Transactional(rollbackFor = [Exception::class]) override fun approveLecture(id: UUID) { @@ -115,7 +115,7 @@ class LectureServiceImpl( /** * 강의 개설 신청을 거절하는 비지니스 로직입니다. - * @param UUID + * @param 개설을 거절할 대기 상태의 강의 id */ @Transactional(rollbackFor = [Exception::class]) override fun rejectLecture(id: UUID) { From 6dab1a34f5be293f16994b9eaa5a0f3fad1f6e63 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Thu, 26 Oct 2023 00:10:35 +0900 Subject: [PATCH 09/26] =?UTF-8?q?add=20::=20security=20=EA=B2=BD=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/team/msg/global/security/SecurityConfig.kt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/global/security/SecurityConfig.kt b/bitgouel-api/src/main/kotlin/team/msg/global/security/SecurityConfig.kt index 8c5250d8e..2b940f49d 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/global/security/SecurityConfig.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/global/security/SecurityConfig.kt @@ -60,8 +60,9 @@ class SecurityConfig( // lecture .mvcMatchers(HttpMethod.POST, "/lecture").hasAnyRole(PROFESSOR, COMPANY_INSTRUCTOR, GOVERNMENT) - .mvcMatchers(HttpMethod.PATCH, "/lecture/{id}/approve").hasAnyRole(ADMIN) - .mvcMatchers(HttpMethod.DELETE, "/lecture/{id}/reject").hasAnyRole(ADMIN) + .mvcMatchers(HttpMethod.POST, "/lecture/{id}").hasRole(STUDENT) + .mvcMatchers(HttpMethod.PATCH, "/lecture/{id}/approve").hasRole(ADMIN) + .mvcMatchers(HttpMethod.DELETE, "/lecture/{id}/reject").hasRole(ADMIN) .anyRequest().authenticated() .and() From a3c20ba7e1a3a4a5710ee19d8e5d207ef3912bce Mon Sep 17 00:00:00 2001 From: ani2689 Date: Thu, 26 Oct 2023 20:32:36 +0900 Subject: [PATCH 10/26] =?UTF-8?q?update=20::=20s=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/data/web/CreateLectureWebRequest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/presentation/data/web/CreateLectureWebRequest.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/presentation/data/web/CreateLectureWebRequest.kt index de30963c9..6bf9bd410 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/presentation/data/web/CreateLectureWebRequest.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/presentation/data/web/CreateLectureWebRequest.kt @@ -20,12 +20,12 @@ data class CreateLectureWebRequest( @field:NotNull @FutureOrPresent - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:s") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") val startDate: LocalDateTime, @field:NotNull @Future - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:s") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") val endDate: LocalDateTime, @field:NotNull @@ -44,4 +44,4 @@ data class CreateLectureWebRequest( @field:NotNull @field:Min(1) val maxRegisteredUser: Int -) +) \ No newline at end of file From 5e5f5bf6cc0a36a4bc4a9144357d0344f093ed61 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 27 Oct 2023 10:37:32 +0900 Subject: [PATCH 11/26] =?UTF-8?q?update=20::=20date=20format=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/data/web/CreateLectureWebRequest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/presentation/data/web/CreateLectureWebRequest.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/presentation/data/web/CreateLectureWebRequest.kt index 6bf9bd410..10a0521b4 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/presentation/data/web/CreateLectureWebRequest.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/presentation/data/web/CreateLectureWebRequest.kt @@ -20,17 +20,17 @@ data class CreateLectureWebRequest( @field:NotNull @FutureOrPresent - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss") val startDate: LocalDateTime, @field:NotNull @Future - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss") val endDate: LocalDateTime, @field:NotNull @Future - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:s") + @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss") val completeDate: LocalDateTime, @field:NotNull From 43539108d9e168cf1094a12086676bf395131b20 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 27 Oct 2023 10:38:59 +0900 Subject: [PATCH 12/26] =?UTF-8?q?update=20::=20date=20format=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../presentation/data/web/CreateLectureWebRequest.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/presentation/data/web/CreateLectureWebRequest.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/presentation/data/web/CreateLectureWebRequest.kt index 10a0521b4..fa960ca89 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/presentation/data/web/CreateLectureWebRequest.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/presentation/data/web/CreateLectureWebRequest.kt @@ -20,17 +20,17 @@ data class CreateLectureWebRequest( @field:NotNull @FutureOrPresent - @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") val startDate: LocalDateTime, @field:NotNull @Future - @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") val endDate: LocalDateTime, @field:NotNull @Future - @JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss") + @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss") val completeDate: LocalDateTime, @field:NotNull From ff4138b6757e6133b162ee99d3c342f5753f882e Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 27 Oct 2023 10:51:21 +0900 Subject: [PATCH 13/26] =?UTF-8?q?update=20::=20lecture=20=EC=B0=B8?= =?UTF-8?q?=EC=A1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/msg/domain/lecture/service/LectureServiceImpl.kt | 2 +- .../domain/lecture/repository/RegisteredLectureRepository.kt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt index 7a1c1f4d3..f5128f824 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt @@ -83,7 +83,7 @@ class LectureServiceImpl( if(lecture.endDate.isAfter(LocalDateTime.now())) throw MissSignUpAbleDateException("늦은 강의 신청입니다. info : [ lectureEndDate = ${lecture.endDate}, currentDate = ${LocalDateTime.now()} ]") - val currentSignUpLectureStudent = registeredLectureRepository.findByLectureId(lecture.id).size + val currentSignUpLectureStudent = registeredLectureRepository.findAllByLecture(lecture).size if(lecture.maxRegisteredUser == currentSignUpLectureStudent) throw OverMaxRegisteredUserException("수강 인원이 가득 찼습니다. info : [ maxRegisteredUser = ${lecture.maxRegisteredUser}, currentSignUpLectureStudent = $currentSignUpLectureStudent ]") diff --git a/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/repository/RegisteredLectureRepository.kt b/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/repository/RegisteredLectureRepository.kt index a8b838612..e69856517 100644 --- a/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/repository/RegisteredLectureRepository.kt +++ b/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/repository/RegisteredLectureRepository.kt @@ -1,11 +1,13 @@ package team.msg.domain.lecture.repository import org.springframework.data.repository.CrudRepository +import team.msg.domain.lecture.model.Lecture import team.msg.domain.lecture.model.RegisteredLecture import team.msg.domain.student.model.Student import java.util.UUID interface RegisteredLectureRepository : CrudRepository { fun findAllByStudent(student: Student): List - fun findByLectureId(lectureId: UUID): List + fun findAllByLecture(lecture: Lecture): List + fun findByStudentAndLecture(student: Student, lecture: Lecture): RegisteredLecture? } \ No newline at end of file From 2ca989d5c3955a0a5adc2e7ea6c9d09a6867404d Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 27 Oct 2023 10:58:09 +0900 Subject: [PATCH 14/26] =?UTF-8?q?create=20::=20=EC=9D=B4=EB=AF=B8=20?= =?UTF-8?q?=EC=8B=A0=EC=B2=AD=ED=95=9C=20=EA=B0=95=EC=9D=98=EC=97=90=20?= =?UTF-8?q?=EC=98=88=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lecture/exception/AlreadySignedUpLectureException.kt | 8 ++++++++ .../domain/lecture/exception/constant/LectureErrorCode.kt | 1 + 2 files changed, 9 insertions(+) create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/AlreadySignedUpLectureException.kt diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/AlreadySignedUpLectureException.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/AlreadySignedUpLectureException.kt new file mode 100644 index 000000000..d0e5cf033 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/AlreadySignedUpLectureException.kt @@ -0,0 +1,8 @@ +package team.msg.domain.lecture.exception + +import team.msg.domain.lecture.exception.constant.LectureErrorCode +import team.msg.global.error.exception.BitgouelException + +class AlreadySignedUpLectureException ( + message: String +) : BitgouelException(message, LectureErrorCode.ALREADY_SIGNEDUP_LECTURE.status) \ No newline at end of file diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt index 8d5069b4c..485b8e911 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt @@ -8,6 +8,7 @@ enum class LectureErrorCode( LECTURE_NOT_FOUND(404), ALREADY_APPROVED_LECTURE(409), + ALREADY_SIGNEDUP_LECTURE(409), NOT_APPROVED_LECTURE(409), OVER_MAX_REGISTERED_USER(409), MISS_SIGNUP_ABLE_DATE(409) From 87ae00d67db2d15560d8dde5374224e2454185c6 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 27 Oct 2023 10:58:29 +0900 Subject: [PATCH 15/26] =?UTF-8?q?add=20::=20=EC=9D=B4=EB=AF=B8=20=EC=8B=A0?= =?UTF-8?q?=EC=B2=AD=ED=95=9C=20=EA=B0=95=EC=9D=98=EC=97=90=20=EC=98=88?= =?UTF-8?q?=EC=99=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/msg/domain/lecture/service/LectureServiceImpl.kt | 4 ++++ .../domain/lecture/repository/RegisteredLectureRepository.kt | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt index f5128f824..7588237d4 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt @@ -7,6 +7,7 @@ import team.msg.common.enum.ApproveStatus import team.msg.common.util.UserUtil import team.msg.domain.lecture.enum.LectureType import team.msg.domain.lecture.exception.AlreadyApprovedLectureException +import team.msg.domain.lecture.exception.AlreadySignedUpLectureException import team.msg.domain.lecture.exception.InvalidLectureTypeException import team.msg.domain.lecture.exception.LectureNotFoundException import team.msg.domain.lecture.exception.MissSignUpAbleDateException @@ -83,6 +84,9 @@ class LectureServiceImpl( if(lecture.endDate.isAfter(LocalDateTime.now())) throw MissSignUpAbleDateException("늦은 강의 신청입니다. info : [ lectureEndDate = ${lecture.endDate}, currentDate = ${LocalDateTime.now()} ]") + if(registeredLectureRepository.existsByStudentAndLecture(student, lecture)) + throw AlreadySignedUpLectureException("이미 신청한 강의입니다. info : [ lectureId = ${lecture.id}, studentId = ${student.id} ]") + val currentSignUpLectureStudent = registeredLectureRepository.findAllByLecture(lecture).size if(lecture.maxRegisteredUser == currentSignUpLectureStudent) diff --git a/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/repository/RegisteredLectureRepository.kt b/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/repository/RegisteredLectureRepository.kt index e69856517..251d1109f 100644 --- a/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/repository/RegisteredLectureRepository.kt +++ b/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/repository/RegisteredLectureRepository.kt @@ -9,5 +9,5 @@ import java.util.UUID interface RegisteredLectureRepository : CrudRepository { fun findAllByStudent(student: Student): List fun findAllByLecture(lecture: Lecture): List - fun findByStudentAndLecture(student: Student, lecture: Lecture): RegisteredLecture? + fun existsByStudentAndLecture(student: Student, lecture: Lecture): Boolean } \ No newline at end of file From 748b19d680e283e3799dab2ebe79af5fd5351f69 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 27 Oct 2023 10:59:25 +0900 Subject: [PATCH 16/26] =?UTF-8?q?update=20::=20=EB=9D=84=EC=96=B4=EC=93=B0?= =?UTF-8?q?=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lecture/exception/AlreadySignedUpLectureException.kt | 2 +- .../domain/lecture/exception/MissSignUpAbleDateException.kt | 2 +- .../msg/domain/lecture/exception/constant/LectureErrorCode.kt | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/AlreadySignedUpLectureException.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/AlreadySignedUpLectureException.kt index d0e5cf033..bad84d4bc 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/AlreadySignedUpLectureException.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/AlreadySignedUpLectureException.kt @@ -5,4 +5,4 @@ import team.msg.global.error.exception.BitgouelException class AlreadySignedUpLectureException ( message: String -) : BitgouelException(message, LectureErrorCode.ALREADY_SIGNEDUP_LECTURE.status) \ No newline at end of file +) : BitgouelException(message, LectureErrorCode.ALREADY_SIGNED_UP_LECTURE.status) \ No newline at end of file diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/MissSignUpAbleDateException.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/MissSignUpAbleDateException.kt index 4718f9b97..a72c51694 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/MissSignUpAbleDateException.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/MissSignUpAbleDateException.kt @@ -5,4 +5,4 @@ import team.msg.global.error.exception.BitgouelException class MissSignUpAbleDateException ( message: String -) : BitgouelException(message, LectureErrorCode.MISS_SIGNUP_ABLE_DATE.status) \ No newline at end of file +) : BitgouelException(message, LectureErrorCode.MISS_SIGN_UP_ABLE_DATE.status) \ No newline at end of file diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt index 485b8e911..efad94b31 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt @@ -8,8 +8,8 @@ enum class LectureErrorCode( LECTURE_NOT_FOUND(404), ALREADY_APPROVED_LECTURE(409), - ALREADY_SIGNEDUP_LECTURE(409), + ALREADY_SIGNED_UP_LECTURE(409), NOT_APPROVED_LECTURE(409), OVER_MAX_REGISTERED_USER(409), - MISS_SIGNUP_ABLE_DATE(409) + MISS_SIGN_UP_ABLE_DATE(409) } \ No newline at end of file From fe6fe9b49cbcd2dac6b01fdfa8fb30833e468cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=85=B8=ED=98=84=EC=A3=BC?= <106813267+ani2689@users.noreply.github.com> Date: Fri, 27 Oct 2023 11:18:19 +0900 Subject: [PATCH 17/26] update :: Not -> Un MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 박주홍 <103554978+JuuuuHong@users.noreply.github.com> --- .../msg/domain/lecture/exception/NotApprovedLectureException.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/NotApprovedLectureException.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/NotApprovedLectureException.kt index 95231d929..b28e6ad26 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/NotApprovedLectureException.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/NotApprovedLectureException.kt @@ -3,6 +3,6 @@ package team.msg.domain.lecture.exception import team.msg.domain.lecture.exception.constant.LectureErrorCode import team.msg.global.error.exception.BitgouelException -class NotApprovedLectureException( +class UnApprovedLectureException( message: String ) : BitgouelException(message, LectureErrorCode.NOT_APPROVED_LECTURE.status) \ No newline at end of file From cca4e4bb4e3d7d585383964f676d014fa66a130a Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 27 Oct 2023 11:20:24 +0900 Subject: [PATCH 18/26] update :: Not -> Un --- ...dLectureException.kt => UnApprovedLectureException.kt} | 0 .../domain/lecture/exception/constant/LectureErrorCode.kt | 4 ++-- .../team/msg/domain/lecture/service/LectureServiceImpl.kt | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) rename bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/{NotApprovedLectureException.kt => UnApprovedLectureException.kt} (100%) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/NotApprovedLectureException.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/UnApprovedLectureException.kt similarity index 100% rename from bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/NotApprovedLectureException.kt rename to bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/UnApprovedLectureException.kt diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt index efad94b31..f4287732f 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt @@ -9,7 +9,7 @@ enum class LectureErrorCode( ALREADY_APPROVED_LECTURE(409), ALREADY_SIGNED_UP_LECTURE(409), - NOT_APPROVED_LECTURE(409), + UNAPPROVED_LECTURE(409), OVER_MAX_REGISTERED_USER(409), MISS_SIGN_UP_ABLE_DATE(409) -} \ No newline at end of file +} diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt index 7588237d4..90abcc669 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt @@ -11,8 +11,8 @@ import team.msg.domain.lecture.exception.AlreadySignedUpLectureException import team.msg.domain.lecture.exception.InvalidLectureTypeException import team.msg.domain.lecture.exception.LectureNotFoundException import team.msg.domain.lecture.exception.MissSignUpAbleDateException -import team.msg.domain.lecture.exception.NotApprovedLectureException import team.msg.domain.lecture.exception.OverMaxRegisteredUserException +import team.msg.domain.lecture.exception.UnApprovedLectureException import team.msg.domain.lecture.model.Lecture import team.msg.domain.lecture.model.RegisteredLecture import team.msg.domain.lecture.presentation.data.request.CreateLectureRequest @@ -70,13 +70,13 @@ class LectureServiceImpl( override fun signUpLecture(id: UUID) { val user = userUtil.queryCurrentUser() - val student = studentRepository.findByIdOrNull(user.id) ?: - throw StudentNotFoundException("학생을 찾을 수 없습니다. info : [ userId = ${user.id}, userName = ${user.name} ]") + val student = studentRepository.findByIdOrNull(user.id) + ?: throw StudentNotFoundException("학생을 찾을 수 없습니다. info : [ userId = ${user.id}, userName = ${user.name} ]") val lecture = queryLecture(id) if(lecture.approveStatus == ApproveStatus.PENDING) - throw NotApprovedLectureException("아직 승인되지 않은 강의입니다. info : [ lectureId = ${lecture.id} ]") + throw UnApprovedLectureException("아직 승인되지 않은 강의입니다. info : [ lectureId = ${lecture.id} ]") if(lecture.startDate.isBefore(LocalDateTime.now())) throw MissSignUpAbleDateException("이른 강의 신청입니다. info : [ lectureStartDate = ${lecture.startDate}, currentDate = ${LocalDateTime.now()} ]") From 3a049aafb655eff5f6955298acc90962784ef212 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 27 Oct 2023 11:21:17 +0900 Subject: [PATCH 19/26] update :: Not -> Un --- .../msg/domain/lecture/exception/UnApprovedLectureException.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/UnApprovedLectureException.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/UnApprovedLectureException.kt index b28e6ad26..ed56b9524 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/UnApprovedLectureException.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/UnApprovedLectureException.kt @@ -5,4 +5,4 @@ import team.msg.global.error.exception.BitgouelException class UnApprovedLectureException( message: String -) : BitgouelException(message, LectureErrorCode.NOT_APPROVED_LECTURE.status) \ No newline at end of file +) : BitgouelException(message, LectureErrorCode.UNAPPROVED_LECTURE.status) \ No newline at end of file From 9e73c85cd4e3a82f40efa7604d9bd1d6bcaf5539 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 27 Oct 2023 11:24:36 +0900 Subject: [PATCH 20/26] update :: username --- .../team/msg/domain/lecture/service/LectureServiceImpl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt index 90abcc669..950437fcb 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt @@ -71,7 +71,7 @@ class LectureServiceImpl( val user = userUtil.queryCurrentUser() val student = studentRepository.findByIdOrNull(user.id) - ?: throw StudentNotFoundException("학생을 찾을 수 없습니다. info : [ userId = ${user.id}, userName = ${user.name} ]") + ?: throw StudentNotFoundException("학생을 찾을 수 없습니다. info : [ userId = ${user.id}, username = ${user.name} ]") val lecture = queryLecture(id) From 9d070838481b4dd411bcac12585b01ee3f7c3fa5 Mon Sep 17 00:00:00 2001 From: ani2689 Date: Fri, 27 Oct 2023 11:29:08 +0900 Subject: [PATCH 21/26] =?UTF-8?q?update=20::=20date=20=EC=98=88=EC=99=B8?= =?UTF-8?q?=20=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...eDateException.kt => NotAvailableSignUpDateException.kt} | 4 ++-- .../domain/lecture/exception/constant/LectureErrorCode.kt | 2 +- .../team/msg/domain/lecture/service/LectureServiceImpl.kt | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) rename bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/{MissSignUpAbleDateException.kt => NotAvailableSignUpDateException.kt} (60%) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/MissSignUpAbleDateException.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/NotAvailableSignUpDateException.kt similarity index 60% rename from bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/MissSignUpAbleDateException.kt rename to bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/NotAvailableSignUpDateException.kt index a72c51694..ce2305a20 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/MissSignUpAbleDateException.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/NotAvailableSignUpDateException.kt @@ -3,6 +3,6 @@ package team.msg.domain.lecture.exception import team.msg.domain.lecture.exception.constant.LectureErrorCode import team.msg.global.error.exception.BitgouelException -class MissSignUpAbleDateException ( +class NotAvailableSignUpDateException ( message: String -) : BitgouelException(message, LectureErrorCode.MISS_SIGN_UP_ABLE_DATE.status) \ No newline at end of file +) : BitgouelException(message, LectureErrorCode.NOT_AVAILABLE_SIGN_UP_DATE.status) \ No newline at end of file diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt index f4287732f..42baf5367 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/exception/constant/LectureErrorCode.kt @@ -11,5 +11,5 @@ enum class LectureErrorCode( ALREADY_SIGNED_UP_LECTURE(409), UNAPPROVED_LECTURE(409), OVER_MAX_REGISTERED_USER(409), - MISS_SIGN_UP_ABLE_DATE(409) + NOT_AVAILABLE_SIGN_UP_DATE(409) } diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt index 950437fcb..337bd9e3e 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt @@ -10,7 +10,7 @@ import team.msg.domain.lecture.exception.AlreadyApprovedLectureException import team.msg.domain.lecture.exception.AlreadySignedUpLectureException import team.msg.domain.lecture.exception.InvalidLectureTypeException import team.msg.domain.lecture.exception.LectureNotFoundException -import team.msg.domain.lecture.exception.MissSignUpAbleDateException +import team.msg.domain.lecture.exception.NotAvailableSignUpDateException import team.msg.domain.lecture.exception.OverMaxRegisteredUserException import team.msg.domain.lecture.exception.UnApprovedLectureException import team.msg.domain.lecture.model.Lecture @@ -79,10 +79,10 @@ class LectureServiceImpl( throw UnApprovedLectureException("아직 승인되지 않은 강의입니다. info : [ lectureId = ${lecture.id} ]") if(lecture.startDate.isBefore(LocalDateTime.now())) - throw MissSignUpAbleDateException("이른 강의 신청입니다. info : [ lectureStartDate = ${lecture.startDate}, currentDate = ${LocalDateTime.now()} ]") + throw NotAvailableSignUpDateException("이른 강의 신청입니다. info : [ lectureStartDate = ${lecture.startDate}, currentDate = ${LocalDateTime.now()} ]") if(lecture.endDate.isAfter(LocalDateTime.now())) - throw MissSignUpAbleDateException("늦은 강의 신청입니다. info : [ lectureEndDate = ${lecture.endDate}, currentDate = ${LocalDateTime.now()} ]") + throw NotAvailableSignUpDateException("늦은 강의 신청입니다. info : [ lectureEndDate = ${lecture.endDate}, currentDate = ${LocalDateTime.now()} ]") if(registeredLectureRepository.existsByStudentAndLecture(student, lecture)) throw AlreadySignedUpLectureException("이미 신청한 강의입니다. info : [ lectureId = ${lecture.id}, studentId = ${student.id} ]") From 6f4f03768fb48d9d3e5c5bd244b35abb30b78f72 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=85=B8=ED=98=84=EC=A3=BC?= <106813267+ani2689@users.noreply.github.com> Date: Fri, 27 Oct 2023 11:30:00 +0900 Subject: [PATCH 22/26] =?UTF-8?q?update=20::=20=EB=B6=88=ED=8E=B8=ED=95=9C?= =?UTF-8?q?=20=EB=9D=84=EC=96=B4=EC=93=B0=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 박주홍 <103554978+JuuuuHong@users.noreply.github.com> --- .../team/msg/domain/lecture/service/LectureServiceImpl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt index 337bd9e3e..5ea7dabbf 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt @@ -122,7 +122,7 @@ class LectureServiceImpl( endDate = lecture.endDate, completeDate = lecture.completeDate, content = lecture.content, - lectureType = lecture.lectureType, + lectureType = lecture.lectureType, credit = lecture.credit, instructor = lecture.instructor, maxRegisteredUser = lecture.maxRegisteredUser, From 4d0b7a557429637f6b761880aa8b5e5763bbae20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EB=85=B8=ED=98=84=EC=A3=BC?= <106813267+ani2689@users.noreply.github.com> Date: Fri, 27 Oct 2023 11:50:36 +0900 Subject: [PATCH 23/26] =?UTF-8?q?update=20::=20=ED=81=AC=EA=B1=B0=EB=82=98?= =?UTF-8?q?=20=EA=B0=99=EC=9D=84=20=EB=95=8C=EB=A1=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: 김희망 <105429536+esperar@users.noreply.github.com> --- .../team/msg/domain/lecture/service/LectureServiceImpl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt index 5ea7dabbf..412d51445 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt @@ -89,7 +89,7 @@ class LectureServiceImpl( val currentSignUpLectureStudent = registeredLectureRepository.findAllByLecture(lecture).size - if(lecture.maxRegisteredUser == currentSignUpLectureStudent) + if(lecture.maxRegisteredUser <= currentSignUpLectureStudent) throw OverMaxRegisteredUserException("수강 인원이 가득 찼습니다. info : [ maxRegisteredUser = ${lecture.maxRegisteredUser}, currentSignUpLectureStudent = $currentSignUpLectureStudent ]") val registeredLecture = RegisteredLecture( From 5c8db5132fde734392aba9fc1f02b3181dc9b68c Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 30 Oct 2023 10:22:32 +0900 Subject: [PATCH 24/26] add :: Lecture status getter --- .../kotlin/team/msg/domain/lecture/model/Lecture.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/model/Lecture.kt b/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/model/Lecture.kt index 7d598da7d..ca9227fe7 100644 --- a/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/model/Lecture.kt +++ b/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/model/Lecture.kt @@ -9,6 +9,7 @@ import javax.persistence.JoinColumn import javax.persistence.ManyToOne import team.msg.common.entity.BaseUUIDEntity import team.msg.common.enum.ApproveStatus +import team.msg.domain.lecture.enum.LectureStatus import team.msg.domain.lecture.enum.LectureType import team.msg.domain.user.model.User import java.time.LocalDateTime @@ -55,4 +56,13 @@ class Lecture( @Enumerated(EnumType.STRING) @Column(columnDefinition = "VARCHAR(10)", nullable = false) var approveStatus: ApproveStatus = ApproveStatus.PENDING -) : BaseUUIDEntity(id) \ No newline at end of file +) : BaseUUIDEntity(id) { + fun getLectureStatus(): LectureStatus { + val currentTime = LocalDateTime.now() + + return if(startDate.isAfter(currentTime) && endDate.isBefore(currentTime)) + LectureStatus.OPEN + else + LectureStatus.CLOSE + } +} \ No newline at end of file From 47c584a1d2f84c8c3b1d5fbeb7f79d04c11f024c Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 30 Oct 2023 10:22:51 +0900 Subject: [PATCH 25/26] create :: Lecture status --- .../kotlin/team/msg/domain/lecture/enum/LectureStatus.kt | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/enum/LectureStatus.kt diff --git a/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/enum/LectureStatus.kt b/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/enum/LectureStatus.kt new file mode 100644 index 000000000..f7a542da3 --- /dev/null +++ b/bitgouel-domain/src/main/kotlin/team/msg/domain/lecture/enum/LectureStatus.kt @@ -0,0 +1,5 @@ +package team.msg.domain.lecture.enum + +enum class LectureStatus { + OPEN, CLOSE +} \ No newline at end of file From 33118a5fdc8cd1026b1e30f188b4f53a7774d74b Mon Sep 17 00:00:00 2001 From: ani2689 Date: Mon, 30 Oct 2023 10:28:59 +0900 Subject: [PATCH 26/26] =?UTF-8?q?update=20::=20Lecture=20status=EB=A1=9C?= =?UTF-8?q?=20=EA=B2=80=EC=A6=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/msg/domain/lecture/service/LectureServiceImpl.kt | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt index 337bd9e3e..acc03d5f9 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/lecture/service/LectureServiceImpl.kt @@ -5,6 +5,7 @@ import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import team.msg.common.enum.ApproveStatus import team.msg.common.util.UserUtil +import team.msg.domain.lecture.enum.LectureStatus import team.msg.domain.lecture.enum.LectureType import team.msg.domain.lecture.exception.AlreadyApprovedLectureException import team.msg.domain.lecture.exception.AlreadySignedUpLectureException @@ -78,11 +79,8 @@ class LectureServiceImpl( if(lecture.approveStatus == ApproveStatus.PENDING) throw UnApprovedLectureException("아직 승인되지 않은 강의입니다. info : [ lectureId = ${lecture.id} ]") - if(lecture.startDate.isBefore(LocalDateTime.now())) - throw NotAvailableSignUpDateException("이른 강의 신청입니다. info : [ lectureStartDate = ${lecture.startDate}, currentDate = ${LocalDateTime.now()} ]") - - if(lecture.endDate.isAfter(LocalDateTime.now())) - throw NotAvailableSignUpDateException("늦은 강의 신청입니다. info : [ lectureEndDate = ${lecture.endDate}, currentDate = ${LocalDateTime.now()} ]") + if(lecture.getLectureStatus() == LectureStatus.CLOSE) + throw NotAvailableSignUpDateException("수강신청이 가능한 시간이 아닙니다. info : [ lectureId = ${lecture.id}, currentTime = ${LocalDateTime.now()} ]") if(registeredLectureRepository.existsByStudentAndLecture(student, lecture)) throw AlreadySignedUpLectureException("이미 신청한 강의입니다. info : [ lectureId = ${lecture.id}, studentId = ${student.id} ]")