feat(recommend): 콘텐츠 조회 이력 서비스를 추가한다
This commit is contained in:
@@ -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
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user