package com.apobates.forum.core.entity;

import com.apobates.forum.event.elderly.ActionEventCulpritor;
import com.apobates.forum.event.elderly.ForumActionEnum;
import java.time.LocalDateTime;
import javax.persistence.DiscriminatorValue;
import javax.persistence.Entity;

/**
 * 版块的操作集合
 * 
 * @author xiaofanku
 * @since 20200514
 */
@Entity
@DiscriminatorValue("B")
public class BoardActionCollection extends ActionEventDescriptor{
    private static final long serialVersionUID = 1L;
    //动作关联的版块ID
    protected long boardId;
    //动作关联的版块名称
    protected String boardTitle;
    
    //empty constructor for JPA instantiation
    public BoardActionCollection() {
        super();
    }
    /**
     * 版块操作
     * @param memberNames 动作的操作会员昵称
     * @param memberId 动作的操作会员ID
     * @param action 动作
     * @param boardTitle 动作关联的版块名称
     * @param boardId 动作关联的版块ID
     * @param ipAddr 操作会员使用的ip
     * @param token 操作绑定的token
     * @param rodeMember 积分计算时的受益会员ID
     */
    public BoardActionCollection(
            String memberNames, 
            long memberId, 
            ForumActionEnum action, 
            String boardTitle, 
            long boardId, 
            String ipAddr, 
            String token, 
            long rodeMember) {
        super(memberNames, memberId, action, LocalDateTime.now(), ipAddr, token, rodeMember);
        this.boardTitle = boardTitle;
        this.boardId = boardId;
    }
    /**
     * 版块操作
     * @param action 动作
     * @param boardTitle 动作关联的版块名称
     * @param boardId 动作关联的版块ID
     * @param culpritor 
     * @param rodeMember 积分计算时的受益会员ID
     */
    public BoardActionCollection(
            ForumActionEnum action, 
            String boardTitle, 
            long boardId, 
            ActionEventCulpritor culpritor, 
            long rodeMember) {
        super(culpritor.getMemberNickname(), culpritor.getMemberId(), action, LocalDateTime.now(), culpritor.getIpAddr(), culpritor.getToken(), rodeMember);
        this.boardTitle = boardTitle;
        this.boardId = boardId;
    }
    
    public long getBoardId() {
        return boardId;
    }
    
    public String getBoardTitle() {
        return boardTitle;
    }
    
    public void setBoardId(long boardId) {
        this.boardId = boardId;
    }
    
    public void setBoardTitle(String boardTitle) {
        this.boardTitle = boardTitle;
    }
    
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = super.hashCode();
        result = prime * result + (int) (boardId ^ (boardId >>> 32));
        return result;
    }
    
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (!super.equals(obj)) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        BoardActionCollection other = (BoardActionCollection) obj;
        return boardId == other.boardId;
    }
}