package com.chushang.system.entity.po;

import com.baomidou.mybatisplus.annotation.*;
import com.chushang.common.mybatis.base.BaseEntity;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.SuperBuilder;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serial;
import java.util.ArrayList;
import java.util.List;

@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName("sys_dept")
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class SysDept extends BaseEntity
{
    @Serial
    private static final long serialVersionUID = 1L;

    /** 部门ID */
    @TableId(value = "dept_id", type = IdType.AUTO)
    private Long deptId;

    /** 父部门ID */
    @TableField(value = "parent_dept_id")
    private Long parentId;

    /** 祖级列表 */
    private String ancestors;

    /** 部门名称 */
    @NotBlank(message = "部门名称不能为空")
    @Size(max = 30, message = "部门名称长度不能超过30个字符")
    private String deptName;

    /** 显示顺序 */
    @NotNull(message = "显示顺序不能为空")
    private Integer orderNum;

    /** 部门状态:0停用,1正常 */
    private Boolean status;

    /** 父部门名称 */
    @TableField(exist = false)
    private String parentName;
    
    /** 子部门 */
    @TableField(exist = false)
    private List<SysDept> children = new ArrayList<>();

    /**
     * 创建人
     */
    @TableField(
            value = "create_by",
            updateStrategy = FieldStrategy.NEVER
    )
    private String createBy;
    /**
     * 修改人
     */
    @TableField(
            value = "update_by",
            insertStrategy = FieldStrategy.NEVER
    )
    private String updateBy;

}