From f65201843d17a557de29f0df39da242938120106 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Thu, 19 Oct 2023 12:19:53 +0900 Subject: [PATCH 01/25] add :: create student activity web request --- .../web/CreateStudentActivityWebRequest.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/user/presentation/data/web/CreateStudentActivityWebRequest.kt diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/user/presentation/data/web/CreateStudentActivityWebRequest.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/user/presentation/data/web/CreateStudentActivityWebRequest.kt new file mode 100644 index 000000000..d52253225 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/user/presentation/data/web/CreateStudentActivityWebRequest.kt @@ -0,0 +1,22 @@ +package team.msg.domain.user.presentation.data.web + +import javax.validation.constraints.Max +import javax.validation.constraints.NotBlank +import javax.validation.constraints.NotNull +import java.time.LocalDateTime + +data class CreateStudentActivityWebRequest( + @field:NotBlank + @field:Max(100) + val title: String, + + @field:NotBlank + @field:Max(1000) + val content: String, + + @field:NotNull + val credit: Int, + + @field:NotNull + val createdAt: LocalDateTime +) \ No newline at end of file From 52257dc6f65de885338bd27230c4e8eb356d84ba Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Thu, 19 Oct 2023 12:20:17 +0900 Subject: [PATCH 02/25] add :: create student activity request --- .../data/request/CreateStudentActivityRequest.kt | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/user/presentation/data/request/CreateStudentActivityRequest.kt diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/user/presentation/data/request/CreateStudentActivityRequest.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/user/presentation/data/request/CreateStudentActivityRequest.kt new file mode 100644 index 000000000..1cbad9295 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/user/presentation/data/request/CreateStudentActivityRequest.kt @@ -0,0 +1,10 @@ +package team.msg.domain.user.presentation.data.request + +import java.time.LocalDateTime + +data class CreateStudentActivityRequest( + val title: String, + val content: String, + val credit: Int, + val createdAt: LocalDateTime +) \ No newline at end of file From df5787b398e8ba31836c2f35928b2107b222fb5e Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Thu, 19 Oct 2023 12:20:46 +0900 Subject: [PATCH 03/25] add :: create student activity mapper --- .../domain/user/mapper/StudentActivityMapper.kt | 8 ++++++++ .../user/mapper/StudentActivityMapperImpl.kt | 14 ++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/user/mapper/StudentActivityMapper.kt create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/user/mapper/StudentActivityMapperImpl.kt diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/user/mapper/StudentActivityMapper.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/user/mapper/StudentActivityMapper.kt new file mode 100644 index 000000000..1fd885750 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/user/mapper/StudentActivityMapper.kt @@ -0,0 +1,8 @@ +package team.msg.domain.user.mapper + +import team.msg.domain.user.presentation.data.request.CreateStudentActivityRequest +import team.msg.domain.user.presentation.data.web.CreateStudentActivityWebRequest + +interface StudentActivityMapper { + fun studentActivityWebRequestToDto(webRequest: CreateStudentActivityWebRequest): CreateStudentActivityRequest +} \ No newline at end of file diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/user/mapper/StudentActivityMapperImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/user/mapper/StudentActivityMapperImpl.kt new file mode 100644 index 000000000..d838faa69 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/user/mapper/StudentActivityMapperImpl.kt @@ -0,0 +1,14 @@ +package team.msg.domain.user.mapper + +import team.msg.domain.user.presentation.data.request.CreateStudentActivityRequest +import team.msg.domain.user.presentation.data.web.CreateStudentActivityWebRequest + +class StudentActivityMapperImpl : StudentActivityMapper { + override fun studentActivityWebRequestToDto(webRequest: CreateStudentActivityWebRequest): CreateStudentActivityRequest = + CreateStudentActivityRequest( + title = webRequest.title, + content = webRequest.content, + credit = webRequest.credit, + createdAt = webRequest.createdAt + ) +} \ No newline at end of file From 9d8ce9e0e0280b1700a60dfec590922efc7a8d4d Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Thu, 19 Oct 2023 14:14:09 +0900 Subject: [PATCH 04/25] =?UTF-8?q?update=20::=20studentactivity=20=EC=BD=94?= =?UTF-8?q?=EB=93=9C=20=EC=83=88=EB=A1=9C=EC=9A=B4=20student=20package?= =?UTF-8?q?=EB=A1=9C=20=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/domain/student/mapper/StudentActivityMapper.kt | 8 ++++++++ .../{user => student}/mapper/StudentActivityMapperImpl.kt | 6 +++--- .../data/request/CreateStudentActivityRequest.kt | 2 +- .../data/web/CreateStudentActivityWebRequest.kt | 2 +- .../team/msg/domain/user/mapper/StudentActivityMapper.kt | 8 -------- 5 files changed, 13 insertions(+), 13 deletions(-) create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/student/mapper/StudentActivityMapper.kt rename bitgouel-api/src/main/kotlin/team/msg/domain/{user => student}/mapper/StudentActivityMapperImpl.kt (65%) rename bitgouel-api/src/main/kotlin/team/msg/domain/{user => student}/presentation/data/request/CreateStudentActivityRequest.kt (75%) rename bitgouel-api/src/main/kotlin/team/msg/domain/{user => student}/presentation/data/web/CreateStudentActivityWebRequest.kt (88%) delete mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/user/mapper/StudentActivityMapper.kt 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 new file mode 100644 index 000000000..4e0d54cc7 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/mapper/StudentActivityMapper.kt @@ -0,0 +1,8 @@ +package team.msg.domain.student.mapper + +import team.msg.domain.student.presentation.data.request.CreateStudentActivityRequest +import team.msg.domain.student.presentation.data.web.CreateStudentActivityWebRequest + +interface StudentActivityMapper { + fun studentActivityWebRequestToDto(webRequest: CreateStudentActivityWebRequest): CreateStudentActivityRequest +} \ No newline at end of file diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/user/mapper/StudentActivityMapperImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/mapper/StudentActivityMapperImpl.kt similarity index 65% rename from bitgouel-api/src/main/kotlin/team/msg/domain/user/mapper/StudentActivityMapperImpl.kt rename to bitgouel-api/src/main/kotlin/team/msg/domain/student/mapper/StudentActivityMapperImpl.kt index d838faa69..4e0010878 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/user/mapper/StudentActivityMapperImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/mapper/StudentActivityMapperImpl.kt @@ -1,7 +1,7 @@ -package team.msg.domain.user.mapper +package team.msg.domain.student.mapper -import team.msg.domain.user.presentation.data.request.CreateStudentActivityRequest -import team.msg.domain.user.presentation.data.web.CreateStudentActivityWebRequest +import team.msg.domain.student.presentation.data.request.CreateStudentActivityRequest +import team.msg.domain.student.presentation.data.web.CreateStudentActivityWebRequest class StudentActivityMapperImpl : StudentActivityMapper { override fun studentActivityWebRequestToDto(webRequest: CreateStudentActivityWebRequest): CreateStudentActivityRequest = diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/user/presentation/data/request/CreateStudentActivityRequest.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/request/CreateStudentActivityRequest.kt similarity index 75% rename from bitgouel-api/src/main/kotlin/team/msg/domain/user/presentation/data/request/CreateStudentActivityRequest.kt rename to bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/request/CreateStudentActivityRequest.kt index 1cbad9295..d8a050d0f 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/user/presentation/data/request/CreateStudentActivityRequest.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/request/CreateStudentActivityRequest.kt @@ -1,4 +1,4 @@ -package team.msg.domain.user.presentation.data.request +package team.msg.domain.student.presentation.data.request import java.time.LocalDateTime diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/user/presentation/data/web/CreateStudentActivityWebRequest.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/web/CreateStudentActivityWebRequest.kt similarity index 88% rename from bitgouel-api/src/main/kotlin/team/msg/domain/user/presentation/data/web/CreateStudentActivityWebRequest.kt rename to bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/web/CreateStudentActivityWebRequest.kt index d52253225..ab5137780 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/user/presentation/data/web/CreateStudentActivityWebRequest.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/web/CreateStudentActivityWebRequest.kt @@ -1,4 +1,4 @@ -package team.msg.domain.user.presentation.data.web +package team.msg.domain.student.presentation.data.web import javax.validation.constraints.Max import javax.validation.constraints.NotBlank diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/user/mapper/StudentActivityMapper.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/user/mapper/StudentActivityMapper.kt deleted file mode 100644 index 1fd885750..000000000 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/user/mapper/StudentActivityMapper.kt +++ /dev/null @@ -1,8 +0,0 @@ -package team.msg.domain.user.mapper - -import team.msg.domain.user.presentation.data.request.CreateStudentActivityRequest -import team.msg.domain.user.presentation.data.web.CreateStudentActivityWebRequest - -interface StudentActivityMapper { - fun studentActivityWebRequestToDto(webRequest: CreateStudentActivityWebRequest): CreateStudentActivityRequest -} \ No newline at end of file From f942e4bf659c5c6b43cf769ed81d04787f16386b Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Thu, 19 Oct 2023 18:26:37 +0900 Subject: [PATCH 05/25] =?UTF-8?q?add=20::=20token=EC=9D=98=20UUID=EB=A1=9C?= =?UTF-8?q?=20User=20=EB=B0=98=ED=99=98=20=EA=B3=B5=ED=86=B5=EB=A1=9C?= =?UTF-8?q?=EC=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/team/msg/common/util/UserUtil.kt | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt diff --git a/bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt b/bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt new file mode 100644 index 000000000..0343fc500 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt @@ -0,0 +1,26 @@ +package team.msg.common.util + +import org.springframework.data.repository.findByIdOrNull +import org.springframework.security.core.context.SecurityContextHolder +import org.springframework.stereotype.Component +import team.msg.domain.user.exception.UserNotFoundException +import team.msg.domain.user.model.User +import team.msg.domain.user.repository.UserRepository +import team.msg.global.security.principal.AuthDetails +import java.util.* + +@Component +class UserUtil( + private val userRepository: UserRepository +) { + fun queryCurrentUser(): User { + val principal = SecurityContextHolder.getContext().authentication.principal + + val userId = UUID.fromString(if(principal is AuthDetails) + principal.username + else + principal.toString()) + + return userRepository.findByIdOrNull(userId) ?: throw UserNotFoundException("존재하지 않는 유저입니다.") + } +} \ No newline at end of file From ba05e8647e5ac71b4124dd1eea563ffbf1a03033 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Thu, 19 Oct 2023 18:29:40 +0900 Subject: [PATCH 06/25] add :: student not found exception --- .../domain/student/exception/StudentNotFoundException.kt | 8 ++++++++ .../domain/student/exception/constant/StudentErrorCode.kt | 8 ++++++++ 2 files changed, 16 insertions(+) create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/student/exception/StudentNotFoundException.kt create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/student/exception/constant/StudentErrorCode.kt diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/exception/StudentNotFoundException.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/exception/StudentNotFoundException.kt new file mode 100644 index 000000000..2488bbf6d --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/exception/StudentNotFoundException.kt @@ -0,0 +1,8 @@ +package team.msg.domain.student.exception + +import team.msg.domain.student.exception.constant.StudentErrorCode +import team.msg.global.error.exception.BitgouelException + +class StudentNotFoundException( + message: String +) : BitgouelException(message, StudentErrorCode.STUDENT_NOT_FOUND.status) \ No newline at end of file diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/exception/constant/StudentErrorCode.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/exception/constant/StudentErrorCode.kt new file mode 100644 index 000000000..73f1548b2 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/exception/constant/StudentErrorCode.kt @@ -0,0 +1,8 @@ +package team.msg.domain.student.exception.constant + +enum class StudentErrorCode( + val message: String, + val status: Int +) { + STUDENT_NOT_FOUND("학생을 찾을 수 없습니다.", 404) +} \ No newline at end of file From 4d442d45e8618607357f38959dbb1f85768d25ed Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Thu, 19 Oct 2023 19:05:39 +0900 Subject: [PATCH 07/25] add :: teacher not found exception --- .../domain/teacher/exception/TeacherNotFoundException.kt | 9 +++++++++ .../teacher/exception/constant/TeacherErrorCode.kt | 8 ++++++++ 2 files changed, 17 insertions(+) create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/teacher/exception/TeacherNotFoundException.kt create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/teacher/exception/constant/TeacherErrorCode.kt diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/teacher/exception/TeacherNotFoundException.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/teacher/exception/TeacherNotFoundException.kt new file mode 100644 index 000000000..428f6079f --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/teacher/exception/TeacherNotFoundException.kt @@ -0,0 +1,9 @@ +package team.msg.domain.teacher.exception + +import team.msg.domain.teacher.exception.constant.TeacherErrorCode +import team.msg.global.error.exception.BitgouelException + +class TeacherNotFoundException( + message: String +) : BitgouelException(message, TeacherErrorCode.TEACHER_NOT_FOUND.status) { +} \ No newline at end of file diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/teacher/exception/constant/TeacherErrorCode.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/teacher/exception/constant/TeacherErrorCode.kt new file mode 100644 index 000000000..d711d6bfa --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/teacher/exception/constant/TeacherErrorCode.kt @@ -0,0 +1,8 @@ +package team.msg.domain.teacher.exception.constant + +enum class TeacherErrorCode( + val message: String, + val status: Int +) { + TEACHER_NOT_FOUND("취업 동아리 선생님을 찾을 수 없습니다.", 404) +} \ No newline at end of file From 63b9cc4b985364135e625baabaea07cbaed91cde Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Thu, 19 Oct 2023 19:39:29 +0900 Subject: [PATCH 08/25] add :: create student activity service --- .../team/msg/domain/student/repository/StudentRepository.kt | 2 ++ .../team/msg/domain/teacher/repository/TeacherRepository.kt | 2 ++ 2 files changed, 4 insertions(+) diff --git a/bitgouel-domain/src/main/kotlin/team/msg/domain/student/repository/StudentRepository.kt b/bitgouel-domain/src/main/kotlin/team/msg/domain/student/repository/StudentRepository.kt index 1b63a8ea1..c6ec190b5 100644 --- a/bitgouel-domain/src/main/kotlin/team/msg/domain/student/repository/StudentRepository.kt +++ b/bitgouel-domain/src/main/kotlin/team/msg/domain/student/repository/StudentRepository.kt @@ -2,7 +2,9 @@ package team.msg.domain.student.repository import org.springframework.data.repository.CrudRepository import team.msg.domain.student.model.Student +import team.msg.domain.user.model.User import java.util.UUID interface StudentRepository : CrudRepository { + fun findByUser(user: User): Student? } \ No newline at end of file diff --git a/bitgouel-domain/src/main/kotlin/team/msg/domain/teacher/repository/TeacherRepository.kt b/bitgouel-domain/src/main/kotlin/team/msg/domain/teacher/repository/TeacherRepository.kt index f70e69666..ad3db16ec 100644 --- a/bitgouel-domain/src/main/kotlin/team/msg/domain/teacher/repository/TeacherRepository.kt +++ b/bitgouel-domain/src/main/kotlin/team/msg/domain/teacher/repository/TeacherRepository.kt @@ -1,8 +1,10 @@ package team.msg.domain.teacher.repository import org.springframework.data.repository.CrudRepository +import team.msg.domain.club.model.Club import team.msg.domain.teacher.model.Teacher import java.util.UUID interface TeacherRepository : CrudRepository { + fun findByClub(club: Club): Teacher? } \ No newline at end of file From e1d6011c69c04421a73e7b244ae25c8111718e91 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Thu, 19 Oct 2023 19:39:59 +0900 Subject: [PATCH 09/25] add :: create student activity service --- .../student/service/StudentActivityService.kt | 7 +++ .../service/StudentActivityServiceImpl.kt | 47 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityService.kt create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt 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 new file mode 100644 index 000000000..71682afd0 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityService.kt @@ -0,0 +1,7 @@ +package team.msg.domain.student.service + +import team.msg.domain.student.presentation.data.request.CreateStudentActivityRequest + +interface StudentActivityService { + fun createStudentActivity(request: CreateStudentActivityRequest) +} \ 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 new file mode 100644 index 000000000..4c44b84c8 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/service/StudentActivityServiceImpl.kt @@ -0,0 +1,47 @@ +package team.msg.domain.student.service + +import org.springframework.stereotype.Service +import team.msg.common.enum.ApproveStatus +import team.msg.common.util.UserUtil +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.repository.StudentActivityRepository +import team.msg.domain.student.repository.StudentRepository +import team.msg.domain.teacher.exception.TeacherNotFoundException +import team.msg.domain.teacher.repository.TeacherRepository +import java.util.* + +@Service +class StudentActivityServiceImpl( + private val userUtil: UserUtil, + private val studentRepository: StudentRepository, + private val teacherRepository: TeacherRepository, + private val studentActivityRepository: StudentActivityRepository +) : StudentActivityService { + + /** + * 학생 활동을 생성하는 비지니스 로직입니다 + * @param CreateStudentActivityRequest + */ + override fun createStudentActivity(request: CreateStudentActivityRequest) { + val user = userUtil.queryCurrentUser() + + val student = studentRepository.findByUser(user) ?: throw StudentNotFoundException("학생을 찾을 수 없습니다.") + + val teacher = teacherRepository.findByClub(student.club) ?: throw TeacherNotFoundException("취업 동아리 선생님을 찾을 수 없습니다.") + + val studentActivity = StudentActivity( + id = UUID.randomUUID(), + title = request.title, + content = request.content, + credit = request.credit, + createdAt = request.createdAt, + student = student, + teacher = teacher, + approveStatus = ApproveStatus.PENDING + ) + + studentActivityRepository.save(studentActivity) + } +} \ No newline at end of file From adc66a4ce7c73141153cd1c765dd45ad383aab9e Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Thu, 19 Oct 2023 19:42:21 +0900 Subject: [PATCH 10/25] =?UTF-8?q?add=20::=20create=20student=20activity?= =?UTF-8?q?=EC=97=90=20Transaction=20annotation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/student/presentation/StudentActivityController.kt | 5 +++++ .../msg/domain/student/service/StudentActivityServiceImpl.kt | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/StudentActivityController.kt 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 new file mode 100644 index 000000000..ed64484f6 --- /dev/null +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/StudentActivityController.kt @@ -0,0 +1,5 @@ +package team.msg.domain.student.presentation + +@ +class StudentActivityController { +} \ 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 4c44b84c8..c2495b676 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 @@ -1,6 +1,7 @@ package team.msg.domain.student.service 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.StudentNotFoundException @@ -24,6 +25,7 @@ class StudentActivityServiceImpl( * 학생 활동을 생성하는 비지니스 로직입니다 * @param CreateStudentActivityRequest */ + @Transactional(rollbackFor = [Exception::class]) override fun createStudentActivity(request: CreateStudentActivityRequest) { val user = userUtil.queryCurrentUser() From 038243acebc6d9c77e89a9728a7445e5113ea8d6 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Thu, 19 Oct 2023 19:46:12 +0900 Subject: [PATCH 11/25] =?UTF-8?q?add=20::=20student=20activity=20mapper?= =?UTF-8?q?=EC=97=90=20Component=20annotation?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/msg/domain/student/mapper/StudentActivityMapperImpl.kt | 2 ++ 1 file changed, 2 insertions(+) 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 4e0010878..4d2c0b14c 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 @@ -1,8 +1,10 @@ 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.web.CreateStudentActivityWebRequest +@Component class StudentActivityMapperImpl : StudentActivityMapper { override fun studentActivityWebRequestToDto(webRequest: CreateStudentActivityWebRequest): CreateStudentActivityRequest = CreateStudentActivityRequest( From ee075ed970c50c0d795fcb5a3a4099b18f63e108 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Thu, 19 Oct 2023 19:47:34 +0900 Subject: [PATCH 12/25] add :: create student activity controller --- .../presentation/StudentActivityController.kt | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) 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 ed64484f6..4b4ad1489 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 @@ -1,5 +1,25 @@ package team.msg.domain.student.presentation -@ -class StudentActivityController { +import javax.validation.Valid +import org.springframework.http.HttpStatus +import org.springframework.http.ResponseEntity +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.service.StudentActivityService + +@RestController +@RequestMapping("/activity") +class StudentActivityController( + private val studentActivityService: StudentActivityService, + private val studentActivityMapper: StudentActivityMapper +) { + @PostMapping + fun createStudentActivity(@RequestBody @Valid request: CreateStudentActivityWebRequest): ResponseEntity { + studentActivityService.createStudentActivity(studentActivityMapper.studentActivityWebRequestToDto(request)) + return ResponseEntity.status(HttpStatus.OK).build() + } } \ No newline at end of file From 945b86761b443b7313c5d5d64e29a338193a59a4 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Thu, 19 Oct 2023 19:55:13 +0900 Subject: [PATCH 13/25] =?UTF-8?q?add=20::=20security=20config=20=EA=B2=BD?= =?UTF-8?q?=EB=A1=9C=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 | 3 +++ 1 file changed, 3 insertions(+) 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 6c70e70cd..27a8bde3f 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 @@ -40,6 +40,9 @@ class SecurityConfig( .mvcMatchers(HttpMethod.POST, "/auth/government").permitAll() .mvcMatchers(HttpMethod.POST, "/auth/company-instructor").permitAll() + // activity + .mvcMatchers(HttpMethod.POST, "/activity").hasRole("STUDENT") + .anyRequest().authenticated() .and() From 4ad8b41a8ac19e4a6b3e369b05ac7dc39c8892f3 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Thu, 19 Oct 2023 20:13:58 +0900 Subject: [PATCH 14/25] =?UTF-8?q?update=20::=20response=20status=20CREATED?= =?UTF-8?q?=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/student/presentation/StudentActivityController.kt | 2 +- 1 file changed, 1 insertion(+), 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 4b4ad1489..5d46714f0 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 @@ -20,6 +20,6 @@ class StudentActivityController( @PostMapping fun createStudentActivity(@RequestBody @Valid request: CreateStudentActivityWebRequest): ResponseEntity { studentActivityService.createStudentActivity(studentActivityMapper.studentActivityWebRequestToDto(request)) - return ResponseEntity.status(HttpStatus.OK).build() + return ResponseEntity.status(HttpStatus.CREATED).build() } } \ No newline at end of file From 006ec32327a396bffcc6dd285a697c310557aec3 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Thu, 19 Oct 2023 20:41:45 +0900 Subject: [PATCH 15/25] =?UTF-8?q?add=20::=20create=20student=20activity=20?= =?UTF-8?q?security=20Config=20=EC=A0=91=EA=B7=BC=20=EA=B6=8C=ED=95=9C=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/kotlin/team/msg/global/security/SecurityConfig.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 27a8bde3f..da9b7c925 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 @@ -18,6 +18,11 @@ import org.springframework.web.cors.CorsUtils class SecurityConfig( private val jwtTokenParser: JwtTokenParser ) { + companion object { + const val ADMIN = "ADMIN" + const val STUDENT = "STUDENT" + } + @Bean protected fun filterChain(http: HttpSecurity): SecurityFilterChain = http @@ -41,7 +46,7 @@ class SecurityConfig( .mvcMatchers(HttpMethod.POST, "/auth/company-instructor").permitAll() // activity - .mvcMatchers(HttpMethod.POST, "/activity").hasRole("STUDENT") + .mvcMatchers(HttpMethod.POST, "/activity").hasAnyRole(ADMIN, STUDENT) .anyRequest().authenticated() .and() From 075de5ba69221fc033e841b41f021b6bb5e66150 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Thu, 19 Oct 2023 22:52:51 +0900 Subject: [PATCH 16/25] =?UTF-8?q?refactor=20::=20=EC=9C=A0=EC=A0=80=20?= =?UTF-8?q?=EA=B2=80=EC=83=89=20=EC=BD=94=EB=93=9C=20=EB=82=B4=EB=B6=80=20?= =?UTF-8?q?=ED=95=A8=EC=88=98=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/team/msg/common/util/UserUtil.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt b/bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt index 0343fc500..3674439f3 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt @@ -21,6 +21,10 @@ class UserUtil( else principal.toString()) - return userRepository.findByIdOrNull(userId) ?: throw UserNotFoundException("존재하지 않는 유저입니다.") + return queryUser(userId) } + + private fun queryUser(userId: UUID): User = + userRepository.findByIdOrNull(userId) + ?: throw UserNotFoundException("존재하지 않는 유저입니다.") } \ No newline at end of file From 3a1bbd57020d71c09651a37226d29bd791ecddc4 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 09:31:42 +0900 Subject: [PATCH 17/25] =?UTF-8?q?refactor=20::=20repository=20=ED=95=A8?= =?UTF-8?q?=EC=88=98=20=EB=B3=80=EC=88=98=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/team/msg/common/util/UserUtil.kt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt b/bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt index 3674439f3..89e09173e 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt @@ -21,10 +21,9 @@ class UserUtil( else principal.toString()) - return queryUser(userId) - } - - private fun queryUser(userId: UUID): User = - userRepository.findByIdOrNull(userId) + val user = userRepository.findByIdOrNull(userId) ?: throw UserNotFoundException("존재하지 않는 유저입니다.") + + return user + } } \ No newline at end of file From 222483d6388b19c695d90654426046a3de0d21da Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 09:44:51 +0900 Subject: [PATCH 18/25] =?UTF-8?q?update=20::=20mapper=20=ED=95=A8=EC=88=98?= =?UTF-8?q?=EB=B3=91=20created=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../team/msg/domain/student/mapper/StudentActivityMapper.kt | 2 +- .../team/msg/domain/student/mapper/StudentActivityMapperImpl.kt | 2 +- .../domain/student/presentation/StudentActivityController.kt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) 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 4e0d54cc7..81d47fbfe 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 @@ -4,5 +4,5 @@ import team.msg.domain.student.presentation.data.request.CreateStudentActivityRe import team.msg.domain.student.presentation.data.web.CreateStudentActivityWebRequest interface StudentActivityMapper { - fun studentActivityWebRequestToDto(webRequest: CreateStudentActivityWebRequest): CreateStudentActivityRequest + fun createStudentActivityWebRequestToDto(webRequest: CreateStudentActivityWebRequest): CreateStudentActivityRequest } \ 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 4d2c0b14c..862d322f5 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 @@ -6,7 +6,7 @@ import team.msg.domain.student.presentation.data.web.CreateStudentActivityWebReq @Component class StudentActivityMapperImpl : StudentActivityMapper { - override fun studentActivityWebRequestToDto(webRequest: CreateStudentActivityWebRequest): CreateStudentActivityRequest = + override fun createStudentActivityWebRequestToDto(webRequest: CreateStudentActivityWebRequest): CreateStudentActivityRequest = CreateStudentActivityRequest( title = webRequest.title, content = webRequest.content, 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 5d46714f0..e24ad56be 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 @@ -19,7 +19,7 @@ class StudentActivityController( ) { @PostMapping fun createStudentActivity(@RequestBody @Valid request: CreateStudentActivityWebRequest): ResponseEntity { - studentActivityService.createStudentActivity(studentActivityMapper.studentActivityWebRequestToDto(request)) + studentActivityService.createStudentActivity(studentActivityMapper.createStudentActivityWebRequestToDto(request)) return ResponseEntity.status(HttpStatus.CREATED).build() } } \ No newline at end of file From 2bc9df30752c7095a690468efba09ab210baa9e2 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 09:47:53 +0900 Subject: [PATCH 19/25] =?UTF-8?q?delete=20::=20=ED=95=84=EC=9A=94=EC=97=86?= =?UTF-8?q?=EB=8A=94=20override=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/team/msg/domain/student/model/StudentActivity.kt | 2 -- 1 file changed, 2 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 579dd32cf..874aaedef 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 @@ -31,8 +31,6 @@ class StudentActivity( @Column(columnDefinition = "VARCHAR(10)", nullable = false) val approveStatus: ApproveStatus, - override val createdAt: LocalDateTime, - @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "student_id", columnDefinition = "BINARY(16)", nullable = false) val student: Student, From 527f193c9cb8b6c3f878a854568931cdcee88c22 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 09:51:08 +0900 Subject: [PATCH 20/25] add :: activity date field --- .../kotlin/team/msg/domain/student/model/StudentActivity.kt | 3 +++ 1 file changed, 3 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 874aaedef..37f32be97 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 @@ -31,6 +31,9 @@ class StudentActivity( @Column(columnDefinition = "VARCHAR(10)", nullable = false) val approveStatus: ApproveStatus, + @Column(nullable = false, updatable = false, columnDefinition = "DATETIME(6)") + val activityDate: LocalDateTime, + @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "student_id", columnDefinition = "BINARY(16)", nullable = false) val student: Student, From 504f38cadb29e50f25a1ce0da1e5c29be4cde81f Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 09:56:00 +0900 Subject: [PATCH 21/25] =?UTF-8?q?update=20::=20createdAt=EC=9D=B4=20?= =?UTF-8?q?=EC=95=84=EB=8B=8C=20activityDate=EB=A1=9C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/student/mapper/StudentActivityMapperImpl.kt | 2 +- .../data/request/CreateStudentActivityRequest.kt | 2 +- .../data/web/CreateStudentActivityWebRequest.kt | 2 +- .../domain/student/service/StudentActivityServiceImpl.kt | 8 +++++--- 4 files changed, 8 insertions(+), 6 deletions(-) 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 862d322f5..c3948e7f3 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 @@ -11,6 +11,6 @@ class StudentActivityMapperImpl : StudentActivityMapper { title = webRequest.title, content = webRequest.content, credit = webRequest.credit, - createdAt = webRequest.createdAt + activityDate = webRequest.activityDate ) } \ No newline at end of file diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/request/CreateStudentActivityRequest.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/request/CreateStudentActivityRequest.kt index d8a050d0f..c0a1c2946 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/request/CreateStudentActivityRequest.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/request/CreateStudentActivityRequest.kt @@ -6,5 +6,5 @@ data class CreateStudentActivityRequest( val title: String, val content: String, val credit: Int, - val createdAt: LocalDateTime + val activityDate: LocalDateTime ) \ No newline at end of file diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/web/CreateStudentActivityWebRequest.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/web/CreateStudentActivityWebRequest.kt index ab5137780..534dc9e66 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/web/CreateStudentActivityWebRequest.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/student/presentation/data/web/CreateStudentActivityWebRequest.kt @@ -18,5 +18,5 @@ data class CreateStudentActivityWebRequest( val credit: Int, @field:NotNull - val createdAt: LocalDateTime + val activityDate: LocalDateTime ) \ 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 c2495b676..bfc83ddf6 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 @@ -29,16 +29,18 @@ class StudentActivityServiceImpl( override fun createStudentActivity(request: CreateStudentActivityRequest) { val user = userUtil.queryCurrentUser() - val student = studentRepository.findByUser(user) ?: throw StudentNotFoundException("학생을 찾을 수 없습니다.") + val student = studentRepository.findByUser(user) + ?: throw StudentNotFoundException("학생을 찾을 수 없습니다.") - val teacher = teacherRepository.findByClub(student.club) ?: throw TeacherNotFoundException("취업 동아리 선생님을 찾을 수 없습니다.") + val teacher = teacherRepository.findByClub(student.club) + ?: throw TeacherNotFoundException("취업 동아리 선생님을 찾을 수 없습니다.") val studentActivity = StudentActivity( id = UUID.randomUUID(), title = request.title, content = request.content, credit = request.credit, - createdAt = request.createdAt, + activityDate = request.activityDate, student = student, teacher = teacher, approveStatus = ApproveStatus.PENDING From e12035aaa1e731f8fcf2573248bf89c2487622a1 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 10:00:08 +0900 Subject: [PATCH 22/25] =?UTF-8?q?update=20::=20error=20message=EC=97=90=20?= =?UTF-8?q?=EC=A0=95=EB=B3=B4=20=EC=B6=9C=EB=A0=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt | 2 +- .../msg/domain/student/service/StudentActivityServiceImpl.kt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt b/bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt index 89e09173e..d3dea2348 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/common/util/UserUtil.kt @@ -22,7 +22,7 @@ class UserUtil( principal.toString()) val user = userRepository.findByIdOrNull(userId) - ?: throw UserNotFoundException("존재하지 않는 유저입니다.") + ?: throw UserNotFoundException("존재하지 않는 유저입니다. : [ id = $userId ]") return user } 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 bfc83ddf6..2afc1d627 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 @@ -30,7 +30,7 @@ class StudentActivityServiceImpl( val user = userUtil.queryCurrentUser() val student = studentRepository.findByUser(user) - ?: throw StudentNotFoundException("학생을 찾을 수 없습니다.") + ?: throw StudentNotFoundException("학생을 찾을 수 없습니다. : [ name = ${user.name} ]") val teacher = teacherRepository.findByClub(student.club) ?: throw TeacherNotFoundException("취업 동아리 선생님을 찾을 수 없습니다.") From 1c779ea6c439e9b3e141ca922509e42e2c9df0bc Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 10:06:04 +0900 Subject: [PATCH 23/25] =?UTF-8?q?delete=20::=20ADMIN=20=EA=B6=8C=ED=95=9C?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/kotlin/team/msg/global/security/SecurityConfig.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 da9b7c925..607d780ab 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 @@ -46,7 +46,7 @@ class SecurityConfig( .mvcMatchers(HttpMethod.POST, "/auth/company-instructor").permitAll() // activity - .mvcMatchers(HttpMethod.POST, "/activity").hasAnyRole(ADMIN, STUDENT) + .mvcMatchers(HttpMethod.POST, "/activity").hasRole(STUDENT) .anyRequest().authenticated() .and() From aacda2f16944236c1f800db6dfc7a4e02e22dc88 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 10:24:44 +0900 Subject: [PATCH 24/25] =?UTF-8?q?update=20::=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=EB=A9=94=EC=8B=9C=EC=A7=80=EC=97=90=20info=20=EC=84=A4?= =?UTF-8?q?=EB=AA=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kotlin/team/msg/domain/auth/service/AuthServiceImpl.kt | 4 ++-- .../msg/domain/student/service/StudentActivityServiceImpl.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bitgouel-api/src/main/kotlin/team/msg/domain/auth/service/AuthServiceImpl.kt b/bitgouel-api/src/main/kotlin/team/msg/domain/auth/service/AuthServiceImpl.kt index 1f41445f4..6906235ee 100644 --- a/bitgouel-api/src/main/kotlin/team/msg/domain/auth/service/AuthServiceImpl.kt +++ b/bitgouel-api/src/main/kotlin/team/msg/domain/auth/service/AuthServiceImpl.kt @@ -193,10 +193,10 @@ class AuthServiceImpl( */ private fun queryClub(highSchool: HighSchool, clubName: String): Club { val school = schoolRepository.findByHighSchool(highSchool) - ?: throw SchoolNotFoundException("존재하지 않는 학교입니다. values : [ highSchool = $highSchool ]") + ?: throw SchoolNotFoundException("존재하지 않는 학교입니다. info : [ highSchool = $highSchool ]") val club = clubRepository.findByNameAndSchool(clubName, school) - ?: throw ClubNotFoundException("존재하지 않는 동아리입니다. values : [ club = $clubName ]") + ?: throw ClubNotFoundException("존재하지 않는 동아리입니다. info : [ club = $clubName ]") return club } 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 2afc1d627..c3674ef50 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 @@ -30,7 +30,7 @@ class StudentActivityServiceImpl( val user = userUtil.queryCurrentUser() val student = studentRepository.findByUser(user) - ?: throw StudentNotFoundException("학생을 찾을 수 없습니다. : [ name = ${user.name} ]") + ?: throw StudentNotFoundException("학생을 찾을 수 없습니다. info : [ name = ${user.name} ]") val teacher = teacherRepository.findByClub(student.club) ?: throw TeacherNotFoundException("취업 동아리 선생님을 찾을 수 없습니다.") From 81dd9d275ede7802499220b296869c2965f03621 Mon Sep 17 00:00:00 2001 From: KimTaeO Date: Fri, 20 Oct 2023 11:15:39 +0900 Subject: [PATCH 25/25] =?UTF-8?q?chore=20::=20create=20student=20activity?= =?UTF-8?q?=20=EC=A3=BC=EC=84=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../msg/domain/student/mapper/StudentActivityMapperImpl.kt | 4 ++++ 1 file changed, 4 insertions(+) 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 c3948e7f3..cf62c681d 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 @@ -6,6 +6,10 @@ import team.msg.domain.student.presentation.data.web.CreateStudentActivityWebReq @Component class StudentActivityMapperImpl : StudentActivityMapper { + + /** + * StudentActivity 생성 Web Request 를 애플리케이션 영역에서 사용될 Dto 로 매핑합니다. + */ override fun createStudentActivityWebRequestToDto(webRequest: CreateStudentActivityWebRequest): CreateStudentActivityRequest = CreateStudentActivityRequest( title = webRequest.title,