package com.lingyue.graph.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.lingyue.common.mybatis.PostgreSqlJsonbTypeHandler;
import com.lingyue.common.domain.entity.SimpleModel;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 规则实体
 * 用于存储用户定义的规则链
 * 
 * @author lingyue
 * @since 2026-01-14
 */
@EqualsAndHashCode(callSuper = true)
@Data
@TableName(value = "rules", autoResultMap = true)
@Schema(description = "规则实体")
public class Rule extends SimpleModel {
    
    @Schema(description = "用户ID")
    @TableField("user_id")
    private String userId;
    
    @Schema(description = "规则名称")
    @TableField("name")
    private String name;
    
    @Schema(description = "规则描述")
    @TableField("description")
    private String description;
    
    @Schema(description = "入口节点ID")
    @TableField("entry_node_id")
    private String entryNodeId;
    
    @Schema(description = "出口节点ID")
    @TableField("exit_node_id")
    private String exitNodeId;
    
    @Schema(description = "规则链", example = "[\"node1\", \"node2\", \"node3\"]")
    @TableField(value = "rule_chain", typeHandler = PostgreSqlJsonbTypeHandler.class)
    private Object ruleChain;
    
    @Schema(description = "状态", example = "active/inactive")
    @TableField("status")
    private String status = "active";
    
    @Schema(description = "元数据")
    @TableField(value = "metadata", typeHandler = PostgreSqlJsonbTypeHandler.class)
    private Object metadata;
}
