package cn.reghao.tnb.content.app.data.service;

import cn.reghao.jutil.jdk.db.PageList;
import cn.reghao.jutil.tool.id.SnowFlake;
import cn.reghao.tnb.content.app.data.db.mongo.RichTextMongo;
import cn.reghao.tnb.content.app.data.model.vo.NewsPost;
import cn.reghao.tnb.content.app.data.model.po.RichText;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author reghao
 * @date 2025-07-29 14:10:11
 */
@Service
public class NewsPostService {
    private final RichTextMongo richTextMongo;
    private final SnowFlake idGenerator;

    public NewsPostService(RichTextMongo richTextMongo) {
        this.richTextMongo = richTextMongo;
        this.idGenerator = new SnowFlake(1, 1);
    }

    public void add() {
    }

    public PageList<NewsPost> getByPage(int pn) {
        PageList<NewsPost> pageList = richTextMongo.findNewsPostByPage(pn);
        return pageList;
    }

    public NewsPost getById(long newsId) {
        RichText richText = richTextMongo.findByContentId(newsId);
        return new NewsPost(richText);
    }
}
