File tree Expand file tree Collapse file tree 6 files changed +10
-21
lines changed
domain/src/main/kotlin/com/gotchai/domain/user
storage/rdb/src/main/kotlin/com/gotchai/storage/rdb/user Expand file tree Collapse file tree 6 files changed +10
-21
lines changed Original file line number Diff line number Diff line change 11package com.gotchai.domain.user.adapter.`in`
22
3- import com.gotchai.domain.user.entity.Profile
4- import com.gotchai.domain.user.exception.ProfileNotFoundException
53import com.gotchai.domain.user.port.`in`.ProfileQueryUseCase
6- import com.gotchai.domain.user.port.out.ProfileQueryPort
74import org.springframework.stereotype.Service
8- import org.springframework.transaction.annotation.Transactional
95
106@Service
11- class ProfileQueryService (
12- private val profileQueryPort : ProfileQueryPort
13- ) : ProfileQueryUseCase {
14- @Transactional(readOnly = true )
15- override fun getProfileByUserId (userId : Long ): Profile ? =
16- profileQueryPort.getProfileByUserId(userId) ? : throw ProfileNotFoundException ()
17- }
7+ class ProfileQueryService : ProfileQueryUseCase
Original file line number Diff line number Diff line change 11package com.gotchai.domain.user.port.`in`
22
3- import com.gotchai.domain.user.entity.Profile
4-
5- interface ProfileQueryUseCase {
6- fun getProfileByUserId (userId : Long ): Profile ?
7- }
3+ interface ProfileQueryUseCase
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ class ProfileQueryAdapter(
1313 @ReadOnlyTransactional
1414 override fun getProfileByUserId (userId : Long ): Profile ? =
1515 profileRepository
16- .findByUserId (userId)
16+ .findByUserIdAndDeletedAtIsNull (userId)
1717 ?.toProfile()
1818
1919 @ReadOnlyTransactional
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ import com.gotchai.domain.user.port.out.UserQueryPort
55import com.gotchai.storage.rdb.global.annotation.Adapter
66import com.gotchai.storage.rdb.global.annotation.ReadOnlyTransactional
77import com.gotchai.storage.rdb.user.repository.UserJpaRepository
8- import org.springframework.data.repository.findByIdOrNull
98
109@Adapter
1110class UserQueryAdapter (
@@ -14,12 +13,12 @@ class UserQueryAdapter(
1413 @ReadOnlyTransactional
1514 override fun getUserById (id : Long ): User ? =
1615 userRepository
17- .findByIdOrNull (id)
16+ .findByIdAndDeletedAtIsNull (id)
1817 ?.toUser()
1918
2019 @ReadOnlyTransactional
2120 override fun getUserByEmail (email : String ): User ? =
2221 userRepository
23- .findByEmail (email)
22+ .findByEmailAndDeletedAtIsNull (email)
2423 ?.toUser()
2524}
Original file line number Diff line number Diff line change @@ -5,4 +5,6 @@ import org.springframework.data.jpa.repository.JpaRepository
55
66interface ProfileJpaRepository : JpaRepository <ProfileEntity , Long > {
77 fun findByUserId (userId : Long ): ProfileEntity ?
8+
9+ fun findByUserIdAndDeletedAtIsNull (userId : Long ): ProfileEntity ?
810}
Original file line number Diff line number Diff line change @@ -4,5 +4,7 @@ import com.gotchai.storage.rdb.user.entity.UserEntity
44import org.springframework.data.jpa.repository.JpaRepository
55
66interface UserJpaRepository : JpaRepository <UserEntity , Long > {
7- fun findByEmail (email : String ): UserEntity ?
7+ fun findByIdAndDeletedAtIsNull (id : Long ): UserEntity ?
8+
9+ fun findByEmailAndDeletedAtIsNull (email : String ): UserEntity ?
810}
You can’t perform that action at this time.
0 commit comments