From 280c26983f9ccfb88ac2c1903917a201f3ee3a19 Mon Sep 17 00:00:00 2001 From: "WIN-C27C5MSVTPO\\16961" <1696136552@qq.com> Date: Wed, 27 Aug 2025 17:39:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A7=E5=B8=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/SysCurrencyController.php | 52 ++++++++++++++++ app/admin/logic/SysCurrencyLogic.php | 17 ++++++ app/admin/service/SysCurrencyService.php | 61 +++++++++++++++++++ app/admin/service/SysDictItemService.php | 37 +++++++++++ app/admin/validate/SysCurrencyValidate.php | 29 +++++++++ app/common/model/SysCurrency.php | 49 +++++++++++++++ config/route.php | 9 +++ 7 files changed, 254 insertions(+) create mode 100644 app/admin/controller/SysCurrencyController.php create mode 100644 app/admin/logic/SysCurrencyLogic.php create mode 100644 app/admin/service/SysCurrencyService.php create mode 100644 app/admin/validate/SysCurrencyValidate.php create mode 100644 app/common/model/SysCurrency.php diff --git a/app/admin/controller/SysCurrencyController.php b/app/admin/controller/SysCurrencyController.php new file mode 100644 index 0000000..0e96169 --- /dev/null +++ b/app/admin/controller/SysCurrencyController.php @@ -0,0 +1,52 @@ +service = new SysCurrencyService(); + } + + /** + * 列表页数据格式化 + * + * @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']); + if (isset($data['last_updated'])) + $data['last_updated'] = date('Y-m-d H:i:s', $data['last_updated']); + 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']); + if (isset($data['last_updated'])) + $data['last_updated'] = date('Y-m-d H:i:s', $data['last_updated']); + return $data; + } +} \ No newline at end of file diff --git a/app/admin/logic/SysCurrencyLogic.php b/app/admin/logic/SysCurrencyLogic.php new file mode 100644 index 0000000..e70b18c --- /dev/null +++ b/app/admin/logic/SysCurrencyLogic.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; + } +} \ No newline at end of file diff --git a/app/admin/service/SysDictItemService.php b/app/admin/service/SysDictItemService.php index a4d54e2..e9269f4 100644 --- a/app/admin/service/SysDictItemService.php +++ b/app/admin/service/SysDictItemService.php @@ -5,6 +5,7 @@ namespace app\admin\service; use app\admin\validate\SysDictItemValidate; use app\common\traits\crud\CrudServiceTrait; use app\common\model\SysDictItem; +use support\Request; class SysDictItemService { @@ -28,4 +29,40 @@ class SysDictItemService { return new $this->validator; } + + /** + * 构建查询条件 + */ + protected function buildQueryConfig(Request $request, string $scene = 'index'): array + { + $p = $request->all(); + + $config = []; + $config['model'] = $this->modelClass; + switch ($scene) { + case 'index': + // ====== ====== 排序 ====== ====== + $config['order']['sort'] = 'desc'; + + // ====== ====== 筛选 ====== ====== + + $config['where']['dict_id'] = $p['id']; + // 状态 + if (isset($p['status']) && in_array($p['status'], [0,1])) { + $config['where']['status'] = $p['status']; + } + break; + case 'show': + $config['where']['id'] = $p['id']; + break; + case 'update': + case 'destroy': + $config['where']['id'] = $p['id']; + break; + case 'store': + break; + } + + return $config; + } } \ No newline at end of file diff --git a/app/admin/validate/SysCurrencyValidate.php b/app/admin/validate/SysCurrencyValidate.php new file mode 100644 index 0000000..4aebb21 --- /dev/null +++ b/app/admin/validate/SysCurrencyValidate.php @@ -0,0 +1,29 @@ + [ + + ], + + 'update' => [ + + ] + ]; +} \ No newline at end of file diff --git a/app/common/model/SysCurrency.php b/app/common/model/SysCurrency.php new file mode 100644 index 0000000..200a23b --- /dev/null +++ b/app/common/model/SysCurrency.php @@ -0,0 +1,49 @@ +