package com.backendsys.modules.cms.banner.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 org.hibernate.validator.constraints.Range;

import java.util.List;

@Data
@TableName("cms_banner")
public class Banner {
    public static interface Detail{}
    public static interface Create{}
    public static interface Update{}
    public static interface Delete{}

    @TableField(exist = false)
    private String lang;
    @TableId(type = IdType.AUTO)
    private Long id;

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

    @TableField(exist = false)
    private String title;
    @TableField(exist = false)
    private String link;
    @TableField(exist = false)
    private String image;
    @TableField(exist = false)
    private String image_thumb;

    @RangeArray(message="幻灯片类型取值有误，范围应是(1首页幻灯片, 2内页幻灯片)", value = {"1", "2"}, groups = { Create.class })
    private Integer type;
    @Range(min = 1, max = 9999, message = "排序必须在 {min} 到 {max} 之间", groups = { Create.class, Update.class})
    private Integer sort;
    @RangeArray(message="幻灯片状态取值有误，范围应是(-1禁用, 1启用)", value = {"-1", "1"}, groups = { Create.class, Update.class})
    private Integer status;

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

    private String create_time;
    private String update_time;

}
