feat(mcp): 新增 MCP 密钥/授权/日志三表 Scheme 与模型

This commit is contained in:
augushong
2026-08-16 20:20:47 +08:00
parent 57873080df
commit 5777448d99
9 changed files with 171 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
<?php
namespace app\admin\model;
use base\admin\model\SystemMcpKeyBase;
class SystemMcpKey extends SystemMcpKeyBase
{
}

View File

@@ -0,0 +1,9 @@
<?php
namespace app\admin\model;
use base\admin\model\SystemMcpKeyNodeBase;
class SystemMcpKeyNode extends SystemMcpKeyNodeBase
{
}

View File

@@ -0,0 +1,9 @@
<?php
namespace app\admin\model;
use base\admin\model\SystemMcpLogBase;
class SystemMcpLog extends SystemMcpLogBase
{
}

View File

@@ -0,0 +1,52 @@
<?php
namespace app\admin\scheme;
use app\common\scheme\BaseScheme;
use app\common\scheme\attribute\Table;
use app\common\scheme\attribute\Field;
use app\common\scheme\attribute\Component;
use app\common\scheme\attribute\Index;
#[Table(name: 'ul_system_mcp_key', comment: 'MCP密钥表')]
#[Index(columns: ['key'], name: 'key', type: 'UNIQUE')]
#[Index(columns: ['delete_time'], name: 'delete_time', type: 'NORMAL')]
class SystemMcpKey extends BaseScheme
{
#[Field(type: 'int', length: 11, nullable: false, unsigned: true, autoIncrement: true, primary: true)]
public $id;
#[Field(type: 'char', length: 50, precision: 50, comment: '密钥名称')]
public $title;
#[Field(type: 'char', length: 64, precision: 64, comment: '密钥SHA-256哈希')]
public $key;
#[Field(type: 'char', length: 16, precision: 16, default: '', comment: '密钥前缀(展示用)')]
public $key_prefix;
#[Field(type: 'bigint', length: 11, comment: '绑定创建者ID', unsigned: true)]
public $bind_admin_id;
#[Field(type: 'int', length: 11, default: '1', comment: '状态')]
#[Component(type: 'radio', options: ['禁用', '启用'])]
public $status;
#[Field(type: 'char', length: 255, precision: 255, default: '')]
public $remark;
#[Field(type: 'bigint', length: 11, default: '0', comment: '调用次数', unsigned: true)]
public $use_num;
#[Field(type: 'int', length: 11, default: '0', unsigned: true)]
public $last_use_time;
#[Field(type: 'int', length: 11, default: '0', comment: '创建时间', unsigned: true)]
public $create_time;
#[Field(type: 'int', length: 11, default: '0', unsigned: true)]
public $update_time;
#[Field(type: 'int', length: 11, default: '0', unsigned: true)]
public $delete_time;
}

View File

@@ -0,0 +1,23 @@
<?php
namespace app\admin\scheme;
use app\common\scheme\BaseScheme;
use app\common\scheme\attribute\Table;
use app\common\scheme\attribute\Field;
use app\common\scheme\attribute\Component;
use app\common\scheme\attribute\Index;
#[Table(name: 'ul_system_mcp_key_node', comment: 'MCP密钥与节点关系表')]
#[Index(columns: ['key_id'], name: 'key_id', type: 'NORMAL')]
class SystemMcpKeyNode extends BaseScheme
{
#[Field(type: 'int', length: 11, nullable: false, unsigned: true, autoIncrement: true, primary: true)]
public $id;
#[Field(type: 'bigint', length: 11, comment: '密钥ID', unsigned: true)]
public $key_id;
#[Field(type: 'char', length: 100, precision: 100, default: '')]
public $node;
}

View File

@@ -0,0 +1,35 @@
<?php
namespace app\admin\scheme;
use app\common\scheme\BaseScheme;
use app\common\scheme\attribute\Table;
use app\common\scheme\attribute\Field;
use app\common\scheme\attribute\Component;
use app\common\scheme\attribute\Index;
#[Table(name: 'ul_system_mcp_log', comment: 'MCP调用日志表')]
#[Index(columns: ['key_id'], name: 'key_id', type: 'NORMAL')]
class SystemMcpLog extends BaseScheme
{
#[Field(type: 'int', length: 11, nullable: false, unsigned: true, autoIncrement: true, primary: true)]
public $id;
#[Field(type: 'bigint', length: 11, comment: '密钥ID', unsigned: true)]
public $key_id;
#[Field(type: 'char', length: 100, precision: 100)]
public $node;
#[Field(type: 'text', nullable: true, comment: '参数摘要JSON')]
public $arguments;
#[Field(type: 'tinyint', length: 1, default: '1')]
public $is_success;
#[Field(type: 'int', length: 11, default: '0')]
public $cost_ms;
#[Field(type: 'int', length: 11, default: '0', comment: '创建时间', unsigned: true)]
public $create_time;
}

View File

@@ -0,0 +1,10 @@
<?php
namespace base\admin\model;
use app\common\model\TimeModel;
class SystemMcpKeyBase extends TimeModel
{
protected $deleteTime = 'delete_time';
}

View File

@@ -0,0 +1,12 @@
<?php
namespace base\admin\model;
use app\common\model\TimeModel;
class SystemMcpKeyNodeBase extends TimeModel
{
protected $autoWriteTimestamp = false;
protected $deleteTime = false;
}

View File

@@ -0,0 +1,12 @@
<?php
namespace base\admin\model;
use app\common\model\TimeModel;
class SystemMcpLogBase extends TimeModel
{
protected $updateTime = false;
protected $deleteTime = false;
}