package com.goldenchart.entity;

import jakarta.persistence.*;
import lombok.*;

import java.time.LocalDateTime;

/**
 * 관심종목 (워치리스트).
 * 기존 crypto_favorites 와 별도로 GoldenChart 전용 관리.
 */
@Entity
@Table(name = "gc_watchlist",
    uniqueConstraints = @UniqueConstraint(name = "uk_watchlist_user_symbol",
        columnNames = {"user_id", "device_id", "symbol"}))
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
public class GcWatchlist {

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

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

    @Column(name = "device_id", length = 100)
    private String deviceId;

    @Column(name = "symbol", length = 50, nullable = false)
    private String symbol;

    @Column(name = "korean_name", length = 100)
    private String koreanName;

    @Column(name = "english_name", length = 100)
    private String englishName;

    @Column(name = "display_order")
    @Builder.Default
    private Integer displayOrder = 0;

    @Column(name = "created_at", nullable = false, updatable = false)
    private LocalDateTime createdAt;

    @PrePersist
    protected void onCreate() {
        createdAt = LocalDateTime.now();
    }
}
