feat: 添加记录操作日志功能

This commit is contained in:
2025-03-10 16:21:49 +08:00
parent a803fa6959
commit ba1651c352
5 changed files with 95 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
<?php
use Phinx\Db\Adapter\MysqlAdapter;
use think\migration\Migrator;
class CreateSysOperateLog extends Migrator
@@ -31,14 +32,15 @@ class CreateSysOperateLog extends Migrator
$table = $this->table('sys_operate_log', ['engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci', 'comment' => '操作日志表']);
$table->addColumn('user_id', 'integer', ['limit' => 11, 'default' => 0, 'comment' => '用户ID'])
->addColumn('title', 'string', ['limit' => 50, 'default' => '', 'comment' => '标题'])
->addColumn('version', 'string', ['limit' => 15, 'default' => '', 'comment' => '版本'])
->addColumn('method', 'string', ['limit' => 10, 'default' => '', 'comment' => '请求方式'])
->addColumn('controller', 'string', ['limit' => 50, 'default' => '', 'comment' => '控制器'])
->addColumn('action', 'string', ['limit' => 50, 'default' => '', 'comment' => '方法'])
->addColumn('url', 'string', ['limit' => 255, 'default' => '', 'comment' => 'URL'])
->addColumn('ip', 'string', ['limit' => 50, 'default' => '', 'comment' => 'IP'])
->addColumn('method', 'string', ['limit' => 10, 'default' => '', 'comment' => '请求方式'])
->addColumn('params', 'text', ['comment' => '请求参数'])
->addColumn('status', 'boolean', ['limit' => 1, 'default' => 1, 'comment' => '状态 1成功 0失败'])
->addColumn('message', 'string', ['limit' => 255, 'default' => '', 'comment' => '消息'])
->addColumn('status', MysqlAdapter::PHINX_TYPE_SMALL_INTEGER, ['limit' => 5, 'default' => 200, 'comment' => '状态'])
->addColumn('message', MysqlAdapter::PHINX_TYPE_TEXT, ['default' => null, 'comment' => '消息'])
->addColumn('created_at', 'timestamp', ['null' => false, 'default' => 'CURRENT_TIMESTAMP', 'comment' => '创建时间'])
->create();
}