package com.yhy.module.core.dal.dataobject.config;

import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
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 com.yhy.module.core.dal.typehandler.PostgreSQLJsonbTypeHandler;
import com.yhy.module.core.dal.typehandler.PostgreSQLTextArrayTypeHandler;
import java.util.Map;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * 项目界面配置树 DO
 * 节点类型：root-根节点, province-省市, industry-行业
 *
 * @author yhy
 */
@TableName(value = "yhy_config_project_tree", autoResultMap = true)
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ConfigProjectTreeDO extends BaseDO {

    /**
     * 主键ID
     */
    @TableId(type = IdType.ASSIGN_ID)
    private Long id;

    /**
     * 租户ID
     */
    private Long tenantId;

    /**
     * 父节点ID
     */
    private Long parentId;

    /**
     * 编码
     */
    private String code;

    /**
     * 名称
     */
    private String name;

    /**
     * 节点类型：root-根节点, province-省市, industry-行业
     */
    private String nodeType;

    /**
     * 排序号
     */
    private Integer sortOrder;

    /**
     * 层级路径（ID数组）
     */
    @TableField(typeHandler = PostgreSQLTextArrayTypeHandler.class)
    private String[] path;

    /**
     * 扩展属性（JSONB）
     */
    @TableField(typeHandler = PostgreSQLJsonbTypeHandler.class)
    private Map<String, Object> attributes;

    // 节点类型常量
    public static final String NODE_TYPE_ROOT = "root";
    public static final String NODE_TYPE_PROVINCE = "province";
    public static final String NODE_TYPE_INDUSTRY = "industry";
}
