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/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/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/service/SysUpdateLogService.php b/app/common/service/SysUpdateLogService.php new file mode 100644 index 0000000..c93c350 --- /dev/null +++ b/app/common/service/SysUpdateLogService.php @@ -0,0 +1,77 @@ +validator; + } + + /** + * 构造 CrudUtil 查询配置 + */ + 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'; + 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/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 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']); + }); });