mirror of
https://gitee.com/ulthon/ulthon_admin.git
synced 2026-08-30 12:45:32 +08:00
feat(mcp): MCP 密钥管理后台(CURD 重组 Base/App,密钥仅创建时明文展示)
This commit is contained in:
33
database/migrations/20260816203001_system_mcp_key.php
Normal file
33
database/migrations/20260816203001_system_mcp_key.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
|
||||
class SystemMcpKey extends Migrator
|
||||
{
|
||||
/**
|
||||
* MCP密钥表.
|
||||
*
|
||||
* 明文密钥永不出现在本表:
|
||||
* - key 存 SHA-256 哈希(char 64,唯一索引)
|
||||
* - key_prefix 存明文前 16 位(char 16,展示用)
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
$table = $this->table('system_mcp_key')
|
||||
->setComment('MCP密钥表')
|
||||
->addColumn('title', 'char', ['limit' => 50, 'null' => true, 'comment' => '密钥名称'])
|
||||
->addColumn('key', 'char', ['limit' => 64, 'null' => true, 'comment' => '密钥SHA-256哈希'])
|
||||
->addColumn('key_prefix', 'char', ['limit' => 16, 'null' => true, 'default' => '', 'comment' => '密钥前缀(展示用)'])
|
||||
->addColumn('bind_admin_id', 'biginteger', ['limit' => 11, 'null' => true, 'signed' => false, 'comment' => '绑定创建者ID'])
|
||||
->addColumn('status', 'integer', ['limit' => 11, 'null' => true, 'default' => 1, 'comment' => '状态 {radio} (0:禁用,1:启用)'])
|
||||
->addColumn('remark', 'char', ['limit' => 255, 'null' => true, 'default' => '', 'comment' => ''])
|
||||
->addColumn('use_num', 'biginteger', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '调用次数'])
|
||||
->addColumn('last_use_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '最后使用时间'])
|
||||
->addColumn('create_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '创建时间'])
|
||||
->addColumn('update_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '更新时间'])
|
||||
->addColumn('delete_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '删除时间'])
|
||||
->addIndex(['key'], ['unique' => true, 'name' => 'key'])
|
||||
->addIndex(['delete_time'], ['name' => 'delete_time'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
21
database/migrations/20260816203002_system_mcp_key_node.php
Normal file
21
database/migrations/20260816203002_system_mcp_key_node.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
|
||||
class SystemMcpKeyNode extends Migrator
|
||||
{
|
||||
/**
|
||||
* MCP密钥与节点关系表.
|
||||
*
|
||||
* 纯关系表:无任何时间戳字段。
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
$table = $this->table('system_mcp_key_node')
|
||||
->setComment('MCP密钥与节点关系表')
|
||||
->addColumn('key_id', 'biginteger', ['limit' => 11, 'null' => true, 'signed' => false, 'comment' => '密钥ID'])
|
||||
->addColumn('node', 'char', ['limit' => 100, 'null' => true, 'default' => '', 'comment' => ''])
|
||||
->addIndex(['key_id'], ['name' => 'key_id'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
25
database/migrations/20260816203003_system_mcp_log.php
Normal file
25
database/migrations/20260816203003_system_mcp_log.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
use think\migration\Migrator;
|
||||
|
||||
class SystemMcpLog extends Migrator
|
||||
{
|
||||
/**
|
||||
* MCP调用日志表.
|
||||
*
|
||||
* 仅 create_time(写入后不变),无 update_time / delete_time。
|
||||
*/
|
||||
public function change()
|
||||
{
|
||||
$table = $this->table('system_mcp_log')
|
||||
->setComment('MCP调用日志表')
|
||||
->addColumn('key_id', 'biginteger', ['limit' => 11, 'null' => true, 'signed' => false, 'comment' => '密钥ID'])
|
||||
->addColumn('node', 'char', ['limit' => 100, 'null' => true, 'comment' => '调用节点'])
|
||||
->addColumn('arguments', 'text', ['null' => true, 'comment' => '参数摘要JSON'])
|
||||
->addColumn('is_success', 'integer', ['limit' => 1, 'null' => true, 'default' => 1, 'comment' => '是否成功:0=失败,1=成功'])
|
||||
->addColumn('cost_ms', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'comment' => '耗时毫秒'])
|
||||
->addColumn('create_time', 'integer', ['limit' => 11, 'null' => true, 'default' => 0, 'signed' => false, 'comment' => '创建时间'])
|
||||
->addIndex(['key_id'], ['name' => 'key_id'])
|
||||
->create();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user