From 98b2d7d31b622bde7bafc0bebe0b0f9f54a4711b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9D=92=E8=8A=92=E7=A7=91=E6=8A=80?= <67047984+qingmang@users.noreply.github.com> Date: Mon, 13 Jul 2020 19:00:53 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E8=AE=BE=E7=BD=AEdepartments=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E7=9A=84=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 只有自定义数据才存在departments --- catch/permissions/controller/Role.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/catch/permissions/controller/Role.php b/catch/permissions/controller/Role.php index 089d229..7c38ecd 100644 --- a/catch/permissions/controller/Role.php +++ b/catch/permissions/controller/Role.php @@ -96,7 +96,7 @@ class Role extends CatchController // 更新department $hasDepartmentIds = $role->getDepartments()->column('id'); - $departmentIds = $request->param('departments'); + $departmentIds = $request->param('departments',[]); // 已存在部门 IDS $existedDepartmentIds = []; From a6ad9b63dd4830d66a02e82328875f253dda4180 Mon Sep 17 00:00:00 2001 From: tlerbao Date: Tue, 14 Jul 2020 21:06:10 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=89=B9=E9=87=8F=E5=88=A0=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catch/system/controller/OperateLog.php | 26 +++++++++++++++++++++++++- catch/system/route.php | 5 +++-- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/catch/system/controller/OperateLog.php b/catch/system/controller/OperateLog.php index 0e6baf8..42a8834 100644 --- a/catch/system/controller/OperateLog.php +++ b/catch/system/controller/OperateLog.php @@ -1,13 +1,19 @@ model = $model; + } /** * * @time 2020年04月28日 @@ -31,4 +37,22 @@ class OperateLog extends CatchController { return CatchResponse::success($log->where('id', '>', 0)->delete(), '清空成功'); } + + /** + * 批量删除 + * + * @param mixed $id + * @throws \Exception + * @return \think\response\Json + */ + public function delete($id) + { + $ids = explode(',', $id); + + if (empty($ids)) { + return false; + } + + return CatchResponse::success($this->model->whereIn('id', $ids)->delete()); + } } diff --git a/catch/system/route.php b/catch/system/route.php index 484bf1f..3d8ef00 100644 --- a/catch/system/route.php +++ b/catch/system/route.php @@ -1,11 +1,12 @@ group(function () use ($router){ +$router->group(function () use ($router) { // 登录日志 $router->get('log/login', '\catchAdmin\system\controller\LoginLog@list'); $router->delete('loginLog/empty', '\catchAdmin\system\controller\LoginLog@empty'); // 操作日志 $router->get('log/operate', '\catchAdmin\system\controller\OperateLog@list'); $router->delete('operateLog/empty', '\catchAdmin\system\controller\OperateLog@empty'); + $router->delete('operateLog/delete', '\catchAdmin\system\controller\OperateLog@delete'); // 数据字典 $router->get('tables', '\catchAdmin\system\controller\DataDictionary@tables'); @@ -35,4 +36,4 @@ $router->group(function () use ($router){ //developer路由 $router->resource('developer', '\catchAdmin\system\controller\Developer')->middleware('auth'); // 开发者认证 -$router->post('developer/authenticate', '\catchAdmin\system\controller\Developer@authenticate'); \ No newline at end of file +$router->post('developer/authenticate', '\catchAdmin\system\controller\Developer@authenticate'); From 142fd71b563dee8ec1512ee3060408c60a9397fa Mon Sep 17 00:00:00 2001 From: tlerbao Date: Wed, 15 Jul 2020 11:39:55 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=9D=A1=E4=BB=B6=E6=9F=A5=E8=AF=A2=EF=BC=8C?= =?UTF-8?q?=E5=B9=B6=E7=AE=80=E5=8D=95=E4=BC=98=E5=8C=96=E4=BA=86=E6=93=8D?= =?UTF-8?q?=E4=BD=9C=E6=97=A5=E5=BF=97=E6=8E=A7=E5=88=B6=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- catch/system/controller/OperateLog.php | 10 ++---- catch/system/model/OperateLog.php | 31 +++++++++++-------- .../system/model/search/OperateLogSearch.php | 26 ++++++++++++++++ 3 files changed, 46 insertions(+), 21 deletions(-) create mode 100644 catch/system/model/search/OperateLogSearch.php diff --git a/catch/system/controller/OperateLog.php b/catch/system/controller/OperateLog.php index 42a8834..55d0366 100644 --- a/catch/system/controller/OperateLog.php +++ b/catch/system/controller/OperateLog.php @@ -8,12 +8,6 @@ use catchAdmin\system\model\OperateLog as Log; class OperateLog extends CatchController { - protected $model; - - public function __construct(Log $model) - { - $this->model = $model; - } /** * * @time 2020年04月28日 @@ -45,7 +39,7 @@ class OperateLog extends CatchController * @throws \Exception * @return \think\response\Json */ - public function delete($id) + public function delete($id, Log $log) { $ids = explode(',', $id); @@ -53,6 +47,6 @@ class OperateLog extends CatchController return false; } - return CatchResponse::success($this->model->whereIn('id', $ids)->delete()); + return CatchResponse::success($log->whereIn('id', $ids)->delete()); } } diff --git a/catch/system/model/OperateLog.php b/catch/system/model/OperateLog.php index 5481646..112df34 100644 --- a/catch/system/model/OperateLog.php +++ b/catch/system/model/OperateLog.php @@ -1,25 +1,29 @@ field([$this->aliasField('*')]) - ->catchJoin(Users::class, 'id', 'creator_id', ['username as creator']) - ->order($this->aliasField('id'), 'desc') - ->paginate(); + ->catchJoin(Users::class, 'id', 'creator_id', ['username as creator']) + ->catchSearch() + ->order($this->aliasField('id'), 'desc') + ->paginate(); } -} \ No newline at end of file +} diff --git a/catch/system/model/search/OperateLogSearch.php b/catch/system/model/search/OperateLogSearch.php new file mode 100644 index 0000000..36fbbee --- /dev/null +++ b/catch/system/model/search/OperateLogSearch.php @@ -0,0 +1,26 @@ +whereLike('module', $value); + } + + public function searchMethodAttr($query, $value, $data) + { + return $query->whereLike('method', $value); + } + + public function searchCreatorAttr($query, $value, $data) + { + return $query->where('username', $value); + } + + public function searchCreateAtAttr($query, $value, $data) + { + return $query->whereTime($this->aliasField('created_at'), 'between', $value); + } +}