diff --git a/app/adminapi/controller/works/xzgl/OaCarCateController.php b/app/adminapi/controller/works/xzgl/OaCarCateController.php new file mode 100644 index 000000000..00fff3bec --- /dev/null +++ b/app/adminapi/controller/works/xzgl/OaCarCateController.php @@ -0,0 +1,108 @@ +dataLists(new OaCarCateLists()); + } + + + /** + * @notes 添加车辆管理 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/22 14:02 + */ + public function add() + { + $params = (new OaCarCateValidate())->post()->goCheck('add'); + $result = OaCarCateLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(OaCarCateLogic::getError()); + } + + + /** + * @notes 编辑车辆管理 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/22 14:02 + */ + public function edit() + { + $params = (new OaCarCateValidate())->post()->goCheck('edit'); + $result = OaCarCateLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(OaCarCateLogic::getError()); + } + + + /** + * @notes 删除车辆管理 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/22 14:02 + */ + public function delete() + { + $params = (new OaCarCateValidate())->post()->goCheck('delete'); + OaCarCateLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取车辆管理详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/22 14:02 + */ + public function detail() + { + $params = (new OaCarCateValidate())->goCheck('detail'); + $result = OaCarCateLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/controller/works/xzgl/OaSealCateController.php b/app/adminapi/controller/works/xzgl/OaSealCateController.php new file mode 100644 index 000000000..3937cc1f2 --- /dev/null +++ b/app/adminapi/controller/works/xzgl/OaSealCateController.php @@ -0,0 +1,108 @@ +dataLists(new OaSealCateLists()); + } + + + /** + * @notes 添加 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/22 11:53 + */ + public function add() + { + $params = (new OaSealCateValidate())->post()->goCheck('add'); + $result = OaSealCateLogic::add($params); + if (true === $result) { + return $this->success('添加成功', [], 1, 1); + } + return $this->fail(OaSealCateLogic::getError()); + } + + + /** + * @notes 编辑 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/22 11:53 + */ + public function edit() + { + $params = (new OaSealCateValidate())->post()->goCheck('edit'); + $result = OaSealCateLogic::edit($params); + if (true === $result) { + return $this->success('编辑成功', [], 1, 1); + } + return $this->fail(OaSealCateLogic::getError()); + } + + + /** + * @notes 删除 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/22 11:53 + */ + public function delete() + { + $params = (new OaSealCateValidate())->post()->goCheck('delete'); + OaSealCateLogic::delete($params); + return $this->success('删除成功', [], 1, 1); + } + + + /** + * @notes 获取详情 + * @return \think\response\Json + * @author likeadmin + * @date 2024/05/22 11:53 + */ + public function detail() + { + $params = (new OaSealCateValidate())->goCheck('detail'); + $result = OaSealCateLogic::detail($params); + return $this->data($result); + } + + +} \ No newline at end of file diff --git a/app/adminapi/lists/works/xzgl/OaCarCateLists.php b/app/adminapi/lists/works/xzgl/OaCarCateLists.php new file mode 100644 index 000000000..04e1c8bc3 --- /dev/null +++ b/app/adminapi/lists/works/xzgl/OaCarCateLists.php @@ -0,0 +1,80 @@ + ['status'], + '%like%' => ['title', 'name'], + ]; + } + + + /** + * @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:02 + */ + public function lists(): array + { + return OaCarCate::where($this->searchWhere) + ->field(['id', 'title', 'name', '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:02 + */ + public function count(): int + { + return OaCarCate::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/lists/works/xzgl/OaSealCateLists.php b/app/adminapi/lists/works/xzgl/OaSealCateLists.php new file mode 100644 index 000000000..fbe8204e9 --- /dev/null +++ b/app/adminapi/lists/works/xzgl/OaSealCateLists.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 11:53 + */ + public function lists(): array + { + return OaSealCate::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 11:53 + */ + public function count(): int + { + return OaSealCate::where($this->searchWhere)->count(); + } + +} \ No newline at end of file diff --git a/app/adminapi/logic/works/xzgl/OaCarCateLogic.php b/app/adminapi/logic/works/xzgl/OaCarCateLogic.php new file mode 100644 index 000000000..09015d1f1 --- /dev/null +++ b/app/adminapi/logic/works/xzgl/OaCarCateLogic.php @@ -0,0 +1,112 @@ + $params['title'], + 'name' => $params['name'], + '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:02 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + OaCarCate::where('id', $params['id'])->update([ + 'title' => $params['title'], + 'name' => $params['name'], + '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:02 + */ + public static function delete(array $params): bool + { + return OaCarCate::destroy($params['id']); + } + + + /** + * @notes 获取车辆管理详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/05/22 14:02 + */ + public static function detail($params): array + { + $data = OaCarCate::findOrEmpty($params['id']); + $data['status_text'] = $data->status_text; + return $data->toArray(); + } +} \ No newline at end of file diff --git a/app/adminapi/logic/works/xzgl/OaSealCateLogic.php b/app/adminapi/logic/works/xzgl/OaSealCateLogic.php new file mode 100644 index 000000000..f0a9e4f23 --- /dev/null +++ b/app/adminapi/logic/works/xzgl/OaSealCateLogic.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 11:53 + */ + public static function edit(array $params): bool + { + Db::startTrans(); + try { + OaSealCate::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 11:53 + */ + public static function delete(array $params): bool + { + return OaSealCate::destroy($params['id']); + } + + + /** + * @notes 获取详情 + * @param $params + * @return array + * @author likeadmin + * @date 2024/05/22 11:53 + */ + public static function detail($params): array + { + $data = OaSealCate::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 new file mode 100644 index 000000000..98a428fc2 --- /dev/null +++ b/app/adminapi/validate/works/xzgl/OaCarCateValidate.php @@ -0,0 +1,107 @@ + 'require|checkData', + 'title' => 'require', + 'name' => 'require', + 'status' => 'integer|in:0,1', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'title' => '车辆名称', + 'name' => '车辆号码', + 'status' => '状态', + ]; + + + /** + * @notes 添加场景 + * @return OaCarCateValidate + * @author likeadmin + * @date 2024/05/22 14:02 + */ + public function sceneAdd() + { + return $this->only(['title','name','status']); + } + + + /** + * @notes 编辑场景 + * @return OaCarCateValidate + * @author likeadmin + * @date 2024/05/22 14:02 + */ + public function sceneEdit() + { + return $this->only(['id','title','name','status']); + } + + + /** + * @notes 删除场景 + * @return OaCarCateValidate + * @author likeadmin + * @date 2024/05/22 14:02 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return OaCarCateValidate + * @author likeadmin + * @date 2024/05/22 14:02 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkData($value,$rule,$data): bool|string + { + $data = OaCarCate::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 new file mode 100644 index 000000000..27da5cc9e --- /dev/null +++ b/app/adminapi/validate/works/xzgl/OaSealCateValidate.php @@ -0,0 +1,105 @@ + 'require|checkData', + 'title' => 'require', + 'status' => 'integer|in:0,1', + ]; + + + /** + * 参数描述 + * @var string[] + */ + protected $field = [ + 'id' => 'id', + 'title' => '印章类型名称', + 'status' => '状态', + ]; + + + /** + * @notes 添加场景 + * @return OaSealCateValidate + * @author likeadmin + * @date 2024/05/22 11:53 + */ + public function sceneAdd() + { + return $this->only(['title','status']); + } + + + /** + * @notes 编辑场景 + * @return OaSealCateValidate + * @author likeadmin + * @date 2024/05/22 11:53 + */ + public function sceneEdit() + { + return $this->only(['id','title','status']); + } + + + /** + * @notes 删除场景 + * @return OaSealCateValidate + * @author likeadmin + * @date 2024/05/22 11:53 + */ + public function sceneDelete() + { + return $this->only(['id']); + } + + + /** + * @notes 详情场景 + * @return OaSealCateValidate + * @author likeadmin + * @date 2024/05/22 11:53 + */ + public function sceneDetail() + { + return $this->only(['id']); + } + + public function checkData($value,$rule,$data): bool|string + { + $data = OaSealCate::field('id')->where('id',$value)->findOrEmpty(); + return $data->isEmpty() ? '数据不存在' : true; + } + +} \ No newline at end of file diff --git a/app/common/model/works/xzgl/OaCarCate.php b/app/common/model/works/xzgl/OaCarCate.php new file mode 100644 index 000000000..73f4cb199 --- /dev/null +++ b/app/common/model/works/xzgl/OaCarCate.php @@ -0,0 +1,38 @@ +'禁用', 1=>'启用']; + return $arr[$data['status']]; + } +} \ No newline at end of file diff --git a/app/common/model/works/xzgl/OaSealCate.php b/app/common/model/works/xzgl/OaSealCate.php new file mode 100644 index 000000000..965509aab --- /dev/null +++ b/app/common/model/works/xzgl/OaSealCate.php @@ -0,0 +1,38 @@ +'禁用', 1=>'启用']; + return $arr[$data['status']]; + } +} \ No newline at end of file