49 lines
2.0 KiB
Python
49 lines
2.0 KiB
Python
|
|
"""
|
|||
|
|
插件模型 — 第三方节点扩展
|
|||
|
|
"""
|
|||
|
|
from sqlalchemy import Column, String, Text, Boolean, DateTime, JSON, Integer, func
|
|||
|
|
from sqlalchemy.dialects.mysql import CHAR
|
|||
|
|
from app.core.database import Base
|
|||
|
|
import uuid
|
|||
|
|
|
|||
|
|
|
|||
|
|
class NodePlugin(Base):
|
|||
|
|
"""第三方节点插件"""
|
|||
|
|
__tablename__ = "node_plugins"
|
|||
|
|
|
|||
|
|
id = Column(CHAR(36), primary_key=True, default=lambda: str(uuid.uuid4()), comment="插件ID")
|
|||
|
|
name = Column(String(128), nullable=False, unique=True, comment="插件名称(唯一)")
|
|||
|
|
version = Column(String(32), nullable=False, default="1.0.0", comment="版本号")
|
|||
|
|
description = Column(Text, comment="描述")
|
|||
|
|
author = Column(String(128), comment="作者")
|
|||
|
|
node_type = Column(String(64), nullable=False, comment="节点类型标识(如 custom_http、custom_data)")
|
|||
|
|
node_label = Column(String(128), comment="节点显示名称")
|
|||
|
|
category = Column(String(64), default="custom", comment="分类: custom/http/data/ai/tool")
|
|||
|
|
|
|||
|
|
# manifest.json 原始内容
|
|||
|
|
manifest = Column(JSON, comment="manifest.json 完整内容")
|
|||
|
|
|
|||
|
|
# 输入/输出定义
|
|||
|
|
inputs_schema = Column(JSON, comment="输入参数 schema")
|
|||
|
|
outputs_schema = Column(JSON, comment="输出参数 schema")
|
|||
|
|
|
|||
|
|
# 代码
|
|||
|
|
code = Column(Text, comment="插件执行代码(Python)")
|
|||
|
|
|
|||
|
|
# 状态
|
|||
|
|
enabled = Column(Boolean, default=True, comment="是否启用")
|
|||
|
|
is_public = Column(Boolean, default=False, comment="是否公开到插件市场")
|
|||
|
|
install_count = Column(Integer, default=0, comment="安装次数")
|
|||
|
|
rating_avg = Column(Integer, default=0, comment="平均评分")
|
|||
|
|
|
|||
|
|
# 元数据
|
|||
|
|
icon = Column(String(256), comment="图标URL")
|
|||
|
|
tags = Column(JSON, comment="标签列表")
|
|||
|
|
user_id = Column(CHAR(36), nullable=True, comment="上传者ID")
|
|||
|
|
|
|||
|
|
created_at = Column(DateTime, default=func.now(), comment="创建时间")
|
|||
|
|
updated_at = Column(DateTime, default=func.now(), onupdate=func.now(), comment="更新时间")
|
|||
|
|
|
|||
|
|
def __repr__(self):
|
|||
|
|
return f"<NodePlugin(id={self.id}, name={self.name}, type={self.node_type})>"
|