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

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 jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
import lombok.Data;

import java.util.List;

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

    public static interface Detail{}
    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;
    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;
    private Long category_id;

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