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 = []; diff --git a/catch/system/controller/OperateLog.php b/catch/system/controller/OperateLog.php index 0e6baf8..55d0366 100644 --- a/catch/system/controller/OperateLog.php +++ b/catch/system/controller/OperateLog.php @@ -1,9 +1,9 @@ where('id', '>', 0)->delete(), '清空成功'); } + + /** + * 批量删除 + * + * @param mixed $id + * @throws \Exception + * @return \think\response\Json + */ + public function delete($id, Log $log) + { + $ids = explode(',', $id); + + if (empty($ids)) { + return false; + } + + 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); + } +} 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');