From 88fe5eed6ea74da6f8809f1e35f7da5ed9caf140 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 14 Nov 2023 10:19:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=94=AE=E5=89=8D=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=88=90=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ProjectPreSalesMembersController.php | 108 +++++++++++++++++ .../project/ProjectPreSalesMembersLists.php | 77 ++++++++++++ .../project/ProjectPreSalesMembersLogic.php | 112 ++++++++++++++++++ .../ProjectPreSalesMembersValidate.php | 94 +++++++++++++++ .../model/project/ProjectPreSalesMembers.php | 34 ++++++ 5 files changed, 425 insertions(+) create mode 100644 app/adminapi/controller/project/ProjectPreSalesMembersController.php create mode 100644 app/adminapi/lists/project/ProjectPreSalesMembersLists.php create mode 100644 app/adminapi/logic/project/ProjectPreSalesMembersLogic.php create mode 100644 app/adminapi/validate/project/ProjectPreSalesMembersValidate.php create mode 100644 app/common/model/project/ProjectPreSalesMembers.php diff --git a/app/adminapi/controller/project/ProjectPreSalesMembersController.php b/app/adminapi/controller/project/ProjectPreSalesMembersController.php new file mode 100644 index 000000000..873f2b72a --- /dev/null +++ b/app/adminapi/controller/project/ProjectPreSalesMembersController.php @@ -0,0 +1,108 @@ +dataLists(new ProjectPreSalesMembersLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/14 10:15 + */ + public function add() + { + $params = (new ProjectPreSalesMembersValidate())->post()->goCheck('add'); + $result = ProjectPreSalesMembersLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(ProjectPreSalesMembersLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/14 10:15 + */ + public function edit() + { + $params = (new ProjectPreSalesMembersValidate())->post()->goCheck('edit'); + $result = ProjectPreSalesMembersLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(ProjectPreSalesMembersLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/14 10:15 + */ + public function delete() + { + $params = (new ProjectPreSalesMembersValidate())->post()->goCheck('delete'); + ProjectPreSalesMembersLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/11/14 10:15 + */ + public function detail() + { + $params = (new ProjectPreSalesMembersValidate())->goCheck('detail'); + $result = ProjectPreSalesMembersLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/project/ProjectPreSalesMembersLists.php b/app/adminapi/lists/project/ProjectPreSalesMembersLists.php new file mode 100644 index 000000000..6d8aaafd7 --- /dev/null +++ b/app/adminapi/lists/project/ProjectPreSalesMembersLists.php @@ -0,0 +1,77 @@ + ['project_id', 'technician_ids', 'business_people_ids', 'cross_departmental_personnel_ids'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/11/14 10:15 + */ + public function lists(): array + { + return ProjectPreSalesMembers::where($this->searchWhere) + ->field(['id', 'project_id', 'technician_ids', 'business_people_ids', 'cross_departmental_personnel_ids']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/11/14 10:15 + */ + public function count(): int + { + return ProjectPreSalesMembers::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/project/ProjectPreSalesMembersLogic.php b/app/adminapi/logic/project/ProjectPreSalesMembersLogic.php new file mode 100644 index 000000000..21e30e229 --- /dev/null +++ b/app/adminapi/logic/project/ProjectPreSalesMembersLogic.php @@ -0,0 +1,112 @@ + $params['project_id'], + 'technician_ids' => $params['technician_ids'], + 'business_people_ids' => $params['business_people_ids'], + 'cross_departmental_personnel_ids' => $params['cross_departmental_personnel_ids'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/14 10:15 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + ProjectPreSalesMembers::where('id', $params['id'])->update([ + 'project_id' => $params['project_id'], + 'technician_ids' => $params['technician_ids'], + 'business_people_ids' => $params['business_people_ids'], + 'cross_departmental_personnel_ids' => $params['cross_departmental_personnel_ids'] + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author likeadmin + * @date 2023/11/14 10:15 + */ + public static function delete(array $params): bool + { + return ProjectPreSalesMembers::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/11/14 10:15 + */ + public static function detail($params): array + { + return ProjectPreSalesMembers::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/project/ProjectPreSalesMembersValidate.php b/app/adminapi/validate/project/ProjectPreSalesMembersValidate.php new file mode 100644 index 000000000..4ab11416e --- /dev/null +++ b/app/adminapi/validate/project/ProjectPreSalesMembersValidate.php @@ -0,0 +1,94 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return ProjectPreSalesMembersValidate + * @author likeadmin + * @date 2023/11/14 10:15 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return ProjectPreSalesMembersValidate + * @author likeadmin + * @date 2023/11/14 10:15 + */ + public function sceneEdit() + { + return $this->only(['id']); + } + + + /** + * @notes 删除场景 + * @return ProjectPreSalesMembersValidate + * @author likeadmin + * @date 2023/11/14 10:15 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return ProjectPreSalesMembersValidate + * @author likeadmin + * @date 2023/11/14 10:15 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/project/ProjectPreSalesMembers.php b/app/common/model/project/ProjectPreSalesMembers.php new file mode 100644 index 000000000..5f5ab257d --- /dev/null +++ b/app/common/model/project/ProjectPreSalesMembers.php @@ -0,0 +1,34 @@ +