diff --git a/catchAdmin/system/controller/DataDictionary.php b/catchAdmin/system/controller/DataDictionary.php index b3d9bbc..caf642d 100644 --- a/catchAdmin/system/controller/DataDictionary.php +++ b/catchAdmin/system/controller/DataDictionary.php @@ -1 +1,84 @@ fetch(); + } + + /** + * + * @time 2019年12月13日 + * @param Request $request + * @return \think\response\Json + */ + public function tables(Request $request): \think\response\Json + { + $tables = Db::query('show table status'); + + return CatchResponse::paginate(Paginator::make($tables, $request->get('limit') ?? 10, $request->get('page'), count($tables), false, [])); + } + + /** + * + * @time 2019年12月13日 + * @param $table + * @throws \Exception + * @return string + */ + public function view($table): string + { + $this->table = Db::query('show full columns from ' . $table); + + return $this->fetch(); + } + + /** + * + * @time 2019年12月13日 + * @return \think\response\Json + */ + public function optimize(): \think\response\Json + { + $tables = \request()->post('data'); + + foreach ($tables as $table) { + Db::query(sprintf('optimize table %s', $table)); + } + + return CatchResponse::success([], '优化成功'); + } + + /** + * + * @time 2019年12月13日 + * @throws FailedException + * @return \think\response\Json + */ + public function backup(): \think\response\Json + { + try { + Console::call('backup:data', [trim(implode(',', \request()->post('data')), ',')]); + }catch (\Exception $e) { + throw new FailedException($e->getMessage()); + } + + return CatchResponse::success([], '备份成功'); + } +} diff --git a/catchAdmin/system/database/migrations/20191212110930_operate_log.php b/catchAdmin/system/database/migrations/20191212110930_operate_log.php index 4e75d7e..0fb31db 100644 --- a/catchAdmin/system/database/migrations/20191212110930_operate_log.php +++ b/catchAdmin/system/database/migrations/20191212110930_operate_log.php @@ -30,8 +30,10 @@ class OperateLog extends Migrator { $table = $this->table('operate_log',['engine'=>'Myisam', 'comment' => '操作日志', 'signed' => false]); $table->addColumn('module', 'string',['limit' => 50,'default'=>'','comment'=>'模块名称']) + ->addColumn('operate', 'string',['default'=> '', 'limit' => 20, 'comment'=>'操作模块']) + ->addColumn('route', 'string',['default'=> '','limit' => 20, 'comment'=>'路由']) + ->addColumn('params', 'string',['default'=> '','limit' => 1000, 'comment'=>'参数']) ->addColumn('ip', 'string',['default'=>'', 'limit' => 20,'comment'=>'ip', 'signed' => false]) - ->addColumn('operate', 'string',['default'=> '','comment'=>'操作模块']) ->addColumn('creator_id', 'integer',['default'=> 0,'comment'=>'创建人ID', 'signed' => false]) ->addColumn('method', 'string',['default'=> '','comment'=>'请求方法']) ->addColumn('created_at', 'integer', array('default'=>0,'comment'=>'登录时间', 'signed' => false )) diff --git a/catchAdmin/system/route.php b/catchAdmin/system/route.php index d81abc8..bf0f500 100644 --- a/catchAdmin/system/route.php +++ b/catchAdmin/system/route.php @@ -5,4 +5,11 @@ $router->get('loginLog/index', '\catchAdmin\system\controller\LoginLog@index'); // 操作日志 $router->get('log/operate', '\catchAdmin\system\controller\OperateLog@list'); $router->get('operateLog/index', '\catchAdmin\system\controller\OperateLog@index'); +// 数据字典 +$router->get('data/dictionary', '\catchAdmin\system\controller\DataDictionary@index'); +$router->get('tables', '\catchAdmin\system\controller\DataDictionary@tables'); +$router->get('table/view/
字段 | +类型 | +字符集 | +Null | +索引 | +默认值 | +权限 | +注释 | +
---|---|---|---|---|---|---|---|
{$field['Field']} | +{$field['Type']} | +{$field['Collation']} | +{$field['Null']} | +{$field['Key']} | +{$field['Default']} | +{$field['Privileges']} | +{$field['Comment']} | +