From 1fd96738aaa0cbd0169576d778ed101ee3321382 Mon Sep 17 00:00:00 2001 From: weiz <736250432@qq.com> Date: Wed, 22 May 2024 14:42:19 +0800 Subject: [PATCH] update --- .../works/xzgl/OaMeetingCateController.php | 108 +++++++++++++++++ .../lists/works/xzgl/OaMeetingCateLists.php | 80 +++++++++++++ .../logic/works/xzgl/OaMeetingCateLogic.php | 110 ++++++++++++++++++ .../validate/works/xzgl/OaCarCateValidate.php | 2 +- .../works/xzgl/OaMeetingCateValidate.php | 105 +++++++++++++++++ .../works/xzgl/OaSealCateValidate.php | 2 +- app/common/model/works/xzgl/OaMeetingCate.php | 38 ++++++ 7 files changed, 443 insertions(+), 2 deletions(-) create mode 100644 app/adminapi/controller/works/xzgl/OaMeetingCateController.php create mode 100644 app/adminapi/lists/works/xzgl/OaMeetingCateLists.php create mode 100644 app/adminapi/logic/works/xzgl/OaMeetingCateLogic.php create mode 100644 app/adminapi/validate/works/xzgl/OaMeetingCateValidate.php create mode 100644 app/common/model/works/xzgl/OaMeetingCate.php diff --git a/app/adminapi/controller/works/xzgl/OaMeetingCateController.php b/app/adminapi/controller/works/xzgl/OaMeetingCateController.php new file mode 100644 index 000000000..d2d674ea3 --- /dev/null +++ b/app/adminapi/controller/works/xzgl/OaMeetingCateController.php @@ -0,0 +1,108 @@ +dataLists(new OaMeetingCateLists()); + } + + + /** + * @notes 添加会议室管理 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/22 14:24 + */ + public function add() + { + $params = (new OaMeetingCateValidate())->post()->goCheck('add'); + $result = OaMeetingCateLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(OaMeetingCateLogic::getError()); + } + + + /** + * @notes 编辑会议室管理 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/22 14:24 + */ + public function edit() + { + $params = (new OaMeetingCateValidate())->post()->goCheck('edit'); + $result = OaMeetingCateLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(OaMeetingCateLogic::getError()); + } + + + /** + * @notes 删除会议室管理 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/22 14:24 + */ + public function delete() + { + $params = (new OaMeetingCateValidate())->post()->goCheck('delete'); + OaMeetingCateLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取会议室管理详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/22 14:24 + */ + public function detail() + { + $params = (new OaMeetingCateValidate())->goCheck('detail'); + $result = OaMeetingCateLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/works/xzgl/OaMeetingCateLists.php b/app/adminapi/lists/works/xzgl/OaMeetingCateLists.php new file mode 100644 index 000000000..098cf47b8 --- /dev/null +++ b/app/adminapi/lists/works/xzgl/OaMeetingCateLists.php @@ -0,0 +1,80 @@ + ['status'], + '%like%' => ['title'], + ]; + } + + + /** + * @notes 获取会议室管理列表 + * @return array + * @throws \think\db\exception\DataNotFoundException + * @throws \think\db\exception\DbException + * @throws \think\db\exception\ModelNotFoundException + * @author likeadmin + * @date 2024/05/22 14:24 + */ + public function lists(): array + { + return OaMeetingCate::where($this->searchWhere) + ->field(['id', 'title', 'status']) + ->limit($this->limitOffset, $this->limitLength) + ->order(['id' => 'desc']) + ->select()->each(function($data){ + $data['status_text'] = $data->status_text; + }) + ->toArray(); + } + + + /** + * @notes 获取会议室管理数量 + * @return int + * @author likeadmin + * @date 2024/05/22 14:24 + */ + public function count(): int + { + return OaMeetingCate::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/works/xzgl/OaMeetingCateLogic.php b/app/adminapi/logic/works/xzgl/OaMeetingCateLogic.php new file mode 100644 index 000000000..170acf842 --- /dev/null +++ b/app/adminapi/logic/works/xzgl/OaMeetingCateLogic.php @@ -0,0 +1,110 @@ + $params['title'], + 'status' => $params['status'] ?? 1 + ]); + + 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/05/22 14:24 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + OaMeetingCate::where('id', $params['id'])->update([ + 'title' => $params['title'], + 'status' => $params['status'] ?? 1 + ]); + + 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/05/22 14:24 + */ + public static function delete(array $params): bool + { + return OaMeetingCate::destroy($params['id']); + } + + + /** + * @notes 获取会议室管理详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/05/22 14:24 + */ + public static function detail($params): array + { + $data = OaMeetingCate::findOrEmpty($params['id']); + $data['status_text'] = $data->status_text; + return $data->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/validate/works/xzgl/OaCarCateValidate.php b/app/adminapi/validate/works/xzgl/OaCarCateValidate.php index 98a428fc2..cc3af0ecb 100644 --- a/app/adminapi/validate/works/xzgl/OaCarCateValidate.php +++ b/app/adminapi/validate/works/xzgl/OaCarCateValidate.php @@ -98,7 +98,7 @@ class OaCarCateValidate extends BaseValidate return $this->only(['id']); } - public function checkData($value,$rule,$data): bool|string + public function checkData($value): bool|string { $data = OaCarCate::field('id')->where('id',$value)->findOrEmpty(); return $data->isEmpty() ? '数据不存在' : true; diff --git a/app/adminapi/validate/works/xzgl/OaMeetingCateValidate.php b/app/adminapi/validate/works/xzgl/OaMeetingCateValidate.php new file mode 100644 index 000000000..32599ee9e --- /dev/null +++ b/app/adminapi/validate/works/xzgl/OaMeetingCateValidate.php @@ -0,0 +1,105 @@ + 'require|checkData', + 'title' => 'require', + 'status' => 'integer|in:0,1', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'title' => '会议室名称', + 'status' => '状态', + ]; + + + /** + * @notes 添加场景 + * @return OaMeetingCateValidate + * @author likeadmin + * @date 2024/05/22 14:24 + */ + public function sceneAdd() + { + return $this->only(['title','status']); + } + + + /** + * @notes 编辑场景 + * @return OaMeetingCateValidate + * @author likeadmin + * @date 2024/05/22 14:24 + */ + public function sceneEdit() + { + return $this->only(['id','title','status']); + } + + + /** + * @notes 删除场景 + * @return OaMeetingCateValidate + * @author likeadmin + * @date 2024/05/22 14:24 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return OaMeetingCateValidate + * @author likeadmin + * @date 2024/05/22 14:24 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkData($value): bool|string + { + $data = OaMeetingCate::field('id')->where('id',$value)->findOrEmpty(); + return $data->isEmpty() ? '数据不存在' : true; + } + +} \ No newline at end of file diff --git a/app/adminapi/validate/works/xzgl/OaSealCateValidate.php b/app/adminapi/validate/works/xzgl/OaSealCateValidate.php index 27da5cc9e..df169375c 100644 --- a/app/adminapi/validate/works/xzgl/OaSealCateValidate.php +++ b/app/adminapi/validate/works/xzgl/OaSealCateValidate.php @@ -96,7 +96,7 @@ class OaSealCateValidate extends BaseValidate return $this->only(['id']); } - public function checkData($value,$rule,$data): bool|string + public function checkData($value): bool|string { $data = OaSealCate::field('id')->where('id',$value)->findOrEmpty(); return $data->isEmpty() ? '数据不存在' : true; diff --git a/app/common/model/works/xzgl/OaMeetingCate.php b/app/common/model/works/xzgl/OaMeetingCate.php new file mode 100644 index 000000000..c716f340d --- /dev/null +++ b/app/common/model/works/xzgl/OaMeetingCate.php @@ -0,0 +1,38 @@ +'禁用', 1=>'启用']; + return $arr[$data['status']]; + } +} \ No newline at end of file