package com.apobates.forum.thrones.vo;

import com.apobates.forum.core.entity.BoardStats;
import com.apobates.forum.core.entity.proxy.TopicReplica;
import com.apobates.forum.utils.DateTimeUtils;
import java.io.Serializable;

/**
 * 版块统计(推送信息)
 *
 * @author xiaofanku
 * @since 20200525
 */
public final class ForumBoardStatsRecord implements Serializable {
    private static final long serialVersionUID = 1278961971387410186L;
    //版块ID
    private final long board;
    //版块的回复数
    private final long postses;
    //版块的主题数
    private final long topices;
    //今日主题数
    private final long todayTopics;
    //版块最近的话题信息
    //最近话题主题
    private final String recentTitle;
    //最近话题连接
    private final String recentLink;
    //话题发布日期
    private final String recentDate;
    //话题的作者/会员ID
    private final long recentAuthor;
    //话题的作者/会员昵称/Member.nickname
    private final String recentAuthorNames;
    
    public ForumBoardStatsRecord(BoardStats boardStats) {
        super();
        this.postses = boardStats.getPostses();
        this.topices = boardStats.getTopices();
        this.todayTopics = boardStats.getTodayTopices();
        this.board = boardStats.getBoardId();
        
        if (boardStats.getRecentTopicId() > 0) {
            this.recentLink = String.format("/topic/%s.xhtml", TopicReplica.generateConnectString(boardStats.getRecentTopicId(), boardStats.getBoardId(), boardStats.getVolumesId()));
            this.recentTitle = boardStats.getRecentTopicTitle();
            this.recentAuthor = boardStats.getRecentTopicMemberId();
            this.recentAuthorNames = boardStats.getRecentTopicMemberNickname();
            this.recentDate = DateTimeUtils.formatClock(boardStats.getUpdateDate());
        } else {
            this.recentLink = "#";
            this.recentTitle = "";
            this.recentDate = "-";
            this.recentAuthor = 0;
            this.recentAuthorNames = "*";
        }
    }
    
    public long getPostses() {
        return postses;
    }
    
    public long getTopices() {
        return topices;
    }
    
    public String getRecentTitle() {
        return recentTitle;
    }
    
    public String getRecentDate() {
        return recentDate;
    }
    
    public long getTodayTopics() {
        return todayTopics;
    }
    
    public String getRecentLink() {
        return recentLink;
    }
    
    public long getRecentAuthor() {
        return recentAuthor;
    }
    
    public String getRecentAuthorNames() {
        return recentAuthorNames;
    }
    
    public long getBoard() {
        return board;
    }
}