package com.backendsys.modules.b2c.good.entity;

import com.backendsys.config.Mybatis.handler.timezone.LocalDateTimeAdapter;
import com.backendsys.entity.validator.RangeArray;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.google.gson.annotations.JsonAdapter;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;

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

@Data
@TableName("b2c_good")
public class Good {

    public static interface Detail{}
    public static interface DetailByUid{}
    public static interface Create{}
    public static interface Update{}
    public static interface Delete{}
    public static interface DeleteBatch{}

    @TableField(exist = false)
    private String lang;

    @TableId(type = IdType.AUTO)
    private Long id;

    @TableField("id")
    @NotNull(message="good_id 不能为空", groups = { Detail.class, Update.class, Delete.class })
    private Long good_id;

    @NotEmpty(message="uid 不能为空", groups = { DetailByUid.class })
    private String uid;

    @NotNull(message = "商品分类ID不能为空", groups = { Create.class, Update.class })
    private Long category_id;

    @TableField(exist = false)
    private String category_name;

    private Long brand_id;

    @TableField(exist = false)
    private String brand_name;
    private Long unit_id;

    @TableField(exist = false)
    private String unit_name;

    @TableField(exist = false)
    private String good_name;

    @TableField(exist = false)
    private String good_description;

    @TableField(exist = false)
    private String good_content;

    @Size(max = 2000, message = "商品缩略图地址长度不超过 {max} 字符", groups = { Create.class, Update.class })
    private String good_thumb;

    @Size(max = 20000, message = "商品图片地址长度不超过 {max} 字符", groups = { Create.class, Update.class })
    private String good_images;

    @TableField(exist = false)
    private String meta_keyword;

    @TableField(exist = false)
    private String meta_description;

    @TableField(exist = false)
    @NotEmpty(message="内容不能为空", groups = { Create.class, Update.class})
    private List<GoodI18n> translations;

    @RangeArray(message="商品状态取值有误，范围应是(-1禁用, 1启用)", value = {"-1", "1"}, groups = { Create.class, Update.class })
    private Integer status;

    private Integer del_flag;

    @TableField(exist = false)
    private String create_time_begin;
    @TableField(exist = false)
    private String create_time_end;

    @JsonAdapter(LocalDateTimeAdapter.class)
    private LocalDateTime create_time;

    @JsonAdapter(LocalDateTimeAdapter.class)
    private LocalDateTime update_time;

    @TableField(value = "create_time")
    private String create_time_utc;

    @TableField(value = "update_time")
    private String update_time_utc;

}
