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