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.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import org.hibernate.validator.constraints.Range;

import java.util.List;

@Data
@TableName("sys_user_role")
public class SysUserRole {

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

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

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

    private String role_sign;

    @Size(min = 2, max = 50, message = "角色名称长度在 {min}-{max} 字符", groups = { Create.class, Update.class })
    private String role_name;

    @Size(max = 200, message = "角色描述长度不超过 {max} 字符", groups = { Create.class, Update.class })
    private String role_description;

    @Size(max = 255, message = "默认登录路由长度不超过 {max} 字符", groups = { Create.class, Update.class })
    private String login_default_page;

    @TableField(exist = false)
    private Integer user_count;

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

    @TableField(exist = false)
    private List<SysUserRolePermission> permissions;

    @NotNull(message="角色权限不能为空", groups = { Create.class, Update.class })
    @TableField(exist = false)
    private List<String> permission_ids;
}
