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 lombok.Data;

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

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

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;

    @Column(name = "discussion_id")
    private Integer discussionId;

    @Column(name = "number")
    private Integer number;

    @Column(name = "time")
    private Date time;

    @Column(name = "user_id")
    private Integer userId;

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

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

    @Column(name = "parent_id")
    private Integer parentId;

    @Column(name = "edit_time")
    private Date editTime;

    @Column(name = "edit_user_id")
    private Integer editUserId;

    /** IP resolved server-side via IpUtils.getClientIp(). */
    @Column(name = "ip_address")
    private String ipAddress;

    /** Province/region derived from IP (e.g. "北京", "广东"). Stored on post creation. */
    @Column(name = "ip_region")
    private String ipRegion;

    /** Parsed browser name+version (e.g. "Chrome 120"). Derived from User-Agent on post creation. */
    @Column(name = "browser")
    private String browser;

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

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

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

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

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

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

