whistle.mock-plugins 1.1.1-beta.8 → 1.1.1-dev.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -183,7 +183,6 @@ module.exports = function(req, res) {
183
183
  interfacesData.interfaces[index] = {
184
184
  ...interfacesData.interfaces[index],
185
185
  name: interfaceData.name,
186
- group: interfaceData.group !== undefined ? interfaceData.group : interfacesData.interfaces[index].group || '', // 添加分组字段
187
186
  urlPattern: interfaceData.urlPattern,
188
187
  proxyType: interfaceData.proxyType,
189
188
  responseContent: interfaceData.responseContent,
@@ -218,7 +217,6 @@ module.exports = function(req, res) {
218
217
  id: Date.now().toString(),
219
218
  featureId: interfaceData.featureId,
220
219
  name: interfaceData.name,
221
- group: interfaceData.group || '', // 添加分组字段
222
220
  urlPattern: interfaceData.urlPattern,
223
221
  proxyType: interfaceData.proxyType || 'response',
224
222
  responseContent: interfaceData.responseContent || '',
@@ -237,7 +235,6 @@ module.exports = function(req, res) {
237
235
 
238
236
  console.log('创建新接口,包含多响应数据:', {
239
237
  name: newInterface.name,
240
- group: newInterface.group, // 添加分组日志
241
238
  responsesCount: newInterface.responses.length,
242
239
  activeResponseId: newInterface.activeResponseId
243
240
  });
@@ -346,7 +343,6 @@ module.exports = function(req, res) {
346
343
  const updatedInterface = {
347
344
  ...interfacesData.interfaces[index],
348
345
  name: interfaceData.name || interfacesData.interfaces[index].name,
349
- group: interfaceData.group !== undefined ? interfaceData.group : interfacesData.interfaces[index].group || '', // 添加分组字段
350
346
  urlPattern: interfaceData.urlPattern || interfacesData.interfaces[index].urlPattern,
351
347
  proxyType: interfaceData.proxyType || interfacesData.interfaces[index].proxyType,
352
348
  responseContent: interfaceData.responseContent !== undefined ? interfaceData.responseContent : interfacesData.interfaces[index].responseContent,
@@ -366,7 +362,6 @@ module.exports = function(req, res) {
366
362
 
367
363
  console.log('PUT更新接口,包含多响应数据:', {
368
364
  name: updatedInterface.name,
369
- group: updatedInterface.group, // 添加分组日志
370
365
  responsesCount: updatedInterface.responses.length,
371
366
  activeResponseId: updatedInterface.activeResponseId
372
367
  });
@@ -383,9 +378,17 @@ module.exports = function(req, res) {
383
378
 
384
379
  // 处理 PATCH 请求 - 部分更新接口(如启用/禁用状态)
385
380
  if (req.method === 'PATCH') {
386
- const { id, active } = req.query;
381
+ const { id } = req.query;
387
382
  const patchData = req.body;
388
383
 
384
+ if (!id) {
385
+ return res.status(400).json({
386
+ code: 400,
387
+ message: '接口ID不能为空',
388
+ data: null
389
+ });
390
+ }
391
+
389
392
  // 读取接口数据
390
393
  let interfacesData;
391
394
  try {
@@ -402,70 +405,6 @@ module.exports = function(req, res) {
402
405
  });
403
406
  }
404
407
 
405
- // 批量更新接口状态
406
- if (active !== undefined) {
407
- const { featureId, group } = patchData;
408
-
409
- if (!featureId) {
410
- return res.status(400).json({
411
- code: 400,
412
- message: '功能ID不能为空',
413
- data: null
414
- });
415
- }
416
-
417
- // 根据分组筛选要更新的接口
418
- let updatedCount = 0;
419
- interfacesData.interfaces = interfacesData.interfaces.map(item => {
420
- // 只更新指定功能模块下的接口
421
- if (item.featureId !== featureId) {
422
- return item;
423
- }
424
-
425
- // 如果指定了分组,只更新该分组下的接口
426
- if (group && item.group !== group) {
427
- return item;
428
- }
429
-
430
- // 更新接口状态
431
- const isActive = active === 'true';
432
- if (item.active !== isActive) {
433
- updatedCount++;
434
- return {
435
- ...item,
436
- active: isActive,
437
- updatedAt: new Date().toISOString()
438
- };
439
- }
440
-
441
- return item;
442
- });
443
-
444
- // 保存更新后的接口列表
445
- fs.writeJsonSync(interfacesFile, interfacesData, { spaces: 2 });
446
-
447
- console.log(`批量${active === 'true' ? '启用' : '禁用'}接口:`, {
448
- featureId,
449
- group,
450
- updatedCount
451
- });
452
-
453
- return res.json({
454
- code: 0,
455
- message: `成功${active === 'true' ? '启用' : '禁用'} ${updatedCount} 个接口`,
456
- data: { updatedCount }
457
- });
458
- }
459
-
460
- // 单个接口更新
461
- if (!id) {
462
- return res.status(400).json({
463
- code: 400,
464
- message: '接口ID不能为空',
465
- data: null
466
- });
467
- }
468
-
469
408
  // 查找接口
470
409
  const index = interfacesData.interfaces.findIndex(item => item.id === id);
471
410