From 0d3fe114f3512955966b20245deefdd0d1f7030f Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 15 Jan 2024 10:07:56 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=B6=88=E6=AF=92=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OperationDisinfectLogController.php | 108 ++++++++++++++++ .../OperationDisinfectLogLists.php | 77 +++++++++++ .../OperationDisinfectLogLogic.php | 122 ++++++++++++++++++ .../OperationDisinfectLogValidate.php | 94 ++++++++++++++ .../OperationDisinfectLog.php | 56 ++++++++ 5 files changed, 457 insertions(+) create mode 100644 app/api/controller/suyuan_operation/OperationDisinfectLogController.php create mode 100644 app/api/lists/suyuan_operation/OperationDisinfectLogLists.php create mode 100644 app/api/logic/suyuan_operation/OperationDisinfectLogLogic.php create mode 100644 app/api/validate/suyuan_operation/OperationDisinfectLogValidate.php create mode 100644 app/common/model/suyuan_operation/OperationDisinfectLog.php diff --git a/app/api/controller/suyuan_operation/OperationDisinfectLogController.php b/app/api/controller/suyuan_operation/OperationDisinfectLogController.php new file mode 100644 index 0000000..75c240f --- /dev/null +++ b/app/api/controller/suyuan_operation/OperationDisinfectLogController.php @@ -0,0 +1,108 @@ +dataLists(new OperationDisinfectLogLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2024/01/15 10:07 + */ + public function add() + { + $params = (new OperationDisinfectLogValidate())->post()->goCheck('add'); + $result = OperationDisinfectLogLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(OperationDisinfectLogLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2024/01/15 10:07 + */ + public function edit() + { + $params = (new OperationDisinfectLogValidate())->post()->goCheck('edit'); + $result = OperationDisinfectLogLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(OperationDisinfectLogLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2024/01/15 10:07 + */ + public function delete() + { + $params = (new OperationDisinfectLogValidate())->post()->goCheck('delete'); + OperationDisinfectLogLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/01/15 10:07 + */ + public function detail() + { + $params = (new OperationDisinfectLogValidate())->goCheck('detail'); + $result = OperationDisinfectLogLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/api/lists/suyuan_operation/OperationDisinfectLogLists.php b/app/api/lists/suyuan_operation/OperationDisinfectLogLists.php new file mode 100644 index 0000000..3940827 --- /dev/null +++ b/app/api/lists/suyuan_operation/OperationDisinfectLogLists.php @@ -0,0 +1,77 @@ + ['fence_house_id', 'animal_info_id'], + ]; + } + + + /** + * @notes 获取列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/01/15 10:07 + */ + public function lists(): array + { + return OperationDisinfectLog::where($this->searchWhere) + ->field(['id', 'fence_house_id', 'animal_info_id', 'disinfectant_name', 'concentration', 'disinfectant_method', 'disinfectant_area', 'operator', 'remark']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select() + ->toArray(); + } + + + /** + * @notes 获取数量 + * @return int + * @author likeadmin + * @date 2024/01/15 10:07 + */ + public function count(): int + { + return OperationDisinfectLog::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/api/logic/suyuan_operation/OperationDisinfectLogLogic.php b/app/api/logic/suyuan_operation/OperationDisinfectLogLogic.php new file mode 100644 index 0000000..04ba9a6 --- /dev/null +++ b/app/api/logic/suyuan_operation/OperationDisinfectLogLogic.php @@ -0,0 +1,122 @@ + $params['fence_house_id'], + 'animal_info_id' => $params['animal_info_id'], + 'disinfectant_name' => $params['disinfectant_name'], + 'concentration' => $params['concentration'], + 'disinfectant_method' => $params['disinfectant_method'], + 'disinfectant_area' => $params['disinfectant_area'], + 'operator' => $params['operator'], + 'image' => $params['image'], + 'remark' => $params['remark'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 编辑 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/01/15 10:07 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + OperationDisinfectLog::where('id', $params['id'])->update([ + 'fence_house_id' => $params['fence_house_id'], + 'animal_info_id' => $params['animal_info_id'], + 'disinfectant_name' => $params['disinfectant_name'], + 'concentration' => $params['concentration'], + 'disinfectant_method' => $params['disinfectant_method'], + 'disinfectant_area' => $params['disinfectant_area'], + 'operator' => $params['operator'], + 'image' => $params['image'], + 'remark' => $params['remark'], + ]); + + Db::commit(); + return true; + } catch (\Exception $e) { + Db::rollback(); + self::setError($e->getMessage()); + return false; + } + } + + + /** + * @notes 删除 + * @param array $params + * @return bool + * @author likeadmin + * @date 2024/01/15 10:07 + */ + public static function delete(array $params): bool + { + return OperationDisinfectLog::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/01/15 10:07 + */ + public static function detail($params): array + { + return OperationDisinfectLog::findOrEmpty($params['id'])->toArray(); + } +} \ No newline at end of file diff --git a/app/api/validate/suyuan_operation/OperationDisinfectLogValidate.php b/app/api/validate/suyuan_operation/OperationDisinfectLogValidate.php new file mode 100644 index 0000000..8b8c470 --- /dev/null +++ b/app/api/validate/suyuan_operation/OperationDisinfectLogValidate.php @@ -0,0 +1,94 @@ + 'require', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + ]; + + + /** + * @notes 添加场景 + * @return OperationDisinfectLogValidate + * @author likeadmin + * @date 2024/01/15 10:07 + */ + public function sceneAdd() + { + return $this->remove('id', true); + } + + + /** + * @notes 编辑场景 + * @return OperationDisinfectLogValidate + * @author likeadmin + * @date 2024/01/15 10:07 + */ + public function sceneEdit() + { + return $this->only(['id']); + } + + + /** + * @notes 删除场景 + * @return OperationDisinfectLogValidate + * @author likeadmin + * @date 2024/01/15 10:07 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return OperationDisinfectLogValidate + * @author likeadmin + * @date 2024/01/15 10:07 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + +} \ No newline at end of file diff --git a/app/common/model/suyuan_operation/OperationDisinfectLog.php b/app/common/model/suyuan_operation/OperationDisinfectLog.php new file mode 100644 index 0000000..f588c5b --- /dev/null +++ b/app/common/model/suyuan_operation/OperationDisinfectLog.php @@ -0,0 +1,56 @@ +hasOne(\app\common\model\fence_house\FenceHouse::class, 'id', 'fence_house_id'); + } + + /** + * @notes 关联animalInfo + * @return \think\model\relation\HasOne + * @author likeadmin + * @date 2024/01/15 10:07 + */ + public function animalInfo() + { + return $this->hasOne(\app\common\model\animal_info\AnimalInfo::class, 'id', 'animal_info_id'); + } + +} \ No newline at end of file