From 11592e28a988c2870ed18b4dd1835c2a355273a7 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 13:33:09 +0900 Subject: [PATCH 01/19] create :: update student activity application dto --- .../data/request/UpdateStudentActivityRequest.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/request/UpdateStudentActivityRequest.kt diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/request/UpdateStudentActivityRequest.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/request/UpdateStudentActivityRequest.kt new file mode 100644 index 000000000..6046a5027 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/request/UpdateStudentActivityRequest.kt @@ -0,0 +1,10 @@ +package team.msg.domain.student.presentation.data.request + +import java.time.LocalDateTime + +data class UpdateStudentActivityRequest( + val title: String, + val content: String, + val credit: Int, + val activityDate: LocalDateTime +) \ No newline at end of file From ecbc4ddd3354cfa3a780e9df59a975634764b138 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 13:33:27 +0900 Subject: [PATCH 02/19] create :: update student activity web dto --- .../web/UpdateStudentActivityWebRequest.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/web/UpdateStudentActivityWebRequest.kt diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/web/UpdateStudentActivityWebRequest.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/web/UpdateStudentActivityWebRequest.kt new file mode 100644 index 000000000..aa1324077 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/web/UpdateStudentActivityWebRequest.kt @@ -0,0 +1,22 @@ +package team.msg.domain.student.presentation.data.web + +import javax.validation.constraints.Max +import javax.validation.constraints.NotBlank +import javax.validation.constraints.NotNull +import java.time.LocalDateTime + +data class UpdateStudentActivityWebRequest( + @field:NotBlank + @field:Max(100) + val title: String, + + @field:NotBlank + @field:Max(1000) + val content: String, + + @field:NotNull + val credit: Int, + + @field:NotNull + val activityDate: LocalDateTime +) \ No newline at end of file From 9fb0a50109a186604d3e0b587957d10dae22e5d3 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 13:36:00 +0900 Subject: [PATCH 03/19] add :: update student activity mapper --- .../student/mapper/StudentActivityMapper.kt | 3 +++ .../student/mapper/StudentActivityMapperImpl.kt | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/mapper/StudentActivityMapper.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/mapper/StudentActivityMapper.kt index 81d47fbfe..f4db65c43 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/student/mapper/StudentActivityMapper.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/mapper/StudentActivityMapper.kt @@ -1,8 +1,11 @@ package team.msg.domain.student.mapper import team.msg.domain.student.presentation.data.request.CreateStudentActivityRequest +import team.msg.domain.student.presentation.data.request.UpdateStudentActivityRequest import team.msg.domain.student.presentation.data.web.CreateStudentActivityWebRequest +import team.msg.domain.student.presentation.data.web.UpdateStudentActivityWebRequest interface StudentActivityMapper { fun createStudentActivityWebRequestToDto(webRequest: CreateStudentActivityWebRequest): CreateStudentActivityRequest + fun updateStudentActivityWebRequestToDto(webRequest: UpdateStudentActivityWebRequest): UpdateStudentActivityRequest } \ No newline at end of file diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/mapper/StudentActivityMapperImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/mapper/StudentActivityMapperImpl.kt index cf62c681d..c60e98fcf 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/student/mapper/StudentActivityMapperImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/mapper/StudentActivityMapperImpl.kt @@ -2,13 +2,15 @@ package team.msg.domain.student.mapper import org.springframework.stereotype.Component import team.msg.domain.student.presentation.data.request.CreateStudentActivityRequest +import team.msg.domain.student.presentation.data.request.UpdateStudentActivityRequest import team.msg.domain.student.presentation.data.web.CreateStudentActivityWebRequest +import team.msg.domain.student.presentation.data.web.UpdateStudentActivityWebRequest @Component class StudentActivityMapperImpl : StudentActivityMapper { /** - * StudentActivity 생성 Web Request 를 애플리케이션 영역에서 사용될 Dto 로 매핑합니다. + * StudentActivity 생성 Web Request를 애플리케이션 영역에서 사용될 Dto 로 매핑합니다. */ override fun createStudentActivityWebRequestToDto(webRequest: CreateStudentActivityWebRequest): CreateStudentActivityRequest = CreateStudentActivityRequest( @@ -17,4 +19,15 @@ class StudentActivityMapperImpl : StudentActivityMapper { credit = webRequest.credit, activityDate = webRequest.activityDate ) + + /** + * StudentActivity 생성 Web Request를 애플리케이션 영역에서 사용될 Dto로 매핑합니다. + */ + override fun updateStudentActivityWebRequestToDto(webRequest: UpdateStudentActivityWebRequest): UpdateStudentActivityRequest = + UpdateStudentActivityRequest( + title = webRequest.title, + content = webRequest.content, + credit = webRequest.credit, + activityDate = webRequest.activityDate + ) } \ No newline at end of file From 001647bee28ca70d76954c7c70cc1bae587a835b Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 14:43:41 +0900 Subject: [PATCH 04/19] create :: student activity not found error handle --- .../exception/StudentActivityNotFoundException.kt | 9 +++++++++ .../exception/constant/StudentActivityErrorCode.kt | 8 ++++++++ 2 files changed, 17 insertions(+) create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/student/exception/StudentActivityNotFoundException.kt create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/student/exception/constant/StudentActivityErrorCode.kt diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/exception/StudentActivityNotFoundException.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/exception/StudentActivityNotFoundException.kt new file mode 100644 index 000000000..582603248 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/exception/StudentActivityNotFoundException.kt @@ -0,0 +1,9 @@ +package team.msg.domain.student.exception + +import team.msg.domain.student.exception.constant.StudentActivityErrorCode +import team.msg.global.error.exception.BitgouelException + +class StudentActivityNotFoundException( + message: String +) : BitgouelException(message, StudentActivityErrorCode.STUDENT_ACTIVITY_NOT_FOUND.status) { +} \ No newline at end of file diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/exception/constant/StudentActivityErrorCode.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/exception/constant/StudentActivityErrorCode.kt new file mode 100644 index 000000000..9b5e70d11 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/exception/constant/StudentActivityErrorCode.kt @@ -0,0 +1,8 @@ +package team.msg.domain.student.exception.constant + +enum class StudentActivityErrorCode( + val message: String, + val status: Int +) { + STUDENT_ACTIVITY_NOT_FOUND("학생 활동을 찾을 수 없습니다", 404) +} \ No newline at end of file From 53c05e748b00d81c6e5b73aa8184462d4b74344b Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 22:56:29 +0900 Subject: [PATCH 05/19] update :: student activity override createdAt --- .../kotlin/team/msg/domain/student/model/StudentActivity.kt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bitgouel-domain/src/main/kotlin/team/msg/domain/student/model/StudentActivity.kt b/bitgouel-domain/src/main/kotlin/team/msg/domain/student/model/StudentActivity.kt index 37f32be97..84768fd5b 100644 --- a/bitgouel-domain/src/main/kotlin/team/msg/domain/student/model/StudentActivity.kt +++ b/bitgouel-domain/src/main/kotlin/team/msg/domain/student/model/StudentActivity.kt @@ -1,5 +1,6 @@ package team.msg.domain.student.model +import javax.persistence.AttributeOverride import team.msg.common.entity.BaseUUIDEntity import javax.persistence.Column import javax.persistence.Entity @@ -31,9 +32,13 @@ class StudentActivity( @Column(columnDefinition = "VARCHAR(10)", nullable = false) val approveStatus: ApproveStatus, + @Column(nullable = false, updatable = false, columnDefinition = "DATETIME(6)") val activityDate: LocalDateTime, + @Column(nullable = false, updatable = false, columnDefinition = "DATETIME(6)") + override val createdAt: LocalDateTime, + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "student_id", columnDefinition = "BINARY(16)", nullable = false) val student: Student, From d214efa490b918657ee0bd13c50c469cee10fac7 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 22:57:43 +0900 Subject: [PATCH 06/19] update :: student activity createAt set default value --- .../kotlin/team/msg/domain/student/model/StudentActivity.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitgouel-domain/src/main/kotlin/team/msg/domain/student/model/StudentActivity.kt b/bitgouel-domain/src/main/kotlin/team/msg/domain/student/model/StudentActivity.kt index 84768fd5b..9c5b6aac3 100644 --- a/bitgouel-domain/src/main/kotlin/team/msg/domain/student/model/StudentActivity.kt +++ b/bitgouel-domain/src/main/kotlin/team/msg/domain/student/model/StudentActivity.kt @@ -37,7 +37,7 @@ class StudentActivity( val activityDate: LocalDateTime, @Column(nullable = false, updatable = false, columnDefinition = "DATETIME(6)") - override val createdAt: LocalDateTime, + override val createdAt: LocalDateTime = LocalDateTime.now(), @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "student_id", columnDefinition = "BINARY(16)", nullable = false) From ad168d158c4975e49ae3c048fa604a63d4ae7c70 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 23:12:59 +0900 Subject: [PATCH 07/19] add :: update student activity service --- .../student/service/StudentActivityService.kt | 3 ++ .../service/StudentActivityServiceImpl.kt | 32 +++++++++++++++++++ .../repository/StudentActivityRepository.kt | 7 ++-- 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityService.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityService.kt index 71682afd0..030e3ec10 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityService.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityService.kt @@ -1,7 +1,10 @@ package team.msg.domain.student.service import team.msg.domain.student.presentation.data.request.CreateStudentActivityRequest +import team.msg.domain.student.presentation.data.request.UpdateStudentActivityRequest +import java.util.UUID interface StudentActivityService { fun createStudentActivity(request: CreateStudentActivityRequest) + fun updateStudentActivity(id: UUID, request: UpdateStudentActivityRequest) } \ No newline at end of file diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt index c3674ef50..62a14934c 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt @@ -4,9 +4,11 @@ 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.student.exception.StudentActivityNotFoundException import team.msg.domain.student.exception.StudentNotFoundException import team.msg.domain.student.model.StudentActivity import team.msg.domain.student.presentation.data.request.CreateStudentActivityRequest +import team.msg.domain.student.presentation.data.request.UpdateStudentActivityRequest import team.msg.domain.student.repository.StudentActivityRepository import team.msg.domain.student.repository.StudentRepository import team.msg.domain.teacher.exception.TeacherNotFoundException @@ -48,4 +50,34 @@ class StudentActivityServiceImpl( studentActivityRepository.save(studentActivity) } + + + /** + * 학생 활동을 업데이트하는 비지니스 로직입니다 + * @param UpdateStudentActivityRequest + */ + @Transactional(rollbackFor = [Exception::class]) + override fun updateStudentActivity(id: UUID,request: UpdateStudentActivityRequest) { + val user = userUtil.queryCurrentUser() + + val student = studentRepository.findByUser(user) + ?: throw StudentNotFoundException("학생을 찾을 수 없습니다. info : [ name = ${user.name} ]") + + val studentActivity = studentActivityRepository.findByIdAndStudent(id, student) + ?: throw StudentActivityNotFoundException("학생 활동을 찾을 수 없습니다. info : [ id = $id ]") + + val updatedStudentActivity = StudentActivity( + id = studentActivity.id, + title = request.title, + content = request.content, + credit = request.credit, + activityDate = request.activityDate, + createdAt = studentActivity.createdAt, + approveStatus = studentActivity.approveStatus, + student = studentActivity.student, + teacher = studentActivity.teacher, + ) + + studentActivityRepository.save(updatedStudentActivity) + } } \ No newline at end of file diff --git a/bitgouel-domain/src/main/kotlin/team/msg/domain/student/repository/StudentActivityRepository.kt b/bitgouel-domain/src/main/kotlin/team/msg/domain/student/repository/StudentActivityRepository.kt index ef39f342d..6afeeccb9 100644 --- a/bitgouel-domain/src/main/kotlin/team/msg/domain/student/repository/StudentActivityRepository.kt +++ b/bitgouel-domain/src/main/kotlin/team/msg/domain/student/repository/StudentActivityRepository.kt @@ -1,7 +1,10 @@ package team.msg.domain.student.repository import org.springframework.data.jpa.repository.JpaRepository +import team.msg.domain.student.model.Student import team.msg.domain.student.model.StudentActivity -import java.util.UUID +import java.util.* -interface StudentActivityRepository : JpaRepository \ No newline at end of file +interface StudentActivityRepository : JpaRepository { + fun findByIdAndStudent(id: UUID, student: Student): StudentActivity? +} \ No newline at end of file From d60a251c7e7c07e11ec755158d8eeca3fa943178 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 23:13:25 +0900 Subject: [PATCH 08/19] add :: update student activity controller --- .../student/presentation/StudentActivityController.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/StudentActivityController.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/StudentActivityController.kt index e24ad56be..c6a17869f 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/StudentActivityController.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/StudentActivityController.kt @@ -3,13 +3,17 @@ package team.msg.domain.student.presentation import javax.validation.Valid import org.springframework.http.HttpStatus import org.springframework.http.ResponseEntity +import org.springframework.web.bind.annotation.PatchMapping +import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.PostMapping import org.springframework.web.bind.annotation.RequestBody import org.springframework.web.bind.annotation.RequestMapping import org.springframework.web.bind.annotation.RestController import team.msg.domain.student.mapper.StudentActivityMapper import team.msg.domain.student.presentation.data.web.CreateStudentActivityWebRequest +import team.msg.domain.student.presentation.data.web.UpdateStudentActivityWebRequest import team.msg.domain.student.service.StudentActivityService +import java.util.UUID @RestController @RequestMapping("/activity") @@ -22,4 +26,10 @@ class StudentActivityController( studentActivityService.createStudentActivity(studentActivityMapper.createStudentActivityWebRequestToDto(request)) return ResponseEntity.status(HttpStatus.CREATED).build() } + + @PatchMapping("/{id}") + fun updateStudentActivity(@PathVariable id: UUID, @RequestBody @Valid webRequest: UpdateStudentActivityWebRequest): ResponseEntity { + studentActivityService.updateStudentActivity(id, studentActivityMapper.updateStudentActivityWebRequestToDto(webRequest)) + return ResponseEntity.status(HttpStatus.NO_CONTENT).build() + } } \ No newline at end of file From ce94bac1657bb81ed6616b1c3ca0f95454ead5fe Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 23:15:38 +0900 Subject: [PATCH 09/19] =?UTF-8?q?add=20::=20security=20config=EC=97=90=20u?= =?UTF-8?q?pdate=20student=20activity=20uri=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/team/msg/global/security/SecurityConfig.kt | 1 + 1 file changed, 1 insertion(+) 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 a7175dc3e..0bb71f4d7 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 @@ -55,6 +55,7 @@ class SecurityConfig( // activity .mvcMatchers(HttpMethod.POST, "/activity").hasRole(STUDENT) + .mvcMatchers(HttpMethod.PATCH, "/activity/{id}").hasRole(STUDENT) // lecture .mvcMatchers(HttpMethod.POST, "/lecture").hasAnyRole(PROFESSOR, COMPANY_INSTRUCTOR, GOVERNMENT) From a663d166eae5532d8cee600aba1f5f8a16ba6863 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Sat, 21 Oct 2023 22:56:50 +0900 Subject: [PATCH 10/19] =?UTF-8?q?refactor=20::=20mapper=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=EB=A5=BC=20=EB=B3=80=EC=88=98=EB=A1=9C=20=EB=B6=84?= =?UTF-8?q?=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/student/presentation/StudentActivityController.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/StudentActivityController.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/StudentActivityController.kt index e77b9d15f..51e14a329 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/StudentActivityController.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/StudentActivityController.kt @@ -30,7 +30,8 @@ class StudentActivityController( @PatchMapping("/{id}") fun updateStudentActivity(@PathVariable id: UUID, @RequestBody @Valid webRequest: UpdateStudentActivityWebRequest): ResponseEntity { - studentActivityService.updateStudentActivity(id, studentActivityMapper.updateStudentActivityWebRequestToDto(webRequest)) + val request = studentActivityMapper.updateStudentActivityWebRequestToDto(webRequest) + studentActivityService.updateStudentActivity(id, request) return ResponseEntity.status(HttpStatus.NO_CONTENT).build() } } \ No newline at end of file From f2aff4733d7b123112496e926e673929bc3c7f66 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=ED=83=9C=EC=98=A4?= <103710151+KimTaeO@users.noreply.github.com> Date: Sat, 21 Oct 2023 14:00:51 +0000 Subject: [PATCH 11/19] Update bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt 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/student/service/StudentActivityServiceImpl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt index 62a14934c..cb06cd717 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt @@ -57,7 +57,7 @@ class StudentActivityServiceImpl( * @param UpdateStudentActivityRequest */ @Transactional(rollbackFor = [Exception::class]) - override fun updateStudentActivity(id: UUID,request: UpdateStudentActivityRequest) { + override fun updateStudentActivity(id: UUID, request: UpdateStudentActivityRequest) { val user = userUtil.queryCurrentUser() val student = studentRepository.findByUser(user) From 749aa993bc1045bb6a4f4410a3e3c473201dce58 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Sat, 21 Oct 2023 23:04:38 +0900 Subject: [PATCH 12/19] =?UTF-8?q?update=20::=20=ED=95=99=EC=83=9D=20?= =?UTF-8?q?=ED=99=9C=EB=8F=99=20=EC=88=98=EC=A0=95=20=EC=8B=9C=20=EC=8A=B9?= =?UTF-8?q?=EC=9D=B8=20=EC=83=81=ED=83=9C=20=EB=8C=80=EA=B8=B0=EB=A1=9C=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/domain/student/service/StudentActivityServiceImpl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt index 62a14934c..5041d5ebd 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt @@ -73,7 +73,7 @@ class StudentActivityServiceImpl( credit = request.credit, activityDate = request.activityDate, createdAt = studentActivity.createdAt, - approveStatus = studentActivity.approveStatus, + approveStatus = ApproveStatus.PENDING, student = studentActivity.student, teacher = studentActivity.teacher, ) From 5bd7912608bfd5b53f759cc8c19310985b2397c9 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Sat, 21 Oct 2023 23:08:58 +0900 Subject: [PATCH 13/19] =?UTF-8?q?update=20::=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=EC=97=90=20id=EC=B6=94=EA=B0=80=20=EB=B0=8F?= =?UTF-8?q?=20name=20->=20username?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/domain/student/service/StudentActivityServiceImpl.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt index 5041d5ebd..646688e58 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt @@ -61,7 +61,7 @@ class StudentActivityServiceImpl( val user = userUtil.queryCurrentUser() val student = studentRepository.findByUser(user) - ?: throw StudentNotFoundException("학생을 찾을 수 없습니다. info : [ name = ${user.name} ]") + ?: throw StudentNotFoundException("학생을 찾을 수 없습니다. info : [ id = ${user.id}, username = ${user.name} ]") val studentActivity = studentActivityRepository.findByIdAndStudent(id, student) ?: throw StudentActivityNotFoundException("학생 활동을 찾을 수 없습니다. info : [ id = $id ]") From dcbdaace1475deb8c490fad3935abe512df89195 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Sat, 21 Oct 2023 23:30:35 +0900 Subject: [PATCH 14/19] =?UTF-8?q?delete=20::=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20overriding=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/msg/domain/student/model/StudentActivity.kt | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/bitgouel-domain/src/main/kotlin/team/msg/domain/student/model/StudentActivity.kt b/bitgouel-domain/src/main/kotlin/team/msg/domain/student/model/StudentActivity.kt index 9c5b6aac3..05d7b5982 100644 --- a/bitgouel-domain/src/main/kotlin/team/msg/domain/student/model/StudentActivity.kt +++ b/bitgouel-domain/src/main/kotlin/team/msg/domain/student/model/StudentActivity.kt @@ -1,7 +1,5 @@ package team.msg.domain.student.model -import javax.persistence.AttributeOverride -import team.msg.common.entity.BaseUUIDEntity import javax.persistence.Column import javax.persistence.Entity import javax.persistence.EnumType @@ -9,10 +7,11 @@ import javax.persistence.Enumerated import javax.persistence.FetchType import javax.persistence.JoinColumn import javax.persistence.ManyToOne +import team.msg.common.entity.BaseUUIDEntity import team.msg.common.enum.ApproveStatus import team.msg.domain.teacher.model.Teacher import java.time.LocalDateTime -import java.util.UUID +import java.util.* @Entity class StudentActivity( @@ -32,13 +31,9 @@ class StudentActivity( @Column(columnDefinition = "VARCHAR(10)", nullable = false) val approveStatus: ApproveStatus, - - @Column(nullable = false, updatable = false, columnDefinition = "DATETIME(6)") + @Column(nullable = false, columnDefinition = "DATETIME(6)") val activityDate: LocalDateTime, - @Column(nullable = false, updatable = false, columnDefinition = "DATETIME(6)") - override val createdAt: LocalDateTime = LocalDateTime.now(), - @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "student_id", columnDefinition = "BINARY(16)", nullable = false) val student: Student, From 3c5b22efad7441406dfa9dd399882cc5e7153998 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Sat, 21 Oct 2023 23:35:11 +0900 Subject: [PATCH 15/19] =?UTF-8?q?add=20::=20LastModifiedAt=20property=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/team/msg/common/entity/BaseTimeEntity.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/bitgouel-domain/src/main/kotlin/team/msg/common/entity/BaseTimeEntity.kt b/bitgouel-domain/src/main/kotlin/team/msg/common/entity/BaseTimeEntity.kt index 39611c085..c34a41f19 100644 --- a/bitgouel-domain/src/main/kotlin/team/msg/common/entity/BaseTimeEntity.kt +++ b/bitgouel-domain/src/main/kotlin/team/msg/common/entity/BaseTimeEntity.kt @@ -2,10 +2,16 @@ package team.msg.common.entity import javax.persistence.Column import javax.persistence.MappedSuperclass +import org.springframework.data.annotation.CreatedDate +import org.springframework.data.annotation.LastModifiedDate import java.time.LocalDateTime @MappedSuperclass abstract class BaseTimeEntity( @Column(nullable = false, updatable = false, columnDefinition = "DATETIME(6)") - open val createdAt: LocalDateTime = LocalDateTime.now() + var createdAt: LocalDateTime = LocalDateTime.now(), + + @LastModifiedDate + @Column(nullable = false, columnDefinition = "DATETIME(6)") + var modifiedAt: LocalDateTime = LocalDateTime.now() ) \ No newline at end of file From 77a7326dba1bf05657d5e251658ec940914d4f3b Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Sat, 21 Oct 2023 23:35:47 +0900 Subject: [PATCH 16/19] =?UTF-8?q?add=20::=20createdAt=EC=97=90=20CreatedDa?= =?UTF-8?q?te=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/team/msg/common/entity/BaseTimeEntity.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/bitgouel-domain/src/main/kotlin/team/msg/common/entity/BaseTimeEntity.kt b/bitgouel-domain/src/main/kotlin/team/msg/common/entity/BaseTimeEntity.kt index c34a41f19..8df64bb95 100644 --- a/bitgouel-domain/src/main/kotlin/team/msg/common/entity/BaseTimeEntity.kt +++ b/bitgouel-domain/src/main/kotlin/team/msg/common/entity/BaseTimeEntity.kt @@ -8,6 +8,7 @@ import java.time.LocalDateTime @MappedSuperclass abstract class BaseTimeEntity( + @CreatedDate @Column(nullable = false, updatable = false, columnDefinition = "DATETIME(6)") var createdAt: LocalDateTime = LocalDateTime.now(), From 4382c4848280969399c308098d4ad560a57923ea Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Sat, 21 Oct 2023 23:36:40 +0900 Subject: [PATCH 17/19] =?UTF-8?q?update=20::=20property=EB=93=A4=20field?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=8F=99=20=EB=B0=8F=20setter=20=EC=A0=91?= =?UTF-8?q?=EA=B7=BC=20=EC=A0=9C=ED=95=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/team/msg/common/entity/BaseTimeEntity.kt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bitgouel-domain/src/main/kotlin/team/msg/common/entity/BaseTimeEntity.kt b/bitgouel-domain/src/main/kotlin/team/msg/common/entity/BaseTimeEntity.kt index 8df64bb95..b1376c2c0 100644 --- a/bitgouel-domain/src/main/kotlin/team/msg/common/entity/BaseTimeEntity.kt +++ b/bitgouel-domain/src/main/kotlin/team/msg/common/entity/BaseTimeEntity.kt @@ -7,12 +7,14 @@ import org.springframework.data.annotation.LastModifiedDate import java.time.LocalDateTime @MappedSuperclass -abstract class BaseTimeEntity( +abstract class BaseTimeEntity { @CreatedDate @Column(nullable = false, updatable = false, columnDefinition = "DATETIME(6)") - var createdAt: LocalDateTime = LocalDateTime.now(), + var createdAt: LocalDateTime = LocalDateTime.now() + protected set @LastModifiedDate @Column(nullable = false, columnDefinition = "DATETIME(6)") var modifiedAt: LocalDateTime = LocalDateTime.now() -) \ No newline at end of file + protected set +} \ No newline at end of file From 68da549a9bdc45c0610b0803a2f6ac81010ba480 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Sat, 21 Oct 2023 23:41:33 +0900 Subject: [PATCH 18/19] =?UTF-8?q?delete=20::=20update=ED=95=A0=20=EA=B0=9D?= =?UTF-8?q?=EC=B2=B4=20=EC=9D=B8=EC=8A=A4=ED=84=B4=EC=8A=A4=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EC=8B=9C=20createdAt=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/domain/student/service/StudentActivityServiceImpl.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt index f181c84df..4691c4522 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt @@ -72,7 +72,6 @@ class StudentActivityServiceImpl( content = request.content, credit = request.credit, activityDate = request.activityDate, - createdAt = studentActivity.createdAt, approveStatus = ApproveStatus.PENDING, student = studentActivity.student, teacher = studentActivity.teacher, From 05d3ea81c6462be0ba4e7aee8138596d9f3ccd19 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Mon, 23 Oct 2023 09:01:58 +0900 Subject: [PATCH 19/19] =?UTF-8?q?update=20::=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EB=A1=9C=EA=B7=B8=20=ED=91=9C=EA=B8=B0=EB=AA=85=20=EC=A0=95?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/domain/student/service/StudentActivityServiceImpl.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt index 4691c4522..ce4439ae6 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt @@ -61,10 +61,10 @@ class StudentActivityServiceImpl( val user = userUtil.queryCurrentUser() val student = studentRepository.findByUser(user) - ?: throw StudentNotFoundException("학생을 찾을 수 없습니다. info : [ id = ${user.id}, username = ${user.name} ]") + ?: throw StudentNotFoundException("학생을 찾을 수 없습니다. info : [ userId = ${user.id}, username = ${user.name} ]") val studentActivity = studentActivityRepository.findByIdAndStudent(id, student) - ?: throw StudentActivityNotFoundException("학생 활동을 찾을 수 없습니다. info : [ id = $id ]") + ?: throw StudentActivityNotFoundException("학생 활동을 찾을 수 없습니다. info : [ studentActivityId = $id ]") val updatedStudentActivity = StudentActivity( id = studentActivity.id,