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/', '\catchAdmin\system\controller\DataDictionary@view'); +$router->post('table/optimize', '\catchAdmin\system\controller\DataDictionary@optimize'); +$router->post('table/backup', '\catchAdmin\system\controller\DataDictionary@backup'); + diff --git a/catchAdmin/system/view/dataDictionary/index.html b/catchAdmin/system/view/dataDictionary/index.html index 566549b..6c41f31 100644 --- a/catchAdmin/system/view/dataDictionary/index.html +++ b/catchAdmin/system/view/dataDictionary/index.html @@ -1,10 +1,113 @@ - - - - - Title - - +{extend name="../../../view/layout"} +{block name="title"}登录日志{/block} +{block name="search"} +
+
+ + + + +
+
+{/block} +{block name="table"} +
+ + +{/block} +{block name="script"} + +{/block} \ No newline at end of file diff --git a/catchAdmin/system/view/dataDictionary/view.html b/catchAdmin/system/view/dataDictionary/view.html index 566549b..f6ab66b 100644 --- a/catchAdmin/system/view/dataDictionary/view.html +++ b/catchAdmin/system/view/dataDictionary/view.html @@ -5,6 +5,35 @@ Title - +
+ + + + + + + + + + + + + + + {foreach $table as $field} + + + + + + + + + + + {/foreach} + +
字段类型字符集Null索引默认值权限注释
{$field['Field']}{$field['Type']}{$field['Collation']}{$field['Null']}{$field['Key']}{$field['Default']}{$field['Privileges']}{$field['Comment']}
+
\ No newline at end of file diff --git a/catchAdmin/system/view/loginLog/index.html b/catchAdmin/system/view/loginLog/index.html index 17d9a45..c28c0a9 100644 --- a/catchAdmin/system/view/loginLog/index.html +++ b/catchAdmin/system/view/loginLog/index.html @@ -3,16 +3,17 @@ {block name="search"}
- - - + + +
{/block} @@ -36,17 +37,19 @@ // toolbar: true, cellMinWidth: 100, cols: [[ - {type: 'id', title: '#', field: 'id'}, - {field: 'login_name', sort: true, title: '登录名'}, - {field: 'login_ip', sort: true, title: '登录IP'}, - {field: 'browser', sort: true, title: '浏览器'}, - {field: 'os', sort: true, title: '操作系统'}, - {field: 'status', sort: true, title: '状态', templet: function (d) { - return d.status === 1 ? '成功' : '失败' + {type: 'id', title: '序号', field: 'id'}, + {field: 'login_name', title: '登录名'}, + {field: 'login_ip', title: '登录IP'}, + {field: 'browser', title: '浏览器'}, + {field: 'os', title: '操作系统'}, + {field: 'status', title: '状态', templet: function (d) { + return d.status === 1 ? + '' : + '' } }, { - field: 'login_at', sort: true, templet: function (d) { + field: 'login_at', templet: function (d) { return util.toDateString(d.login_at); }, title: '登录时间' }, diff --git a/catchAdmin/system/view/operateLog/index.html b/catchAdmin/system/view/operateLog/index.html index 57b5cad..6563419 100644 --- a/catchAdmin/system/view/operateLog/index.html +++ b/catchAdmin/system/view/operateLog/index.html @@ -36,15 +36,16 @@ // toolbar: true, cellMinWidth: 100, cols: [[ - {type: 'id', title: '#', field: 'id'}, - {field: 'module', sort: true, title: '模块'}, - {field: 'ip', sort: true, title: 'IP'}, - {field: 'operate', sort: true, title: 'operate'}, - {field: 'creator', sort: true, title: '操作者'}, - {field: 'method', sort: true, title: '请求方法'}, - {field: 'created_at', sort: true, title: '创建时间', templet: function (d) { - return d.status === 1 ? '成功' : '失败' - } + {type: 'id', title: '序号', field: 'id'}, + {field: 'module', title: '模块'}, + {field: 'ip', title: 'IP'}, + {field: 'operate', title: 'operate'}, + {field: 'creator', title: '操作者'}, + {field: 'method', title: '请求方法'}, + { + field: 'created_at', sort: true, templet: function (d) { + return util.toDateString(d.created_at); + }, title: '创建时间' }, ]], });