From 08aee72ab949a8639afadd229d09015db1afc0f5 Mon Sep 17 00:00:00 2001 From: JaguarJack Date: Tue, 28 Apr 2020 22:02:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97=E5=88=97?= =?UTF-8?q?=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catch/system/controller/Generate.php | 19 +++++++++++++++++ catch/system/controller/LoginLog.php | 24 +++++++++++++++++---- catch/system/controller/OperateLog.php | 29 +++++++++++++++++--------- catch/system/model/LoginLog.php | 1 - catch/system/route.php | 6 +++++- 5 files changed, 63 insertions(+), 16 deletions(-) diff --git a/catch/system/controller/Generate.php b/catch/system/controller/Generate.php index b3d9bbc..415d92a 100644 --- a/catch/system/controller/Generate.php +++ b/catch/system/controller/Generate.php @@ -1 +1,20 @@ done($request->param())); + } + + public function preview() + { + + } +} diff --git a/catch/system/controller/LoginLog.php b/catch/system/controller/LoginLog.php index 1c174a6..5b45351 100644 --- a/catch/system/controller/LoginLog.php +++ b/catch/system/controller/LoginLog.php @@ -4,16 +4,32 @@ namespace catchAdmin\system\controller; use catcher\base\CatchController; use catcher\CatchResponse; use think\facade\Db; +use catchAdmin\system\model\LoginLog as Log; class LoginLog extends CatchController { - public function list() + /** + * + * @time 2020年04月28日 + * @param Log $log + * @throws \think\db\exception\DbException + * @return \think\response\Json + */ + public function list(Log $log) { - return CatchResponse::paginate(Db::name('login_log')->paginate(request()->param('limit') ?? 10)); + return CatchResponse::paginate($log->paginate()); } - public function empty() + /** + * 清空 + * + * @time 2020年04月28日 + * @param Log $log + * @throws \Exception + * @return \think\response\Json + */ + public function empty(Log $log) { - return CatchResponse::success(Db::name('login_log')->delete(true), '清空成功'); + return CatchResponse::success($log->where('id', '>', 0)->delete(), '清空成功'); } } diff --git a/catch/system/controller/OperateLog.php b/catch/system/controller/OperateLog.php index 55e30f7..0e6baf8 100644 --- a/catch/system/controller/OperateLog.php +++ b/catch/system/controller/OperateLog.php @@ -4,22 +4,31 @@ namespace catchAdmin\system\controller; use catcher\base\CatchController; use catcher\CatchResponse; use think\facade\Db; +use catchAdmin\system\model\OperateLog as Log; class OperateLog extends CatchController { - public function list() + /** + * + * @time 2020年04月28日 + * @param Log $log + * @throws \think\db\exception\DbException + * @return \think\response\Json + */ + public function list(Log $log) { - return CatchResponse::paginate( - Db::name('operate_log') - ->field(['operate_log.*', 'users.username as creator']) - ->join('users','users.id = operate_log.creator_id') - ->order('id', 'desc') - ->paginate(request()->param('limit') ?? 10) - ); + return CatchResponse::paginate($log->getList()); } - public function empty() + /** + * + * @time 2020年04月28日 + * @param Log $log + * @throws \Exception + * @return \think\response\Json + */ + public function empty(Log $log) { - return CatchResponse::success(Db::name('operate_log')->delete(true), '清空成功'); + return CatchResponse::success($log->where('id', '>', 0)->delete(), '清空成功'); } } diff --git a/catch/system/model/LoginLog.php b/catch/system/model/LoginLog.php index 7933805..13ebf37 100644 --- a/catch/system/model/LoginLog.php +++ b/catch/system/model/LoginLog.php @@ -1,7 +1,6 @@ resource('attachments', '\catchAdmin\system\controller\Attachments'); // 配置 $router->get('config/parent', '\catchAdmin\system\controller\Config@parent'); -$router->resource('config', '\catchAdmin\system\controller\Config'); \ No newline at end of file +$router->resource('config', '\catchAdmin\system\controller\Config'); + +// 代码生成 +$router->post('generate', '\catchAdmin\system\controller\Generate@save'); +$router->post('generate/preview', '\catchAdmin\system\controller\Generate@preview'); // 预览