Skip to content

Commit

Permalink
Merge pull request #29 from Preta3418/main
Browse files Browse the repository at this point in the history
Refactoring: member 측 매핑 제거
  • Loading branch information
Preta3418 authored Nov 5, 2024
2 parents cc1716d + ff1a84d commit eedc2ce
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,6 @@ data class Member(
@OneToOne(mappedBy = "member", cascade = [CascadeType.ALL], fetch = FetchType.LAZY)
var profile: Profile? = null,

@OneToMany(mappedBy = "sender", cascade = [CascadeType.ALL], orphanRemoval = true)
val sentScoutRequests: MutableList<ScoutRequest> = mutableListOf(),

@OneToMany(mappedBy = "receiver", cascade = [CascadeType.ALL], orphanRemoval = true)
val receivedScoutRequests: MutableList<ScoutRequest> = mutableListOf(),

@Column(nullable = false, unique = true)
var username: String = "",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ import org.springframework.data.jpa.repository.JpaRepository
import org.tenten.bittakotlin.scout.entity.ScoutRequest

interface ScoutRequestRepository : JpaRepository<ScoutRequest, Long> {
fun findBySender_IdOrderById(senderId: Long, pageable: Pageable): Page<ScoutRequest>
fun findByReceiver_IdOrderById(receiverId: Long, pageable: Pageable): Page<ScoutRequest>
fun findBySenderIdOrderById(senderId: Long, pageable: Pageable): Page<ScoutRequest>
fun findByReceiverIdOrderById(receiverId: Long, pageable: Pageable): Page<ScoutRequest>
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ScoutRequestService(
fun getSentScoutRequests(senderId: Long, pageable: Pageable): Page<ScoutDTO> {
logger.info("Fetching sent scout requests for senderId=$senderId")

val sentRequests = scoutRequestRepository.findBySender_IdOrderById(senderId, pageable)
val sentRequests = scoutRequestRepository.findBySenderIdOrderById(senderId, pageable)
.map { request -> entityToDto(request) }

logger.info("Retrieved ${sentRequests.totalElements} sent scout requests for senderId=$senderId")
Expand All @@ -50,7 +50,7 @@ class ScoutRequestService(
fun getReceivedScoutRequests(receiverId: Long, pageable: Pageable): Page<ScoutDTO> {
logger.info("Fetching received scout requests for receiverId=$receiverId")

val receivedRequests = scoutRequestRepository.findByReceiver_IdOrderById(receiverId, pageable)
val receivedRequests = scoutRequestRepository.findByReceiverIdOrderById(receiverId, pageable)
.map { request -> entityToDto(request) }

logger.info("Retrieved ${receivedRequests.totalElements} received scout requests for receiverId=$receiverId")
Expand Down

0 comments on commit eedc2ce

Please sign in to comment.