package com.backendsys.modules.system.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 jakarta.validation.constraints.Size;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import java.util.List;

@Data
@TableName("sys_user_role_menu")
public class SysUserRoleMenu {

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

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

    private Long parent_id;

    @NotEmpty(message="菜单名称不能为空", groups = { Create.class, Update.class })
    @Size(min = 2, max = 50, message = "菜单名称长度在 {min}-{max} 字符", groups = { Create.class, Update.class })
    private String menu_name;

    @NotEmpty(message="菜单名称(英文)不能为空", groups = { Create.class, Update.class })
    @Size(min = 2, max = 50, message = "菜单名称(英文)长度在 {min}-{max} 字符", groups = { Create.class, Update.class })
    private String menu_name_en;

    @NotNull(message="菜单类型不能为空", groups = { Create.class, Update.class })
    @RangeArray(message="菜单类型取值有误，范围应是(1菜单, 2按钮)", value = {"1", "2"}, groups = { Create.class, Update.class })
    private Integer type;

    @NotEmpty(message="跳转路径不能为空", groups = { Create.class, Update.class })
    private String path;
    private String component;

    private String meta;
    private String icon;
    private String permission_id;

    @TableField(exist = false)
    private List<SysUserRoleMenu> children;

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