Skip to content

Commit

Permalink
fix: exclude content column in ReadAllDiaryPort
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyLightQP committed Feb 6, 2025
1 parent bff8933 commit 3051da3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
package me.daegyeo.maru.diary.adaptor.out.persistence

import me.daegyeo.maru.diary.application.domain.Diary
import me.daegyeo.maru.diary.application.persistence.DiaryEntity
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import java.util.UUID

interface DiaryRepository : JpaRepository<DiaryEntity, Long> {
fun findByUserId(userId: UUID): List<DiaryEntity>
@Query(
"""SELECT new me.daegyeo.maru.diary.application.domain.Diary(d.diaryId, d.title, '', d.createdAt, d.updatedAt)
FROM DiaryEntity d
WHERE d.userId = :userId""",
)
fun findByUserIdExcludingContent(userId: UUID): List<Diary>
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package me.daegyeo.maru.diary.adaptor.out.persistence

import me.daegyeo.maru.diary.adaptor.out.mapper.DiaryMapper
import me.daegyeo.maru.diary.application.domain.Diary
import me.daegyeo.maru.diary.application.port.out.ReadAllDiaryPort
import org.springframework.stereotype.Component
Expand All @@ -9,10 +8,9 @@ import java.util.UUID
@Component
class ReadAllDiaryPersistenceAdapter(
private val diaryRepository: DiaryRepository,
private val diaryMapper: DiaryMapper,
) : ReadAllDiaryPort {
override fun readAllDiaryByUserId(userId: UUID): List<Diary> {
val diaries = diaryRepository.findByUserId(userId)
return diaries.map { diaryMapper.toDomain(it) }
val diaries = diaryRepository.findByUserIdExcludingContent(userId)
return diaries
}
}

0 comments on commit 3051da3

Please sign in to comment.