From 179a90d23b8e8b66e77ea7c9a2cbd1627f9e361f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=B3=E6=B8=85=E7=88=BD?= Date: Thu, 3 Apr 2025 17:52:30 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=A1=E5=88=92=E4=BB=BB=E5=8A=A1=20-=20?= =?UTF-8?q?=E8=8E=B7=E5=AE=A2=E5=9C=BA=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Server/application/plan/config/route.php | 15 ++++ Server/application/plan/controller/Scene.php | 67 +++++++++++++++++ Server/application/plan/model/PlanScene.php | 75 ++++++++++++++++++++ Server/route/route.php | 3 + 4 files changed, 160 insertions(+) create mode 100644 Server/application/plan/config/route.php create mode 100644 Server/application/plan/controller/Scene.php create mode 100644 Server/application/plan/model/PlanScene.php diff --git a/Server/application/plan/config/route.php b/Server/application/plan/config/route.php new file mode 100644 index 00000000..f315dded --- /dev/null +++ b/Server/application/plan/config/route.php @@ -0,0 +1,15 @@ +middleware(['jwt']); \ No newline at end of file diff --git a/Server/application/plan/controller/Scene.php b/Server/application/plan/controller/Scene.php new file mode 100644 index 00000000..e9897986 --- /dev/null +++ b/Server/application/plan/controller/Scene.php @@ -0,0 +1,67 @@ + 200, + 'msg' => '获取成功', + 'data' => $result + ]); + } + + /** + * 获取单个场景详情 + * + * @param int $id 场景ID + * @return \think\response\Json + */ + public function read($id) + { + // 查询场景信息 + $scene = PlanScene::getSceneInfo($id); + + if (!$scene) { + return json([ + 'code' => 404, + 'msg' => '场景不存在' + ]); + } + + return json([ + 'code' => 200, + 'msg' => '获取成功', + 'data' => $scene + ]); + } +} \ No newline at end of file diff --git a/Server/application/plan/model/PlanScene.php b/Server/application/plan/model/PlanScene.php new file mode 100644 index 00000000..de84e9e0 --- /dev/null +++ b/Server/application/plan/model/PlanScene.php @@ -0,0 +1,75 @@ + 'integer', + 'status' => 'integer', + 'createTime' => 'integer', + 'updateTime' => 'integer', + 'deleteTime' => 'integer' + ]; + + /** + * 获取场景列表 + * + * @param array $where 查询条件 + * @param string $order 排序 + * @param int $page 页码 + * @param int $limit 每页数量 + * @return array 场景列表和总数 + */ + public static function getSceneList($where = [], $order = 'id desc', $page = 1, $limit = 10) + { + // 构建查询 + $query = self::where($where); + + // 计算总数 + $total = $query->count(); + + // 分页查询数据 + $list = $query->page($page, $limit) + ->order($order) + ->select(); + + return [ + 'list' => $list, + 'total' => $total, + 'page' => $page, + 'limit' => $limit + ]; + } + + /** + * 获取单个场景信息 + * + * @param int $id 场景ID + * @return array|null 场景信息 + */ + public static function getSceneInfo($id) + { + return self::where('id', $id)->find(); + } +} \ No newline at end of file diff --git a/Server/route/route.php b/Server/route/route.php index 2d9bc7a3..9589acf2 100755 --- a/Server/route/route.php +++ b/Server/route/route.php @@ -27,4 +27,7 @@ include __DIR__ . '/../application/store/config/route.php'; // 加载CozeAI模块路由配置 include __DIR__ . '/../application/cozeai/config/route.php'; +// 加载Plan模块路由配置 +include __DIR__ . '/../application/plan/config/route.php'; + return [];