package com.backendsys.modules.cms.article.entity;

import com.backendsys.config.Mybatis.handler.timezone.LocalDateTimeAdapter;
import com.backendsys.entity.validator.RangeArray;
import com.baomidou.mybatisplus.annotation.*;
import com.google.gson.annotations.JsonAdapter;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

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

@Data
@TableName("cms_article")
public class Article {

    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="article_id 不能为空", groups = { Detail.class, Update.class, Delete.class })
    private Long article_id;
    @NotEmpty(message="uid 不能为空", groups = { DetailByUid.class })
    private String uid;
    private String thumb;
    @TableField(exist = false)
    @NotNull(message="article_id 不能为空", groups = { Delete.class })
    private List<Long> article_ids;

    @TableField(exist = false)
    private String title;
    @TableField(exist = false)
    private String description;
    @TableField(exist = false)
    private String content;
    @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<ArticleI18n> translations;

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

    private Long category_id;
    @TableField(exist = false)
    private String category_name;

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


    @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;

}
