package com.apobates.forum.thrones.vo;

import com.apobates.forum.core.entity.Topic;
import com.apobates.forum.core.entity.proxy.TopicActionCollectionReplica;
import com.apobates.forum.core.entity.proxy.TopicReplica;
import com.apobates.forum.utils.DateTimeUtils;
import java.io.Serializable;
import java.util.Objects;

/**
 * 会员中心的会员操作历史(收藏|点赞的话题)
 * @author xiaofanku
 * @since 20200517
 */
public final class ForumTopicActionRecord 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 long id;
    
    public ForumTopicActionRecord(TopicActionCollectionReplica topicAction) {
        Objects.requireNonNull(topicAction);
        Topic topic = topicAction.getTopic();
        if (null != topic) {
            this.link = String.format("/topic/%s.xhtml", TopicReplica.generateConnectString(topic.getId(), topic.getBoardId(), topic.getVolumesId()));
        } else {
            this.link = "javascript:;";
        }
        this.title = topicAction.getTopicTitle();
        this.action = topicAction.getAction().name().toLowerCase().substring(6);
        this.actionTitle = topicAction.getAction().getTitle();
        this.actionDate = DateTimeUtils.formatClock(topicAction.getEntryDateTime());
        this.id = topicAction.getTopicId();
    }
    
    public String getTitle() {
        return title;
    }
    
    public String getLink() {
        return link;
    }
    
    public String getAction() {
        return action;
    }
    
    public String getActionDate() {
        return actionDate;
    }
    
    public long getId() {
        return id;
    }
    
    public String getActionTitle() {
        return actionTitle;
    }
}