From 8c2d6e07ff8edde0eb4d65ac3aca926d26491d56 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Tue, 21 Oct 2025 15:17:08 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SysUpdateLogController.php | 35 +++++++++ app/common/logic/SysUpdateLogLogic.php | 17 ++++ app/common/model/SysUpdateLog.php | 49 ++++++++++++ app/common/service/SysUpdateLogService.php | 78 +++++++++++++++++++ app/common/validate/SysUpdateLogValidate.php | 29 +++++++ config/route.php | 16 +++- 6 files changed, 223 insertions(+), 1 deletion(-) create mode 100644 app/common/controller/SysUpdateLogController.php create mode 100644 app/common/logic/SysUpdateLogLogic.php create mode 100644 app/common/model/SysUpdateLog.php create mode 100644 app/common/service/SysUpdateLogService.php create mode 100644 app/common/validate/SysUpdateLogValidate.php diff --git a/app/common/controller/SysUpdateLogController.php b/app/common/controller/SysUpdateLogController.php new file mode 100644 index 0000000..56a3218 --- /dev/null +++ b/app/common/controller/SysUpdateLogController.php @@ -0,0 +1,35 @@ +service = new SysUpdateLogService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + protected function indexFormat($data) + { + if (isset($data['update_time'])) + $data['update_time'] = date('Y-m-d H:i:s', $data['update_time']); + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } +} \ No newline at end of file diff --git a/app/common/logic/SysUpdateLogLogic.php b/app/common/logic/SysUpdateLogLogic.php new file mode 100644 index 0000000..6bec427 --- /dev/null +++ b/app/common/logic/SysUpdateLogLogic.php @@ -0,0 +1,17 @@ +validator; + } + + /** + * 构造 CrudUtil 查询配置 + */ + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'default': + $config['order']['id'] = 'desc'; + case 'index': + break; + case 'show': + $config['where']['id'] = $p['id']; + break; + case 'store': + break; + case 'update': + case 'destroy': + $config['where']['id'] = $p['id']; + break; + } + + return $config; + } + + /** + * 添加前置处理 + */ + public function beforeServiceStore($data, Request $request) + { + $data['update_time'] = !empty($data['update_time'])?strtotime($data['update_time']):0; + return $data; + } + + /** + * 添加前置处理 + */ + public function beforeServiceupdate($data, Request $request) + { + $data['update_time'] = !empty($data['update_time'])?strtotime($data['update_time']):0; + return $data; + } +} \ No newline at end of file diff --git a/app/common/validate/SysUpdateLogValidate.php b/app/common/validate/SysUpdateLogValidate.php new file mode 100644 index 0000000..59bb004 --- /dev/null +++ b/app/common/validate/SysUpdateLogValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/config/route.php b/config/route.php index 687c002..2fafd16 100644 --- a/config/route.php +++ b/config/route.php @@ -400,7 +400,6 @@ Route::group('/admin', function () { Route::any('/resubmit', [app\common\controller\PurchaseOrdersController::class, 'resubmit']); }); - Route::group('/user/group', function () { Route::any('/list', [app\admin\controller\UserGroupController::class, 'index']); Route::any('/show', [app\admin\controller\UserGroupController::class, 'show']); @@ -408,6 +407,21 @@ Route::group('/admin', function () { Route::any('/update', [app\admin\controller\UserGroupController::class, 'update']); Route::any('/destroy', [app\admin\controller\UserGroupController::class, 'destroy']); }); + + // 操作日志 + Route::group('/op/log', function () { + Route::any('/list', [app\common\controller\SysOpLogController::class, 'index']); + Route::any('/show', [app\common\controller\SysOpLogController::class, 'show']); + }); + + // 操作日志 + Route::group('/update/log', function () { + Route::any('/list', [app\common\controller\SysUpdateLogController::class, 'index']); + Route::any('/show', [app\common\controller\SysUpdateLogController::class, 'show']); + Route::any('/store', [app\common\controller\SysUpdateLogController::class, 'store']); + Route::any('/update', [app\common\controller\SysUpdateLogController::class, 'update']); + Route::any('/destroy', [app\common\controller\SysUpdateLogController::class, 'destroy']); + }); }); From 5e3d05e502b66de21022cdf087ac7cd597bac4b1 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Thu, 23 Oct 2025 13:21:07 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E8=AF=B7=E6=B1=82=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/controller/SysOpLogController.php | 33 +++++++++ app/common/logic/SysOpLogLogic.php | 17 +++++ app/common/model/SysOpLog.php | 49 ++++++++++++ app/common/service/SysOpLogService.php | 78 ++++++++++++++++++++ app/common/validate/SysOpLogValidate.php | 29 ++++++++ 5 files changed, 206 insertions(+) create mode 100644 app/common/controller/SysOpLogController.php create mode 100644 app/common/logic/SysOpLogLogic.php create mode 100644 app/common/model/SysOpLog.php create mode 100644 app/common/service/SysOpLogService.php create mode 100644 app/common/validate/SysOpLogValidate.php diff --git a/app/common/controller/SysOpLogController.php b/app/common/controller/SysOpLogController.php new file mode 100644 index 0000000..525232e --- /dev/null +++ b/app/common/controller/SysOpLogController.php @@ -0,0 +1,33 @@ +service = new SysOpLogService(); + } + + /** + * 列表页数据格式化 + * + * @param array $data + * @return array + */ + protected function indexFormat($data) + { + if (isset($data['created_at'])) + $data['created_at'] = date('Y-m-d H:i:s', $data['created_at']); + if (isset($data['updated_at'])) + $data['updated_at'] = date('Y-m-d H:i:s', $data['updated_at']); + return $data; + } +} \ No newline at end of file diff --git a/app/common/logic/SysOpLogLogic.php b/app/common/logic/SysOpLogLogic.php new file mode 100644 index 0000000..ec454cd --- /dev/null +++ b/app/common/logic/SysOpLogLogic.php @@ -0,0 +1,17 @@ +validator; + } + + + /** + * 构建查询条件 + */ + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'index': + // ====== ====== 排序 ====== ====== + $config['order']['id'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + // 状态 + if (isset($p['user_id']) && $p['user_id']) { + $config['where']['user_id'] = $p['user_id']; + } + // ip + if (isset($p['ip']) && $p['ip']) { + $config['where']['ip'] = $p['ip']; + } + // ip + if (isset($p['method']) && $p['method']) { + $config['where']['method'] = $p['method']; + } + // 关键字 + if (isset($p['keyword']) && $p['keyword']) { + $k = '%' . $p['keyword'] . '%'; + foreach (['user_name', 'route'] as $col) { + $config['orWhere'][] = [$col, 'like', $k]; + } + } + //$config['where']['status'] = 1; + break; + case 'show': + $config['where']['id'] = $p['id']; + //$config['where']['status'] = 1; + break; + } + + return $config; + } +} \ No newline at end of file diff --git a/app/common/validate/SysOpLogValidate.php b/app/common/validate/SysOpLogValidate.php new file mode 100644 index 0000000..3d8a1d2 --- /dev/null +++ b/app/common/validate/SysOpLogValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file From 24b3ef44154625f8f4d8ff71469a007b1aa64a4d Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Fri, 24 Oct 2025 15:25:29 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=8E=92=E5=BA=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/service/SysUpdateLogService.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/common/service/SysUpdateLogService.php b/app/common/service/SysUpdateLogService.php index 643b4f0..c93c350 100644 --- a/app/common/service/SysUpdateLogService.php +++ b/app/common/service/SysUpdateLogService.php @@ -40,9 +40,8 @@ class SysUpdateLogService $config = []; $config['model'] = $this->modelClass; switch ($scene) { - case 'default': - $config['order']['id'] = 'desc'; case 'index': + $config['order']['id'] = 'desc'; break; case 'show': $config['where']['id'] = $p['id'];