package kr.lunaticbum.back.lun.service

import kr.lunaticbum.back.lun.model.PostHistory
import kr.lunaticbum.back.lun.repository.PostHistoryRepository
import org.springframework.stereotype.Service
import reactor.core.publisher.Flux
import reactor.core.publisher.Mono


// 3. PostHistory를 위한 Service 클래스
@Service
class PostHistoryManager(private val repository: PostHistoryRepository) {
    fun save(postHistory: PostHistory): Mono<PostHistory> {
        return repository.save(postHistory)
    }

    // [추가] postId로 모든 히스토리를 조회하는 함수
    fun findByPostId(postId: String): Flux<PostHistory> {
        return repository.findByPostIdOrderByArchivedAtDesc(postId)
    }
}