package cn.reghao.tnb.search.app.comment.service;

import cn.reghao.jutil.jdk.web.db.PageList;
import cn.reghao.jutil.jdk.string.SnowFlake;
import cn.reghao.tnb.search.app.comment.db.mongo.RichTextMongo;
import cn.reghao.tnb.search.app.comment.model.po.RichText;
import cn.reghao.tnb.search.app.comment.model.vo.NewsPost;
import org.springframework.stereotype.Service;

/**
 * @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);
    }
}
