package com.goldenchart.entity; import jakarta.persistence.*; import lombok.*; import java.math.BigDecimal; import java.time.LocalDateTime; /** * 보유종목. */ @Entity @Table(name = "gc_holdings", uniqueConstraints = @UniqueConstraint(name = "uk_holdings_user_symbol", columnNames = {"user_id", "device_id", "symbol"})) @Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder public class GcHoldings { @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 = "avg_price", precision = 30, scale = 8) private BigDecimal avgPrice; /** 보유 수량 */ @Column(name = "quantity", precision = 30, scale = 8) private BigDecimal quantity; @Column(name = "display_order") @Builder.Default private Integer displayOrder = 0; @Column(name = "created_at", nullable = false, updatable = false) private LocalDateTime createdAt; @Column(name = "updated_at") private LocalDateTime updatedAt; @PrePersist protected void onCreate() { createdAt = LocalDateTime.now(); updatedAt = LocalDateTime.now(); } @PreUpdate protected void onUpdate() { updatedAt = LocalDateTime.now(); } }