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); + } +}