package com.yaoyuan.jiscuss.entity;

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
import jakarta.persistence.Table;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;

import java.io.Serializable;
import java.util.Date;

@Data
@Entity
@Table(name = "discussion")
public class Discussion implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", unique = true)
    private Integer id;

    @NotBlank
    @Size(max = 200)
    @Column(name = "title")
    private String title;

    @Column(name = "content")
    private String content;

    @Column(name = "comments_count")
    private Integer commentsCount;

    @Column(name = "participants_count")
    private Integer participantsCount;

    @Column(name = "number_index")
    private Integer numberIndex;

    @Column(name = "start_time")
    private Date startTime;

    @Column(name = "start_user_id")
    private Integer startUserId;

    @Column(name = "start_post_id")
    private Integer startPostId;

    @Column(name = "last_time")
    private Date lastTime;

    @Column(name = "last_user_id")
    private Integer lastUserId;

    @Column(name = "last_post_id")
    private Integer lastPostId;

    @Column(name = "last_post_number")
    private Integer lastPostNumber;

    @Column(name = "is_approved")
    private Integer isApproved;

    @Column(name = "like_count")
    private Integer likeCount;

    @Column(name = "dislike_count")
    private Integer dislikeCount;

    /** IP is resolved server-side via IpUtils.getClientIp() — never trusted from X-Forwarded-For alone. */
    @Column(name = "ip_address")
    private String ipAddress;

    @Column(name = "create_id")
    private Integer createId;

    @Column(name = "create_time")
    private Date createTime;

    @Column(name = "view_count")
    private Integer viewCount;
}

