package com.apobates.forum.thrones.vo;

import com.apobates.forum.core.entity.Board;
import com.apobates.forum.core.entity.proxy.BoardActionCollectionReplica;
import com.apobates.forum.core.entity.proxy.BoardReplica;
import com.apobates.forum.utils.DateTimeUtils;
import java.io.Serializable;
import java.util.Objects;

/**
 * 会员中心的版块操作记录(收藏的版块)
 * @author xiaofanku
 * @since 20200621
 */
public final class ForumBoardActionRecord implements Serializable{
    private static final long serialVersionUID = 1L;
    private final String title;
    private final String link;
    private final String action;
    private final String actionTitle;
    private final String actionDate;
    private final String description;
    private final long id;
    
    public ForumBoardActionRecord(BoardActionCollectionReplica boardAction) {
        Objects.requireNonNull(boardAction);
        Board board = boardAction.getBoard();
        if (null != board) {
            this.link = String.format("/board/%s.xhtml", BoardReplica.generateConnectString(board.getId(), board.getVolumesId()));
            this.description = board.getDescription();
        } else {
            this.link = "javascript:;";
            this.description = "";
        }
        this.title = boardAction.getBoardTitle();
        this.action = boardAction.getAction().name().toLowerCase().substring(6);
        this.actionTitle = boardAction.getAction().getTitle();
        this.actionDate = DateTimeUtils.formatClock(boardAction.getEntryDateTime());
        this.id = boardAction.getBoardId();
    }
    
    public String getTitle() {
        return title;
    }
    
    public String getLink() {
        return link;
    }
    
    public String getAction() {
        return action;
    }
    
    public String getActionTitle() {
        return actionTitle;
    }
    
    public String getActionDate() {
        return actionDate;
    }
    
    public String getDescription() {
        return description;
    }
    
    public long getId() {
        return id;
    }
}