package cn.reghao.tnb.search.esapp.blog.model.vo;

import cn.reghao.jutil.jdk.converter.DateTimeConverter;
import cn.reghao.tnb.search.esapp.blog.model.po.Article;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;

/**
 * @author reghao
 * @date 2023-04-13 17:17:37
 */
@NoArgsConstructor
@Setter
@Getter
public class AdminArticle {
    private int id;
    private String articleId;
    private String title;
    private String category;
    private List<String> tags;
    private String publishAt;
    private boolean published;
    private String editor;
    private int views;
    private String url;
    private String content;
    private int weight;

    public AdminArticle(Article article, int viewCount, String category, List<String> tags, String domain) {
        this.id = article.getId();
        this.articleId = article.getArticleId();
        this.title = article.getTitle();
        this.category = category;
        this.tags = tags;
        this.publishAt = DateTimeConverter.format(article.getUpdateTime());
        this.published = article.getPublished();
        this.editor = article.getEditor();
        this.views = viewCount;
        this.url = String.format("//%s/post/%s", domain, this.articleId);
        this.content = article.getContent();
        this.weight = article.getWeight();
    }
}
