package com.lingyue.extract.entity;

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

import java.util.List;
import java.util.Map;

/**
 * 规则模板实体
 * 
 * 用于保存和复用规则配置
 * 
 * @author lingyue
 * @since 2026-01-22
 */
@EqualsAndHashCode(callSuper = true)
@Data
@TableName(value = "extract_rule_templates", autoResultMap = true)
@Schema(description = "规则模板")
public class RuleTemplate 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 = "规则配置快照")
    @TableField(value = "rules_snapshot", typeHandler = JacksonTypeHandler.class)
    private List<Map<String, Object>> rulesSnapshot;
    
    @Schema(description = "适用的文档类型模式")
    @TableField(value = "doc_type_pattern", typeHandler = JacksonTypeHandler.class)
    private Map<String, Object> docTypePattern;
    
    // ==================== 可见性 ====================
    
    @Schema(description = "是否公开")
    @TableField("is_public")
    private Boolean isPublic;
    
    // ==================== 统计 ====================
    
    @Schema(description = "使用次数")
    @TableField("use_count")
    private Integer useCount;
    
    // ==================== 元数据 ====================
    
    @Schema(description = "元数据")
    @TableField(value = "metadata", typeHandler = JacksonTypeHandler.class)
    private Map<String, Object> metadata;
}
