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 = "products")
@Getter
@Setter
public class Product {

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

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

    @Column(nullable = false, columnDefinition = "double default 0")
    private double price;

    @Column(columnDefinition = "double default 0")
    private double discountPrice;

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

    @Column(length = 500)
    private String coverUrl;

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

    @Column(length = 500, columnDefinition = "varchar(500) default ''")
    private String verificationUrl;

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

    @Column(columnDefinition = "tinyint(1) default 1")
    private boolean active = true;

    @Column(columnDefinition = "tinyint(1) default 0")
    private boolean requireLogin;

    @Column(columnDefinition = "int default 0")
    private int maxPerAccount;

    @Column(columnDefinition = "int default 0")
    private int totalSold;

    @Column(columnDefinition = "int default 0")
    private int viewCount;

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

    @Column(length = 16, columnDefinition = "varchar(16) default 'card'")
    private String fulfillmentType = "card";

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

    @Column(columnDefinition = "tinyint(1) default 1")
    private boolean showNote = true;

    @Column(columnDefinition = "tinyint(1) default 1")
    private boolean showContact = true;

    @Column
    private LocalDateTime createdAt;
}
