From bbdee9d7d7fcf8788a2adb05814ea38ca2c65d8c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?old=E6=98=93?= <156663459@qq.com> Date: Mon, 28 Jul 2025 14:25:09 +0800 Subject: [PATCH] ww --- mock-config.json | 109 +++++++++++++++++++++++++++++++++++++++++------ server.js | 10 +++++ 2 files changed, 107 insertions(+), 12 deletions(-) diff --git a/mock-config.json b/mock-config.json index 7c3e3d9..d3f290c 100644 --- a/mock-config.json +++ b/mock-config.json @@ -1333,6 +1333,7 @@ { "method": "GET", "path": "/api/nursing/hospital-companion/list", + "query": { "type": "1" }, "response": { "code": 200, "message": "ok", @@ -1374,20 +1375,10 @@ "image": "https://res.klyj.jinzejk.com/nursing/2h.png" } ] - }, "swagger": { + }, + "swagger": { "summary": "获取住院陪护详情", "description": "返回指定 ID 的住院陪护服务详情,包括服务名称、评分、价格、购买人数、图片等信息。", - "parameters": [ - { - "name": "id", - "in": "query", - "required": true, - "schema": { - "type": "integer" - }, - "description": "服务ID" - } - ], "responses": { "200": { "description": "返回住院陪护服务详情", @@ -1412,6 +1403,100 @@ } } }, +{ + "method": "GET", + "path": "/api/nursing/hospital-companion/list", + "query": { "type": "2" }, + "response": { + "services": [ + { + "id": "1", + "title": "住院陪护4小时", + "rating": 4.8, + "price": 120.0, + "unit": "起", + "purchasedCount": 73, + "image": "https://res.klyj.jinzejk.com/nursing/hospital1.png" + }, + { + "id": "2", + "title": "住院陪护8小时", + "rating": 4.8, + "price": 230.0, + "unit": "起", + "purchasedCount": 73, + "image": "https://res.klyj.jinzejk.com/nursing/hospital2.png" + } + ] + } +}, +{ + "method": "GET", + "path": "/api/nursing/hospital-companion/list", + "query": { + "type": "3" + }, + "response": { + "list": [ + { + "id": 1, + "title": "上门助浴2人", + "cover": "https://res.klyj.jinzejk.com/nursing/bathing/2.png", + "rating": 4.8, + "price": 120, + "unit": "起", + "purchasedCount": 73 + }, + { + "id": 2, + "title": "上门助浴4人", + "image": "https://res.klyj.jinzejk.com/nursing/bathing/4.png", + "rating": 4.8, + "price": 230, + "unit": "起", + "purchasedCount": 73 + } + ] + } +}, +{ + "method": "GET", + "path": "/api/nursing/hospital-companion/list", + "query": { + "type": "4" + }, + "response": { + "list": [ + { + "id": 1, + "title": "4小时陪诊", + "image": "https://res.klyj.jinzejk.com/nursing/4h.png", + "rating": 4.8, + "price": 120, + "unit": "起", + "purchasedCount": 73 + }, + { + "id": 2, + "title": "8小时陪诊", + "image": "https://res.klyj.jinzejk.com/nursing/8h.png", + "rating": 4.8, + "price": 230, + "unit": "起", + "purchasedCount": 73 + }, + { + "id": 3, + "title": "12小时陪诊", + "image": "https://res.klyj.jinzejk.com/nursing/12h.png", + "rating": 4.8, + "price": 230, + "unit": "起", + "purchasedCount": 73 + } + ] + } +}, { "method": "GET", "path": "/api/service/detail", diff --git a/server.js b/server.js index a50fdc1..6b3066f 100644 --- a/server.js +++ b/server.js @@ -42,6 +42,16 @@ function registerMockApi(config) { return res.json(formatResponse(defaultConfig.response)); } } + if (path === '/api/nursing/hospital-companion/list' && Object.keys(req.query).length === 0) { + const defaultConfig = global.mockConfigs.find(c => + c.path === path && c.query?.type === 'home' + ); + if (defaultConfig) { + console.log(`[MOCK] Fallback to default (home)`); + return res.json(formatResponse(defaultConfig.response)); + } + } + // 精确 query 匹配 if (query) {