feat(recommend): 콘텐츠 조회 이력 서비스를 추가한다

This commit is contained in:
2026-05-31 18:19:28 +09:00
parent 2ef8e8e489
commit 43179de810
2 changed files with 92 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
package kr.co.vividnext.sodalive.v2.recommend.application
import kr.co.vividnext.sodalive.v2.recommend.port.out.CreatorContentViewHistoryPort
import kr.co.vividnext.sodalive.v2.recommend.port.out.CreatorContentViewHistoryRecord
import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Propagation
import org.springframework.transaction.annotation.Transactional
import java.time.LocalDateTime
@Service
class CreatorContentViewHistoryService(
private val port: CreatorContentViewHistoryPort
) {
@Transactional(propagation = Propagation.REQUIRES_NEW)
fun recordView(memberId: Long?, contentId: Long, viewedAt: LocalDateTime = LocalDateTime.now()) {
if (memberId == null) return
val genreId = port.findGenreIdByContentId(contentId) ?: return
port.save(
CreatorContentViewHistoryRecord(
memberId = memberId,
contentId = contentId,
genreId = genreId,
viewedAt = viewedAt
)
)
}
}