package com.smyhub.store.mengyastorebackendjava.entity;

import com.smyhub.store.mengyastorebackendjava.entity.converter.StringListConverter;
import jakarta.persistence.*;
import lombok.Getter;
import lombok.Setter;

import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;

@Entity
@Table(name = "orders")
@Getter
@Setter
public class Order {

    @Id
    @Column(length = 36)
    private String id;

    @Column(name = "product_id", length = 36, nullable = false)
    private String productId;

    @Column(name = "product_name", length = 255, nullable = false)
    private String productName;

    @Column(name = "user_account", length = 255)
    private String userAccount;

    @Column(name = "user_name", length = 255)
    private String userName;

    @Column(nullable = false, columnDefinition = "int default 1")
    private int quantity;

    @Convert(converter = StringListConverter.class)
    @Column(name = "delivered_codes", columnDefinition = "json")
    private List<String> deliveredCodes = new ArrayList<>();

    @Column(length = 20, nullable = false, columnDefinition = "varchar(20) default 'pending'")
    private String status = "pending";

    @Column(name = "delivery_mode", length = 20, columnDefinition = "varchar(20) default 'auto'")
    private String deliveryMode = "auto";

    @Column(columnDefinition = "text")
    private String note;

    @Column(name = "contact_phone", length = 50)
    private String contactPhone;

    @Column(name = "contact_email", length = 255)
    private String contactEmail;

    @Column(name = "notify_email", length = 255)
    private String notifyEmail;

    @Column(name = "created_at")
    private LocalDateTime createdAt;
}
