From 02ef21cb7c2ad44a04bd02ef324413033a6a4983 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Fri, 31 May 2024 17:54:46 +0800 Subject: [PATCH] =?UTF-8?q?(=E4=BD=A0=E7=9A=84=E6=8F=90=E4=BA=A4=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=EF=BC=9A=20=E5=88=9B=E5=BB=BA=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=8E=A7=E5=88=B6=E5=99=A8=E3=80=81=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E3=80=81=E9=80=BB=E8=BE=91=E3=80=81=E9=AA=8C=E8=AF=81?= =?UTF-8?q?=E5=99=A8=E5=92=8C=E6=A8=A1=E5=9E=8B)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system_store/SystemStoreController.php | 95 ++++++++++++++++ .../lists/system_store/SystemStoreLists.php | 65 +++++++++++ .../logic/system_store/SystemStoreLogic.php | 106 ++++++++++++++++++ .../system_store/SystemStoreValidate.php | 94 ++++++++++++++++ app/common/model/system_store/SystemStore.php | 22 ++++ 5 files changed, 382 insertions(+) create mode 100644 app/admin/controller/system_store/SystemStoreController.php create mode 100644 app/admin/lists/system_store/SystemStoreLists.php create mode 100644 app/admin/logic/system_store/SystemStoreLogic.php create mode 100644 app/admin/validate/system_store/SystemStoreValidate.php create mode 100644 app/common/model/system_store/SystemStore.php diff --git a/app/admin/controller/system_store/SystemStoreController.php b/app/admin/controller/system_store/SystemStoreController.php new file mode 100644 index 000000000..c01ef820e --- /dev/null +++ b/app/admin/controller/system_store/SystemStoreController.php @@ -0,0 +1,95 @@ +dataLists(new SystemStoreLists()); + } + + + /** + * @notes 添加门店列表 + * @return \think\response\Json + * @author admin + * @date 2024/05/31 17:45 + */ + public function add() + { + $params = (new SystemStoreValidate())->post()->goCheck('add'); + $result = SystemStoreLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(SystemStoreLogic::getError()); + } + + + /** + * @notes 编辑门店列表 + * @return \think\response\Json + * @author admin + * @date 2024/05/31 17:45 + */ + public function edit() + { + $params = (new SystemStoreValidate())->post()->goCheck('edit'); + $result = SystemStoreLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(SystemStoreLogic::getError()); + } + + + /** + * @notes 删除门店列表 + * @return \think\response\Json + * @author admin + * @date 2024/05/31 17:45 + */ + public function delete() + { + $params = (new SystemStoreValidate())->post()->goCheck('delete'); + SystemStoreLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取门店列表详情 + * @return \think\response\Json + * @author admin + * @date 2024/05/31 17:45 + */ + public function detail() + { + $params = (new SystemStoreValidate())->goCheck('detail'); + $result = SystemStoreLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/admin/lists/system_store/SystemStoreLists.php b/app/admin/lists/system_store/SystemStoreLists.php new file mode 100644 index 000000000..e10aaa4fc --- /dev/null +++ b/app/admin/lists/system_store/SystemStoreLists.php @@ -0,0 +1,65 @@ + ['name', 'phone'], + ]; + } + + + /** + * @notes 获取门店列表列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author admin + * @date 2024/05/31 17:45 + */ + public function lists(): array + { + return SystemStore::where($this->searchWhere) + ->field(['id', 'name', 'phone', 'detailed_address', 'image', 'is_show']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取门店列表数量 + * @return int + * @author admin + * @date 2024/05/31 17:45 + */ + public function count(): int + { + return SystemStore::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/admin/logic/system_store/SystemStoreLogic.php b/app/admin/logic/system_store/SystemStoreLogic.php new file mode 100644 index 000000000..42a601854 --- /dev/null +++ b/app/admin/logic/system_store/SystemStoreLogic.php @@ -0,0 +1,106 @@ + $params['name'], + 'introduction' => $params['introduction'], + 'phone' => $params['phone'], + 'detailed_address' => $params['detailed_address'], + 'image' => $params['image'], + 'is_show' => $params['is_show'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑门店列表 + * @param array $params + * @return bool + * @author admin + * @date 2024/05/31 17:45 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + SystemStore::where('id', $params['id'])->update([ + 'name' => $params['name'], + 'introduction' => $params['introduction'], + 'phone' => $params['phone'], + 'detailed_address' => $params['detailed_address'], + 'image' => $params['image'], + 'latitude' => $params['latitude'], + 'longitude' => $params['longitude'], + 'is_show' => $params['is_show'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除门店列表 + * @param array $params + * @return bool + * @author admin + * @date 2024/05/31 17:45 + */ + public static function delete(array $params): bool + { + return SystemStore::destroy($params['id']); + } + + + /** + * @notes 获取门店列表详情 + * @param $params + * @return array + * @author admin + * @date 2024/05/31 17:45 + */ + public static function detail($params): array + { + return SystemStore::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/admin/validate/system_store/SystemStoreValidate.php b/app/admin/validate/system_store/SystemStoreValidate.php new file mode 100644 index 000000000..a3590881c --- /dev/null +++ b/app/admin/validate/system_store/SystemStoreValidate.php @@ -0,0 +1,94 @@ + 'require', + 'name' => 'require', + 'phone' => 'require', + 'detailed_address' => 'require', + 'image' => 'require', + 'latitude' => 'require', + 'longitude' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'name' => '门店名称', + 'phone' => '手机号码', + 'detailed_address' => '详细地址', + 'image' => '门店logo', + 'latitude' => '纬度', + 'longitude' => '经度', + ]; + + + /** + * @notes 添加场景 + * @return SystemStoreValidate + * @author admin + * @date 2024/05/31 17:45 + */ + public function sceneAdd() + { + return $this->only(['name','phone','detailed_address','image','latitude','longitude']); + } + + + /** + * @notes 编辑场景 + * @return SystemStoreValidate + * @author admin + * @date 2024/05/31 17:45 + */ + public function sceneEdit() + { + return $this->only(['id','name','phone','detailed_address','image','latitude','longitude']); + } + + + /** + * @notes 删除场景 + * @return SystemStoreValidate + * @author admin + * @date 2024/05/31 17:45 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return SystemStoreValidate + * @author admin + * @date 2024/05/31 17:45 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/system_store/SystemStore.php b/app/common/model/system_store/SystemStore.php new file mode 100644 index 000000000..ac1c4345b --- /dev/null +++ b/app/common/model/system_store/SystemStore.php @@ -0,0 +1,22 @@ +