Skip to content

Commit 2fbedd8

Browse files
authored
Release 0.0.2
2 parents f917f12 + 039e3c2 commit 2fbedd8

File tree

6 files changed

+10
-21
lines changed

6 files changed

+10
-21
lines changed
Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,7 @@
11
package com.gotchai.domain.user.adapter.`in`
22

3-
import com.gotchai.domain.user.entity.Profile
4-
import com.gotchai.domain.user.exception.ProfileNotFoundException
53
import com.gotchai.domain.user.port.`in`.ProfileQueryUseCase
6-
import com.gotchai.domain.user.port.out.ProfileQueryPort
74
import 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
Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
11
package 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

storage/rdb/src/main/kotlin/com/gotchai/storage/rdb/user/adapter/out/ProfileQueryAdapter.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

storage/rdb/src/main/kotlin/com/gotchai/storage/rdb/user/adapter/out/UserQueryAdapter.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import com.gotchai.domain.user.port.out.UserQueryPort
55
import com.gotchai.storage.rdb.global.annotation.Adapter
66
import com.gotchai.storage.rdb.global.annotation.ReadOnlyTransactional
77
import com.gotchai.storage.rdb.user.repository.UserJpaRepository
8-
import org.springframework.data.repository.findByIdOrNull
98

109
@Adapter
1110
class 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
}

storage/rdb/src/main/kotlin/com/gotchai/storage/rdb/user/repository/ProfileJpaRepository.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ import org.springframework.data.jpa.repository.JpaRepository
55

66
interface ProfileJpaRepository : JpaRepository<ProfileEntity, Long> {
77
fun findByUserId(userId: Long): ProfileEntity?
8+
9+
fun findByUserIdAndDeletedAtIsNull(userId: Long): ProfileEntity?
810
}

storage/rdb/src/main/kotlin/com/gotchai/storage/rdb/user/repository/UserJpaRepository.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ import com.gotchai.storage.rdb.user.entity.UserEntity
44
import org.springframework.data.jpa.repository.JpaRepository
55

66
interface UserJpaRepository : JpaRepository<UserEntity, Long> {
7-
fun findByEmail(email: String): UserEntity?
7+
fun findByIdAndDeletedAtIsNull(id: Long): UserEntity?
8+
9+
fun findByEmailAndDeletedAtIsNull(email: String): UserEntity?
810
}

0 commit comments

Comments
 (0)