From 92591b4b5106f40f10c892af20b35f9fd3996e96 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Sat, 23 Sep 2023 15:12:45 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=95=E8=AF=89=E5=8F=8D=E9=A6=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../CompanyComplaintFeedbackController.php | 108 ++++++++++++++++++ .../lists/CompanyComplaintFeedbackLists.php | 77 +++++++++++++ .../logic/CompanyComplaintFeedbackLogic.php | 106 +++++++++++++++++ .../CompanyComplaintFeedbackValidate.php | 96 ++++++++++++++++ app/common/model/CompanyComplaintFeedback.php | 34 ++++++ 5 files changed, 421 insertions(+) create mode 100644 app/adminapi/controller/CompanyComplaintFeedbackController.php create mode 100644 app/adminapi/lists/CompanyComplaintFeedbackLists.php create mode 100644 app/adminapi/logic/CompanyComplaintFeedbackLogic.php create mode 100644 app/adminapi/validate/CompanyComplaintFeedbackValidate.php create mode 100644 app/common/model/CompanyComplaintFeedback.php diff --git a/app/adminapi/controller/CompanyComplaintFeedbackController.php b/app/adminapi/controller/CompanyComplaintFeedbackController.php new file mode 100644 index 000000000..b691d21eb --- /dev/null +++ b/app/adminapi/controller/CompanyComplaintFeedbackController.php @@ -0,0 +1,108 @@ +dataLists(new CompanyComplaintFeedbackLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2023/09/23 15:08 + */ + public function add() + { + $params = (new CompanyComplaintFeedbackValidate())->post()->goCheck('add'); + $result = CompanyComplaintFeedbackLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(CompanyComplaintFeedbackLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2023/09/23 15:08 + */ + public function edit() + { + $params = (new CompanyComplaintFeedbackValidate())->post()->goCheck('edit'); + $result = CompanyComplaintFeedbackLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(CompanyComplaintFeedbackLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2023/09/23 15:08 + */ + public function delete() + { + $params = (new CompanyComplaintFeedbackValidate())->post()->goCheck('delete'); + CompanyComplaintFeedbackLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2023/09/23 15:08 + */ + public function detail() + { + $params = (new CompanyComplaintFeedbackValidate())->goCheck('detail'); + $result = CompanyComplaintFeedbackLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/CompanyComplaintFeedbackLists.php b/app/adminapi/lists/CompanyComplaintFeedbackLists.php new file mode 100644 index 000000000..613ff7847 --- /dev/null +++ b/app/adminapi/lists/CompanyComplaintFeedbackLists.php @@ -0,0 +1,77 @@ + ['content'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2023/09/23 15:08 + */ + public function lists(): array + { + return CompanyComplaintFeedback::where($this->searchWhere) + ->field(['id', 'content', 'create_time']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2023/09/23 15:08 + */ + public function count(): int + { + return CompanyComplaintFeedback::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/CompanyComplaintFeedbackLogic.php b/app/adminapi/logic/CompanyComplaintFeedbackLogic.php new file mode 100644 index 000000000..fa3d1bc00 --- /dev/null +++ b/app/adminapi/logic/CompanyComplaintFeedbackLogic.php @@ -0,0 +1,106 @@ + $params['content'], + ]); + + 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/09/23 15:08 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + CompanyComplaintFeedback::where('id', $params['id'])->update([ + 'content' => $params['content'], + ]); + + 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/09/23 15:08 + */ + public static function delete(array $params): bool + { + return CompanyComplaintFeedback::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2023/09/23 15:08 + */ + public static function detail($params): array + { + return CompanyComplaintFeedback::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/CompanyComplaintFeedbackValidate.php b/app/adminapi/validate/CompanyComplaintFeedbackValidate.php new file mode 100644 index 000000000..87ce3088d --- /dev/null +++ b/app/adminapi/validate/CompanyComplaintFeedbackValidate.php @@ -0,0 +1,96 @@ + 'require', + 'content' => 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'content' => '内容', + ]; + + + /** + * @notes 添加场景 + * @return CompanyComplaintFeedbackValidate + * @author likeadmin + * @date 2023/09/23 15:08 + */ + public function sceneAdd() + { + return $this->only(['content']); + } + + + /** + * @notes 编辑场景 + * @return CompanyComplaintFeedbackValidate + * @author likeadmin + * @date 2023/09/23 15:08 + */ + public function sceneEdit() + { + return $this->only(['id','content']); + } + + + /** + * @notes 删除场景 + * @return CompanyComplaintFeedbackValidate + * @author likeadmin + * @date 2023/09/23 15:08 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return CompanyComplaintFeedbackValidate + * @author likeadmin + * @date 2023/09/23 15:08 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/CompanyComplaintFeedback.php b/app/common/model/CompanyComplaintFeedback.php new file mode 100644 index 000000000..1dee194d0 --- /dev/null +++ b/app/common/model/CompanyComplaintFeedback.php @@ -0,0 +1,34 @@ +