From 035450e7623585dfe48da1ede570399d410234ca Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Thu, 28 Aug 2025 14:04:58 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/VehModificationController.php | 48 +++++++++++ app/admin/logic/VehModificationLogic.php | 17 ++++ app/admin/service/BrandSeriesService.php | 49 +++++++++++ app/admin/service/BrandService.php | 48 +++++++++++ app/admin/service/SysDictItemService.php | 7 ++ app/admin/service/SysDictService.php | 2 +- app/admin/service/VehModificationService.php | 83 +++++++++++++++++++ .../validate/VehModificationValidate.php | 29 +++++++ app/common/model/VehModification.php | 49 +++++++++++ config/route.php | 9 ++ 10 files changed, 340 insertions(+), 1 deletion(-) create mode 100644 app/admin/controller/VehModificationController.php create mode 100644 app/admin/logic/VehModificationLogic.php create mode 100644 app/admin/service/VehModificationService.php create mode 100644 app/admin/validate/VehModificationValidate.php create mode 100644 app/common/model/VehModification.php diff --git a/app/admin/controller/VehModificationController.php b/app/admin/controller/VehModificationController.php new file mode 100644 index 0000000..fc057e1 --- /dev/null +++ b/app/admin/controller/VehModificationController.php @@ -0,0 +1,48 @@ +service = new VehModificationService(); + } + + /** + * 列表页数据格式化 + * + * @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; + } + + /** + * 数据格式化 + * + * @param array $data + * @return array + */ + protected function showFormat($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/admin/logic/VehModificationLogic.php b/app/admin/logic/VehModificationLogic.php new file mode 100644 index 0000000..511a9f6 --- /dev/null +++ b/app/admin/logic/VehModificationLogic.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']['sort'] = 'desc'; + $config['order']['id'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + $config['where']['brand_id'] = $p['brand_id']; + // 状态 + if (isset($p['status']) && in_array($p['status'], [0,1])) { + $config['where']['status'] = $p['status']; + } + // 关键字 + if (isset($p['keyword']) && $p['keyword']) { + $k = '%' . $p['keyword'] . '%'; + foreach (['series_code','series_name'] as $col) { + $config['orWhere'][] = [$col, 'like', $k]; + } + } + //$config['where']['status'] = 1; + break; + case 'show': + $config['where']['id'] = $p['id']; + //$config['where']['status'] = 1; + break; + case 'store': + break; + case 'update': + $config['where']['id'] = $p['id']; + break; + case 'destroy': + $config['where']['id'] = $p['id']; + break; + } + + return $config; + } } \ No newline at end of file diff --git a/app/admin/service/BrandService.php b/app/admin/service/BrandService.php index 83af709..c35df96 100644 --- a/app/admin/service/BrandService.php +++ b/app/admin/service/BrandService.php @@ -5,6 +5,7 @@ namespace app\admin\service; use app\admin\validate\BrandValidate; use app\common\traits\crud\CrudServiceTrait; use app\common\model\Brand; +use support\Request; class BrandService { @@ -28,4 +29,51 @@ class BrandService { return new $this->validator; } + + /** + * 构建查询条件 + */ + + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'index': + // ====== ====== 排序 ====== ====== + $config['order']['sort'] = 'desc'; + $config['order']['id'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + // 状态 + if (isset($p['status']) && in_array($p['status'], [0,1])) { + $config['where']['status'] = $p['status']; + } + // 关键字 + if (isset($p['keyword']) && $p['keyword']) { + $k = '%' . $p['keyword'] . '%'; + foreach (['brand_code','brand_name'] as $col) { + $config['orWhere'][] = [$col, 'like', $k]; + } + } + //$config['where']['status'] = 1; + break; + case 'show': + $config['where']['id'] = $p['id']; + //$config['where']['status'] = 1; + break; + case 'store': + break; + case 'update': + $config['where']['id'] = $p['id']; + break; + case 'destroy': + $config['where']['id'] = $p['id']; + break; + } + + return $config; + } } \ No newline at end of file diff --git a/app/admin/service/SysDictItemService.php b/app/admin/service/SysDictItemService.php index e9269f4..577b9f0 100644 --- a/app/admin/service/SysDictItemService.php +++ b/app/admin/service/SysDictItemService.php @@ -51,6 +51,13 @@ class SysDictItemService if (isset($p['status']) && in_array($p['status'], [0,1])) { $config['where']['status'] = $p['status']; } + // 关键字 + if (isset($p['keyword']) && $p['keyword']) { + $k = '%' . $p['keyword'] . '%'; + foreach (['item_label','item_value','remark'] as $col) { + $config['orWhere'][] = [$col, 'like', $k]; + } + } break; case 'show': $config['where']['id'] = $p['id']; diff --git a/app/admin/service/SysDictService.php b/app/admin/service/SysDictService.php index 82c6be6..1d08fcb 100644 --- a/app/admin/service/SysDictService.php +++ b/app/admin/service/SysDictService.php @@ -53,7 +53,7 @@ class SysDictService // 关键字 if (isset($p['keyword']) && $p['keyword']) { $k = '%' . $p['keyword'] . '%'; - foreach (['dict_name','dict_code','description','whatsapp','contacts'] as $col) { + foreach (['dict_name','dict_code','description'] as $col) { $config['orWhere'][] = [$col, 'like', $k]; } } diff --git a/app/admin/service/VehModificationService.php b/app/admin/service/VehModificationService.php new file mode 100644 index 0000000..6c56d9b --- /dev/null +++ b/app/admin/service/VehModificationService.php @@ -0,0 +1,83 @@ +validator; + } + + /** + * 构建查询条件 + */ + + protected function buildQueryConfig(Request $request, string $scene = 'default'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'index': + // ====== ====== 排序 ====== ====== + $config['order']['sort'] = 'desc'; + $config['order']['id'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + // 状态 + if (isset($p['status']) && in_array($p['status'], [0,1])) { + $config['where']['status'] = $p['status']; + } + // 状态 + if (isset($p['type']) && $p['type']) { + $config['where']['type'] = $p['type']; + } + // 关键字 + if (isset($p['keyword']) && $p['keyword']) { + $k = '%' . $p['keyword'] . '%'; + foreach (['code','name'] as $col) { + $config['orWhere'][] = [$col, 'like', $k]; + } + } + //$config['where']['status'] = 1; + break; + case 'show': + $config['where']['id'] = $p['id']; + //$config['where']['status'] = 1; + break; + case 'store': + break; + case 'update': + $config['where']['id'] = $p['id']; + break; + case 'destroy': + $config['where']['id'] = $p['id']; + break; + } + + return $config; + } +} \ No newline at end of file diff --git a/app/admin/validate/VehModificationValidate.php b/app/admin/validate/VehModificationValidate.php new file mode 100644 index 0000000..805b049 --- /dev/null +++ b/app/admin/validate/VehModificationValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/model/VehModification.php b/app/common/model/VehModification.php new file mode 100644 index 0000000..d3bd16e --- /dev/null +++ b/app/common/model/VehModification.php @@ -0,0 +1,49 @@ +