package com.apobates.forum.core.impl.service;

import com.apobates.forum.core.dao.TopicStatsDao;
import com.apobates.forum.core.entity.TopicStats;
import com.apobates.forum.core.service.TopicStatsService;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 *
 * @author xiaofanku
 * @since 20200513
 */
@Service
public class TopicStatsServiceImpl implements TopicStatsService{
    @Autowired
    private TopicStatsDao topicStatsDao;
    
    @Override
    public Stream<TopicStats> getByTopicIdList(List<Long> topicIdList) {
        return topicStatsDao.findAllByTopicId(topicIdList);  //DAO会进行检查
    }
    
    @Override
    public Optional<TopicStats> getByTopic(long topicId) {
        return topicStatsDao.findOneByTopic(topicId);
    }
}