Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,17 +1,7 @@
package com.gotchai.domain.user.adapter.`in`

import com.gotchai.domain.user.entity.Profile
import com.gotchai.domain.user.exception.ProfileNotFoundException
import com.gotchai.domain.user.port.`in`.ProfileQueryUseCase
import com.gotchai.domain.user.port.out.ProfileQueryPort
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional

@Service
class ProfileQueryService(
private val profileQueryPort: ProfileQueryPort
) : ProfileQueryUseCase {
@Transactional(readOnly = true)
override fun getProfileByUserId(userId: Long): Profile? =
profileQueryPort.getProfileByUserId(userId) ?: throw ProfileNotFoundException()
}
class ProfileQueryService : ProfileQueryUseCase
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
package com.gotchai.domain.user.port.`in`

import com.gotchai.domain.user.entity.Profile

interface ProfileQueryUseCase {
fun getProfileByUserId(userId: Long): Profile?
}
interface ProfileQueryUseCase
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ProfileQueryAdapter(
@ReadOnlyTransactional
override fun getProfileByUserId(userId: Long): Profile? =
profileRepository
.findByUserId(userId)
.findByUserIdAndDeletedAtIsNull(userId)
?.toProfile()

@ReadOnlyTransactional
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import com.gotchai.domain.user.port.out.UserQueryPort
import com.gotchai.storage.rdb.global.annotation.Adapter
import com.gotchai.storage.rdb.global.annotation.ReadOnlyTransactional
import com.gotchai.storage.rdb.user.repository.UserJpaRepository
import org.springframework.data.repository.findByIdOrNull

@Adapter
class UserQueryAdapter(
Expand All @@ -14,12 +13,12 @@ class UserQueryAdapter(
@ReadOnlyTransactional
override fun getUserById(id: Long): User? =
userRepository
.findByIdOrNull(id)
.findByIdAndDeletedAtIsNull(id)
?.toUser()

@ReadOnlyTransactional
override fun getUserByEmail(email: String): User? =
userRepository
.findByEmail(email)
.findByEmailAndDeletedAtIsNull(email)
?.toUser()
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,6 @@ import org.springframework.data.jpa.repository.JpaRepository

interface ProfileJpaRepository : JpaRepository<ProfileEntity, Long> {
fun findByUserId(userId: Long): ProfileEntity?

fun findByUserIdAndDeletedAtIsNull(userId: Long): ProfileEntity?
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ import com.gotchai.storage.rdb.user.entity.UserEntity
import org.springframework.data.jpa.repository.JpaRepository

interface UserJpaRepository : JpaRepository<UserEntity, Long> {
fun findByEmail(email: String): UserEntity?
fun findByIdAndDeletedAtIsNull(id: Long): UserEntity?

fun findByEmailAndDeletedAtIsNull(email: String): UserEntity?
}
Loading