File tree Expand file tree Collapse file tree 6 files changed +17
-0
lines changed
domain/src/main/kotlin/com/gotchai/domain
storage/rdb/src/main/kotlin/com/gotchai/storage/rdb/user/adapter/out Expand file tree Collapse file tree 6 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -44,6 +44,7 @@ class AuthCommandService(
4444 @Value(" \$ {jwt.refresh-token-expiration}" )
4545 private val refreshTokenExpiration : Duration
4646) : AuthCommandUseCase {
47+ @Transactional
4748 override fun login (
4849 deviceId : String? ,
4950 command : LoginCommand
Original file line number Diff line number Diff line change @@ -7,16 +7,19 @@ import com.gotchai.domain.badge.port.`in`.BadgeQueryUseCase
77import com.gotchai.domain.badge.port.out.BadgeQueryPort
88import com.gotchai.domain.badge.port.out.UserBadgeQueryPort
99import org.springframework.stereotype.Service
10+ import org.springframework.transaction.annotation.Transactional
1011
1112@Service
1213class BadgeQueryService (
1314 private val badgeQueryPort : BadgeQueryPort ,
1415 private val userBadgeQueryPort : UserBadgeQueryPort
1516) : BadgeQueryUseCase {
17+ @Transactional(readOnly = true )
1618 override fun getBadgeById (badgeId : Long ): Badge =
1719 badgeQueryPort.getBadgeById(badgeId)
1820 ? : throw BadgeNotFoundException ()
1921
22+ @Transactional(readOnly = true )
2023 override fun getMyBadges (userId : Long ): List <Badge > {
2124 val userBadges = userBadgeQueryPort.getUserBadgesByUserId(userId)
2225 val badges =
@@ -26,6 +29,7 @@ class BadgeQueryService(
2629 return badges
2730 }
2831
32+ @Transactional(readOnly = true )
2933 override fun getBadgeByExamIdAndTier (
3034 examId : Long ,
3135 tier : Tier
Original file line number Diff line number Diff line change @@ -7,24 +7,29 @@ import com.gotchai.domain.exam.port.out.ExamHistoryQueryPort
77import com.gotchai.domain.exam.port.out.ExamQueryPort
88import com.gotchai.domain.quiz.port.out.QuizQueryPort
99import org.springframework.stereotype.Service
10+ import org.springframework.transaction.annotation.Transactional
1011
1112@Service
1213class ExamQueryService (
1314 private val examQueryPort : ExamQueryPort ,
1415 private val examHistoryQueryPort : ExamHistoryQueryPort ,
1516 private val quizQueryPort : QuizQueryPort
1617) : ExamQueryUseCase {
18+ @Transactional(readOnly = true )
1719 override fun getExamById (examId : Long ): Exam = examQueryPort.getExamById(examId) ? : throw ExamNotFoundException ()
1820
21+ @Transactional(readOnly = true )
1922 override fun getExams (): List <Exam > = examQueryPort.getExams()
2023
24+ @Transactional(readOnly = true )
2125 override fun getExamsByUserId (userId : Long ): List <Exam > {
2226 val examHistories = examHistoryQueryPort.getExamHistoriesByUserIdAndSolvedTrue(userId)
2327 val exams = examQueryPort.getExamsByInIn(examHistories.map { it.id })
2428
2529 return exams
2630 }
2731
32+ @Transactional(readOnly = true )
2833 override fun getExamParticipantCountById (examId : Long ): Int =
2934 examHistoryQueryPort
3035 .getExamHistoriesByExamIdAndSolvedTrue(examId)
Original file line number Diff line number Diff line change @@ -7,12 +7,14 @@ import com.gotchai.domain.quiz.port.`in`.QuizQueryUseCase
77import com.gotchai.domain.quiz.port.out.QuizPickQueryPort
88import com.gotchai.domain.quiz.port.out.QuizQueryPort
99import org.springframework.stereotype.Service
10+ import org.springframework.transaction.annotation.Transactional
1011
1112@Service
1213class QuizQueryService (
1314 private val quizQueryPort : QuizQueryPort ,
1415 private val quizPickQueryPort : QuizPickQueryPort
1516) : QuizQueryUseCase {
17+ @Transactional(readOnly = true )
1618 override fun getQuizById (quizId : Long ): GetQuizResult {
1719 val quiz = quizQueryPort.getQuizById(quizId) ? : throw QuizNotFoundException ()
1820 val quizPicks = quizPickQueryPort.getQuizPicksByQuizId(quiz.id)
Original file line number Diff line number Diff line change @@ -5,11 +5,13 @@ import com.gotchai.domain.user.exception.ProfileNotFoundException
55import com.gotchai.domain.user.port.`in`.ProfileQueryUseCase
66import com.gotchai.domain.user.port.out.ProfileQueryPort
77import org.springframework.stereotype.Service
8+ import org.springframework.transaction.annotation.Transactional
89
910@Service
1011class ProfileQueryService (
1112 private val profileQueryPort : ProfileQueryPort
1213) : ProfileQueryUseCase {
14+ @Transactional(readOnly = true )
1315 override fun getProfileByUserId (userId : Long ): Profile ? =
1416 profileQueryPort.getProfileByUserId(userId) ? : throw ProfileNotFoundException ()
1517}
Original file line number Diff line number Diff line change @@ -3,18 +3,21 @@ package com.gotchai.storage.rdb.user.adapter.out
33import com.gotchai.domain.user.entity.User
44import com.gotchai.domain.user.port.out.UserQueryPort
55import com.gotchai.storage.rdb.global.annotation.Adapter
6+ import com.gotchai.storage.rdb.global.annotation.ReadOnlyTransactional
67import com.gotchai.storage.rdb.user.repository.UserJpaRepository
78import org.springframework.data.repository.findByIdOrNull
89
910@Adapter
1011class UserQueryAdapter (
1112 private val userRepository : UserJpaRepository
1213) : UserQueryPort {
14+ @ReadOnlyTransactional
1315 override fun getUserById (id : Long ): User ? =
1416 userRepository
1517 .findByIdOrNull(id)
1618 ?.toUser()
1719
20+ @ReadOnlyTransactional
1821 override fun getUserByEmail (email : String ): User ? =
1922 userRepository
2023 .findByEmail(email)
You can’t perform that action at this time.
0 commit comments