diff --git a/build.gradle.kts b/build.gradle.kts index 7c8ab6f..dc45936 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -35,8 +35,9 @@ dependencies { implementation("org.jetbrains.kotlin:kotlin-reflect") implementation("io.jsonwebtoken:jjwt:0.9.1") implementation("org.springdoc:springdoc-openapi-ui:1.6.9") - implementation("com.amazonaws:aws-java-sdk-s3:1.12.281") + implementation("com.amazonaws:aws-java-sdk-s3:1.12.529") implementation("com.google.firebase:firebase-admin:8.1.0") + implementation("javax.servlet:javax.servlet-api:4.0.1") compileOnly("org.projectlombok:lombok") runtimeOnly("com.mysql:mysql-connector-j") annotationProcessor("org.projectlombok:lombok") diff --git a/src/main/kotlin/org/meogo/domain/comment/service/CreateCommentService.kt b/src/main/kotlin/org/meogo/domain/comment/service/CreateCommentService.kt index a4ae194..9337abb 100644 --- a/src/main/kotlin/org/meogo/domain/comment/service/CreateCommentService.kt +++ b/src/main/kotlin/org/meogo/domain/comment/service/CreateCommentService.kt @@ -13,6 +13,7 @@ import org.meogo.domain.user.facade.UserFacade import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional import java.time.LocalDateTime + @Service class CreateCommentService( private val commentRepository: CommentRepository, diff --git a/src/main/kotlin/org/meogo/domain/comment/service/CommentService.kt b/src/main/kotlin/org/meogo/domain/comment/service/QueryCommentService.kt similarity index 86% rename from src/main/kotlin/org/meogo/domain/comment/service/CommentService.kt rename to src/main/kotlin/org/meogo/domain/comment/service/QueryCommentService.kt index b1e6b4b..6bbaa58 100644 --- a/src/main/kotlin/org/meogo/domain/comment/service/CommentService.kt +++ b/src/main/kotlin/org/meogo/domain/comment/service/QueryCommentService.kt @@ -7,11 +7,11 @@ import org.springframework.stereotype.Service import org.springframework.transaction.annotation.Transactional @Service -class CommentService( +class QueryCommentService( private val commentRepository: CommentRepository ) { @Transactional(readOnly = true) - fun getCommentResponses(basicComments: List): List { + fun execute(basicComments: List): List { return basicComments.map { basicComment -> val replies = commentRepository.findAllByComment(basicComment) CommentResponse(basicComment, replies.map { CommentResponse(it) }) diff --git a/src/main/kotlin/org/meogo/domain/post/service/QueryPostDetailService.kt b/src/main/kotlin/org/meogo/domain/post/service/QueryPostDetailService.kt index 3b16c35..164784b 100644 --- a/src/main/kotlin/org/meogo/domain/post/service/QueryPostDetailService.kt +++ b/src/main/kotlin/org/meogo/domain/post/service/QueryPostDetailService.kt @@ -2,7 +2,7 @@ package org.meogo.domain.post.service import org.meogo.domain.comment.domain.CommentRepository import org.meogo.domain.comment.presentation.dto.response.CommentListResponse -import org.meogo.domain.comment.service.CommentService +import org.meogo.domain.comment.service.QueryCommentService import org.meogo.domain.post.domain.PostRepository import org.meogo.domain.post.presentation.dto.response.PostDetailResponse import org.springframework.stereotype.Service @@ -12,7 +12,7 @@ import org.springframework.transaction.annotation.Transactional class QueryPostDetailService( private val postRepository: PostRepository, private val commentRepository: CommentRepository, - private val commentService: CommentService + private val queryCommentService: QueryCommentService ) { @Transactional(readOnly = true) fun execute(postId: Long): PostDetailResponse { @@ -20,7 +20,7 @@ class QueryPostDetailService( val basicComments = commentRepository.findAllByPost(post) - val replies = commentService.getCommentResponses(basicComments) + val replies = queryCommentService.execute(basicComments) val contentListResponse = CommentListResponse( count = replies.size + basicComments.size, diff --git a/src/main/kotlin/org/meogo/domain/question/service/QueryDetailQuestionService.kt b/src/main/kotlin/org/meogo/domain/question/service/QueryDetailQuestionService.kt index 9c4707e..165f57f 100644 --- a/src/main/kotlin/org/meogo/domain/question/service/QueryDetailQuestionService.kt +++ b/src/main/kotlin/org/meogo/domain/question/service/QueryDetailQuestionService.kt @@ -2,7 +2,7 @@ package org.meogo.domain.question.service import org.meogo.domain.comment.domain.CommentRepository import org.meogo.domain.comment.presentation.dto.response.CommentListResponse -import org.meogo.domain.comment.service.CommentService +import org.meogo.domain.comment.service.QueryCommentService import org.meogo.domain.question.domain.QuestionRepository import org.meogo.domain.question.presentation.dto.response.QuestionDetailResponse import org.springframework.stereotype.Service @@ -12,7 +12,7 @@ import org.springframework.transaction.annotation.Transactional class QueryDetailQuestionService( private val questionRepository: QuestionRepository, private val commentRepository: CommentRepository, - private val commentService: CommentService + private val queryCommentService: QueryCommentService ) { @Transactional(readOnly = true) fun execute(questionId: Long): QuestionDetailResponse { @@ -20,7 +20,7 @@ class QueryDetailQuestionService( val basicComments = commentRepository.findAllByQuestion(question) - val replies = commentService.getCommentResponses(basicComments) + val replies = queryCommentService.execute(basicComments) val contentListResponse = CommentListResponse( count = replies.size + basicComments.size, diff --git a/src/main/kotlin/org/meogo/domain/user/domain/User.kt b/src/main/kotlin/org/meogo/domain/user/domain/User.kt index 44d96e2..2c7aa79 100644 --- a/src/main/kotlin/org/meogo/domain/user/domain/User.kt +++ b/src/main/kotlin/org/meogo/domain/user/domain/User.kt @@ -1,16 +1,13 @@ package org.meogo.domain.user.domain import org.meogo.global.base.BaseUUIDEntity -import java.util.UUID import javax.persistence.Column import javax.persistence.Entity import javax.persistence.EnumType import javax.persistence.Enumerated @Entity -class User( - id: UUID? = null, - +data class User( @Column(nullable = false, length = 4) var name: String, @@ -25,12 +22,20 @@ class User( var profile: String, @Enumerated(EnumType.STRING) - val role: UserRole -) : BaseUUIDEntity(id) { + val role: UserRole, + + @Column(name = "device_token", nullable = true) + var deviceToken: String? = null +) : BaseUUIDEntity() { fun updateProfile(name: String, enrolledSchool: Int, profile: String): User { this.name = name this.enrolledSchool = enrolledSchool this.profile = profile return this } + + fun updateDeviceToken(deviceToken: String): User { + this.deviceToken = deviceToken + return this + } } diff --git a/src/main/kotlin/org/meogo/domain/user/presentation/dto/request/UserSignInRequest.kt b/src/main/kotlin/org/meogo/domain/user/presentation/dto/request/UserSignInRequest.kt index f346d68..fa6fa11 100644 --- a/src/main/kotlin/org/meogo/domain/user/presentation/dto/request/UserSignInRequest.kt +++ b/src/main/kotlin/org/meogo/domain/user/presentation/dto/request/UserSignInRequest.kt @@ -2,5 +2,6 @@ package org.meogo.domain.user.presentation.dto.request data class UserSignInRequest( val accountId: String, - val password: String + val password: String, + val deviceToken: String ) diff --git a/src/main/kotlin/org/meogo/domain/user/service/UserSignInService.kt b/src/main/kotlin/org/meogo/domain/user/service/UserSignInService.kt index 832faec..1b41f7a 100644 --- a/src/main/kotlin/org/meogo/domain/user/service/UserSignInService.kt +++ b/src/main/kotlin/org/meogo/domain/user/service/UserSignInService.kt @@ -21,6 +21,11 @@ class UserSignInService( if (!passwordEncoder.matches(request.password, user.password)) throw PasswordMismatchException + userRepository.save( + user.updateDeviceToken( + request.deviceToken + ) + ) return jwtTokenProvider.getToken(user.accountId) } } diff --git a/src/main/kotlin/org/meogo/domain/user/service/UserSignUpService.kt b/src/main/kotlin/org/meogo/domain/user/service/UserSignUpService.kt index 033d84f..292df45 100644 --- a/src/main/kotlin/org/meogo/domain/user/service/UserSignUpService.kt +++ b/src/main/kotlin/org/meogo/domain/user/service/UserSignUpService.kt @@ -7,7 +7,6 @@ import org.meogo.domain.user.presentation.dto.request.UserSignUpRequest import org.meogo.global.jwt.JwtTokenProvider import org.meogo.global.jwt.dto.TokenResponse import org.meogo.global.s3.FileUtil -import org.meogo.global.s3.Path import org.springframework.beans.factory.annotation.Value import org.springframework.security.crypto.password.PasswordEncoder import org.springframework.stereotype.Service @@ -23,15 +22,13 @@ class UserSignUpService( ) { fun execute(request: UserSignUpRequest): TokenResponse { - val image = fileUtil.generateObjectUrl(defaultImage, Path.USER) - val user = User( name = request.name, accountId = request.accountId, password = passwordEncoder.encode(request.password), enrolledSchool = request.enrolledSchool?.toInt(), role = UserRole.USER, - profile = image + profile = defaultImage ) userRepository.save(user) diff --git a/src/main/kotlin/org/meogo/global/base/BaseUUIDEntity.kt b/src/main/kotlin/org/meogo/global/base/BaseUUIDEntity.kt index 3e63c9a..4a4d3ba 100644 --- a/src/main/kotlin/org/meogo/global/base/BaseUUIDEntity.kt +++ b/src/main/kotlin/org/meogo/global/base/BaseUUIDEntity.kt @@ -14,5 +14,5 @@ abstract class BaseUUIDEntity( columnDefinition = "BINARY(16)", nullable = false ) - val id: UUID? + val id: UUID? = null )