package com.apobates.forum.member.entity;

import com.apobates.forum.event.elderly.ForumActionEnum;
import java.io.Serializable;
import java.time.LocalDateTime;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * 会员在线记录
 *
 * @author xiaofanku
 * @since 20200514
 */
@Entity
@Table(name = "apo_member_online")
public class MemberOnline implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(nullable = false, columnDefinition="CHAR(52) NOT NULL")
    private String id;
    /**
     * 会员ID
     */
    private long mid;
    /**
     * 会员的登录帐号
     */
    private String memberNames;
    /**
     * 会员昵称
     */
    private String memberNickname;
    /**
     * 最近的操作
     */
    @Basic
    @Enumerated(EnumType.STRING)
    private ForumActionEnum action;
    /**
     * 最近活跃日期
     */
    private LocalDateTime activeDateTime;

    //empty constructor for JPA instantiation
    public MemberOnline() {
    }
    
    public MemberOnline(String sessionId, long memberId, String memberNames, String memberNickname, ForumActionEnum action) {
        this.action = action;
        this.mid = memberId;
        this.memberNames = memberNames;
        this.memberNickname = memberNickname;
        this.activeDateTime = LocalDateTime.now();
        this.id = sessionId;
    }
    
    public long getMid() {
        return mid;
    }
    
    public String getMemberNickname() {
        return memberNickname;
    }
    
    public ForumActionEnum getAction() {
        return action;
    }
    
    public LocalDateTime getActiveDateTime() {
        return activeDateTime;
    }
    
    public void setMid(long mid) {
        this.mid = mid;
    }
    
    public void setMemberNickname(String memberNickname) {
        this.memberNickname = memberNickname;
    }
    
    public void setAction(ForumActionEnum action) {
        this.action = action;
    }
    
    public void setActiveDateTime(LocalDateTime activeDateTime) {
        this.activeDateTime = activeDateTime;
    }
    
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public String getMemberNames() {
        return memberNames;
    }
    
    public void setMemberNames(String memberNames) {
        this.memberNames = memberNames;
    }
    
}