package com.test.musichouduan.entity;

import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import java.time.LocalDateTime;

/**
 * 评论实体类
 */
@Data
@Entity
@Table(name = "comment")
public class Comment {

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

    /**
     * 评论内容
     */
    @Column(nullable = false, length = 500)
    private String content;

    /**
     * 评论用户
     */
    @ManyToOne
    @JoinColumn(name = "user_id", nullable = false)
    private User user;

    /**
     * 评论目标ID
     */
    @Column(nullable = false)
    private Long targetId;

    /**
     * 评论目标类型：1-音乐，2-歌单，3-歌手
     */
    @Column(nullable = false)
    private Integer targetType;

    /**
     * 父评论ID
     */
    @Column
    private Long parentId;

    /**
     * 状态：0-禁用，1-正常
     */
    @Column
    private Integer status;

    /**
     * 创建时间
     */
    @CreationTimestamp
    @Column(nullable = false, updatable = false)
    private LocalDateTime createTime;

    /**
     * 更新时间
     */
    @UpdateTimestamp
    @Column(nullable = false)
    private LocalDateTime updateTime;
}
