From 17dc611c2851dd5c4522876b0e9389882c935f7e Mon Sep 17 00:00:00 2001 From: yaooo <272523191@qq.com> Date: Wed, 13 Dec 2023 11:43:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E8=A1=8C=E6=94=BF=E5=90=88?= =?UTF-8?q?=E5=90=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AdministrativeContractController.php | 108 ++++++++++++++ .../contract/AdministrativeContractLists.php | 77 ++++++++++ .../contract/AdministrativeContractLogic.php | 132 ++++++++++++++++++ .../AdministrativeContractValidate.php | 97 +++++++++++++ .../model/contract/AdministrativeContract.php | 34 +++++ 5 files changed, 448 insertions(+) create mode 100644 app/adminapi/controller/contract/AdministrativeContractController.php create mode 100644 app/adminapi/lists/contract/AdministrativeContractLists.php create mode 100644 app/adminapi/logic/contract/AdministrativeContractLogic.php create mode 100644 app/adminapi/validate/contract/AdministrativeContractValidate.php create mode 100644 app/common/model/contract/AdministrativeContract.php diff --git a/app/adminapi/controller/contract/AdministrativeContractController.php b/app/adminapi/controller/contract/AdministrativeContractController.php new file mode 100644 index 000000000..1b50d1b00 --- /dev/null +++ b/app/adminapi/controller/contract/AdministrativeContractController.php @@ -0,0 +1,108 @@ +dataLists(new AdministrativeContractLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/13 11:40 + */ + public function add() + { + $params = (new AdministrativeContractValidate())->post()->goCheck('add'); + $result = AdministrativeContractLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(AdministrativeContractLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/13 11:40 + */ + public function edit() + { + $params = (new AdministrativeContractValidate())->post()->goCheck('edit'); + $result = AdministrativeContractLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(AdministrativeContractLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/13 11:40 + */ + public function delete() + { + $params = (new AdministrativeContractValidate())->post()->goCheck('delete'); + AdministrativeContractLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/12/13 11:40 + */ + public function detail() + { + $params = (new AdministrativeContractValidate())->goCheck('detail'); + $result = AdministrativeContractLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/contract/AdministrativeContractLists.php b/app/adminapi/lists/contract/AdministrativeContractLists.php new file mode 100644 index 000000000..907e8b368 --- /dev/null +++ b/app/adminapi/lists/contract/AdministrativeContractLists.php @@ -0,0 +1,77 @@ + ['supplier_id', 'contract_no', 'contract_name', 'procurement_type', 'asset_apply_no'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/12/13 11:40 + */ + public function lists(): array + { + return AdministrativeContract::where($this->searchWhere) + ->field(['*']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/12/13 11:40 + */ + public function count(): int + { + return AdministrativeContract::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/contract/AdministrativeContractLogic.php b/app/adminapi/logic/contract/AdministrativeContractLogic.php new file mode 100644 index 000000000..e131d9a75 --- /dev/null +++ b/app/adminapi/logic/contract/AdministrativeContractLogic.php @@ -0,0 +1,132 @@ + $params['supplier_id'] ?? 0, + 'contract_no' => $params['contract_no'] ?? '', + 'contract_name' => $params['contract_name'] ?? '', + 'procurement_type' => $params['procurement_type'] ?? 0, + 'asset_apply_no' => $params['asset_apply_no'] ?? '', + 'start_date' => $params['start_date'] ?? '', + 'end_date' => $params['end_date'] ?? '', + 'signing_date' => $params['signing_date'] ?? '', + 'pay_type' => $params['pay_type'] ?? 0, + 'amount' => $params['amount'] ?? 0, + 'amount_daxie' => $params['amount_daxie'] ?? '', + 'main_content' => $params['main_content'] ?? '', + 'remark' => $params['remark'] ?? '', + 'annex' => $params['annex'] ?? '', + ]); + + 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/12/13 11:40 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + AdministrativeContract::where('id', $params['id'])->update([ + 'supplier_id' => $params['supplier_id'] ?? 0, + 'contract_no' => $params['contract_no'] ?? '', + 'contract_name' => $params['contract_name'] ?? '', + 'procurement_type' => $params['procurement_type'] ?? 0, + 'asset_apply_no' => $params['asset_apply_no'] ?? '', + 'start_date' => $params['start_date'] ?? '', + 'end_date' => $params['end_date'] ?? '', + 'signing_date' => $params['signing_date'] ?? '', + 'pay_type' => $params['pay_type'] ?? 0, + 'amount' => $params['amount'] ?? 0, + 'amount_daxie' => $params['amount_daxie'] ?? '', + 'main_content' => $params['main_content'] ?? '', + 'remark' => $params['remark'] ?? '', + 'annex' => $params['annex'] ?? '', + ]); + + 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/12/13 11:40 + */ + public static function delete(array $params): bool + { + return AdministrativeContract::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/12/13 11:40 + */ + public static function detail($params): array + { + return AdministrativeContract::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/contract/AdministrativeContractValidate.php b/app/adminapi/validate/contract/AdministrativeContractValidate.php new file mode 100644 index 000000000..bab944d13 --- /dev/null +++ b/app/adminapi/validate/contract/AdministrativeContractValidate.php @@ -0,0 +1,97 @@ + 'require', + 'supplier_id' => 'require', + 'contract_no' => 'require', + 'contract_name' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return AdministrativeContractValidate + * @author likeadmin + * @date 2023/12/13 11:40 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return AdministrativeContractValidate + * @author likeadmin + * @date 2023/12/13 11:40 + */ + public function sceneEdit() + { + return $this->only(['id', 'supplier_id', 'contract_no', 'contract_name']); + } + + + /** + * @notes 删除场景 + * @return AdministrativeContractValidate + * @author likeadmin + * @date 2023/12/13 11:40 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return AdministrativeContractValidate + * @author likeadmin + * @date 2023/12/13 11:40 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/contract/AdministrativeContract.php b/app/common/model/contract/AdministrativeContract.php new file mode 100644 index 000000000..81deb57c8 --- /dev/null +++ b/app/common/model/contract/AdministrativeContract.php @@ -0,0 +1,34 @@ +