package com.backendsys.modules.material.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.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.annotations.JsonAdapter;
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("ai_material")
public class Material {

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

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

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

    private Long user_id;
    @TableField(exist = false)
    private String user_nickname;

    @NotNull(message="素材分类ID不能为空", groups = { Create.class, Update.class })
    private Long category_id;
    @TableField(exist = false)
    private String category_name;

    private String tag_ids;
    @TableField(exist = false)
    private Long tag_id;
    @TableField(exist = false)
    private List<MaterialTag> tag_list;

    @Size(max = 100, message = "素材名称长度不超过 {max} 个字符", groups = { Create.class, Update.class })
    @NotEmpty(message="素材名称不能为空", groups = { Create.class, Update.class })
    private String material_name;

    @Size(max = 1000, message = "缩略图路径长度不超过 {max} 个字符", groups = { Create.class, Update.class })
    private String image_thumb_url;
    @Size(max = 1000, message = "高清图路径长度不超过 {max} 个字符", groups = { Create.class, Update.class })
    private String image_url;
    @Size(max = 1000, message = "文件地址长度不超过 {max} 个字符", groups = { Create.class, Update.class })
    private String file_url;
    @Size(max = 1000, message = "百度网盘地址长度不超过 {max} 个字符", groups = { Create.class, Update.class })
    private String pan_baidu_url;

    @RangeArray(message="是否有版权，范围应是(-1否, 1是)", value = {"-1", "1"}, groups = { Create.class, Update.class })
    private Integer is_copyright;

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @JsonAdapter(LocalDateTimeAdapter.class)
    private LocalDateTime create_time;

    @JsonProperty(access = JsonProperty.Access.READ_ONLY)
    @JsonAdapter(LocalDateTimeAdapter.class)
    private LocalDateTime update_time;

}
