65 lines
1.9 KiB
Java
65 lines
1.9 KiB
Java
package com.goldenchart.entity;
|
|
|
|
import jakarta.persistence.*;
|
|
import lombok.*;
|
|
import org.hibernate.annotations.JdbcTypeCode;
|
|
import org.hibernate.type.SqlTypes;
|
|
|
|
import java.time.LocalDateTime;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
|
|
/**
|
|
* 사용자 차트 워크스페이스.
|
|
* 멀티차트 레이아웃 및 슬롯 집합을 관리한다.
|
|
*/
|
|
@Entity
|
|
@Table(name = "gc_chart_workspace")
|
|
@Getter @Setter @NoArgsConstructor @AllArgsConstructor @Builder
|
|
public class GcChartWorkspace {
|
|
|
|
@Id
|
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
|
private Long id;
|
|
|
|
/** 소유 사용자 ID (users.id 논리 참조) */
|
|
@Column(name = "user_id")
|
|
private Long userId;
|
|
|
|
/** 비회원 기기 식별자 */
|
|
@Column(name = "device_id", length = 100)
|
|
private String deviceId;
|
|
|
|
/** 현재 적용된 레이아웃 ID (frontend layoutTypes.ts 의 LayoutDef.id 와 일치: "1","2v","2h",...) */
|
|
@Column(name = "layout_id", length = 20, nullable = false)
|
|
private String layoutId;
|
|
|
|
/** 차트 슬롯 설정 목록 (1:N) */
|
|
@OneToMany(mappedBy = "workspace", cascade = CascadeType.ALL, orphanRemoval = true)
|
|
@OrderBy("slotIndex ASC")
|
|
@Builder.Default
|
|
private List<GcChartSlot> slots = new ArrayList<>();
|
|
|
|
/** 차트 간 동기화 옵션 JSON {"symbol":true,"timeframe":false,"crosshair":true} */
|
|
@Column(name = "sync_options_json", columnDefinition = "JSON")
|
|
@JdbcTypeCode(SqlTypes.JSON)
|
|
private String syncOptionsJson;
|
|
|
|
@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();
|
|
}
|
|
}
|