package com.agent.management.model.entity;

import lombok.Data;

import java.time.LocalDateTime;

/**
 * 标签节点 — 自引用树结构
 * 每个标签组创建时自动生成一个根节点（parentId = null）
 */
@Data
public class Tag {

    private Long id;

    private Long groupId;

    /** 父节点 ID，根节点为 null */
    private Long parentId;

    private String name;

    private Integer sortOrder;

    private LocalDateTime createdAt;

    private LocalDateTime updatedAt;

    public void onCreate() {
        createdAt = LocalDateTime.now();
        updatedAt = LocalDateTime.now();
    }

    public void onUpdate() {
        updatedAt = LocalDateTime.now();
    }
}
