@zzp123/mcp-zentao 1.18.2 → 1.18.4
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.
- package/CHANGELOG.md +48 -0
- package/README.md +39 -0
- package/dist/api/zentaoApi.js +1 -266
- package/dist/config.js +1 -1
- package/dist/index-dev.js +4 -23
- package/dist/index-pm.js +70 -85
- package/dist/index-qa.js +1 -23
- package/dist/index.js +74 -130
- package/dist/mcpHelpers.d.ts +13 -0
- package/dist/mcpHelpers.js +24 -0
- package/package.json +1 -1
package/dist/api/zentaoApi.js
CHANGED
|
@@ -18,13 +18,10 @@ export class ZentaoAPI {
|
|
|
18
18
|
.update(this.config.password)
|
|
19
19
|
.digest('hex');
|
|
20
20
|
try {
|
|
21
|
-
console.log('正在请求token...');
|
|
22
|
-
console.log('请求URL:', `${this.config.url}/api.php/${this.config.apiVersion}/tokens`);
|
|
23
21
|
const response = await this.client.post('/tokens', {
|
|
24
22
|
account: this.config.username,
|
|
25
23
|
password,
|
|
26
24
|
});
|
|
27
|
-
console.log('服务器响应:', response.data);
|
|
28
25
|
if (response.status === 200 || response.status === 201) {
|
|
29
26
|
if (typeof response.data === 'object' && response.data.token) {
|
|
30
27
|
this.token = response.data.token;
|
|
@@ -47,7 +44,6 @@ export class ZentaoAPI {
|
|
|
47
44
|
async request(method, url, params, data) {
|
|
48
45
|
const token = await this.getToken();
|
|
49
46
|
try {
|
|
50
|
-
console.log(`正在请求 ${method} ${url}`, { params, data });
|
|
51
47
|
const response = await this.client.request({
|
|
52
48
|
method,
|
|
53
49
|
url,
|
|
@@ -55,17 +51,10 @@ export class ZentaoAPI {
|
|
|
55
51
|
data,
|
|
56
52
|
headers: { Token: token },
|
|
57
53
|
});
|
|
58
|
-
console.log(`响应状态码: ${response.status}`);
|
|
59
|
-
console.log('响应数据:', response.data);
|
|
60
54
|
return response.data;
|
|
61
55
|
}
|
|
62
56
|
catch (error) {
|
|
63
57
|
if (axios.isAxiosError(error)) {
|
|
64
|
-
console.error('请求失败:', {
|
|
65
|
-
status: error.response?.status,
|
|
66
|
-
data: error.response?.data,
|
|
67
|
-
message: error.message
|
|
68
|
-
});
|
|
69
58
|
throw new Error(`请求失败: ${error.response?.data?.message || error.message}`);
|
|
70
59
|
}
|
|
71
60
|
throw error;
|
|
@@ -81,13 +70,10 @@ export class ZentaoAPI {
|
|
|
81
70
|
}
|
|
82
71
|
async getTaskDetail(taskId) {
|
|
83
72
|
try {
|
|
84
|
-
console.log(`正在获取任务 ${taskId} 的详情...`);
|
|
85
73
|
const response = await this.request('GET', `/tasks/${taskId}`);
|
|
86
|
-
console.log('任务详情响应:', response);
|
|
87
74
|
return response;
|
|
88
75
|
}
|
|
89
76
|
catch (error) {
|
|
90
|
-
console.error('获取任务详情失败:', error);
|
|
91
77
|
throw error;
|
|
92
78
|
}
|
|
93
79
|
}
|
|
@@ -164,9 +150,7 @@ export class ZentaoAPI {
|
|
|
164
150
|
async getProducts(fields) {
|
|
165
151
|
try {
|
|
166
152
|
const finalFields = fields || 'default';
|
|
167
|
-
console.log(`正在获取产品列表 (fields=${finalFields})...`);
|
|
168
153
|
const response = await this.request('GET', '/products');
|
|
169
|
-
console.log('产品列表响应:', response);
|
|
170
154
|
let products = [];
|
|
171
155
|
if (Array.isArray(response)) {
|
|
172
156
|
products = response;
|
|
@@ -182,7 +166,6 @@ export class ZentaoAPI {
|
|
|
182
166
|
return filteredProducts;
|
|
183
167
|
}
|
|
184
168
|
catch (error) {
|
|
185
|
-
console.error('获取产品列表失败:', error);
|
|
186
169
|
throw error;
|
|
187
170
|
}
|
|
188
171
|
}
|
|
@@ -253,7 +236,6 @@ export class ZentaoAPI {
|
|
|
253
236
|
}
|
|
254
237
|
// 使用第二个产品(如果存在),否则使用第一个
|
|
255
238
|
productId = products.length > 1 ? products[1].id : products[0].id;
|
|
256
|
-
console.log(`使用产品ID: ${productId} (${products.length > 1 ? '第二个' : '第一个'})`);
|
|
257
239
|
}
|
|
258
240
|
// 固定每页20条
|
|
259
241
|
const finalLimit = 20;
|
|
@@ -272,9 +254,7 @@ export class ZentaoAPI {
|
|
|
272
254
|
// 固定添加状态筛选:只查询指派给我的 Bug
|
|
273
255
|
queryParams.append('status', finalStatus);
|
|
274
256
|
try {
|
|
275
|
-
console.log(`正在获取产品 ${productId} 的Bug列表,参数: status=${finalStatus}, branch=${finalBranch}, page=${finalPage}, limit=${finalLimit}, order=${finalOrder}, fields=${finalFields}`);
|
|
276
257
|
const response = await this.request('GET', `/products/${productId}/bugs?${queryParams.toString()}`);
|
|
277
|
-
console.log(`Bug列表响应: 获取到 ${response.bugs?.length || 0} 条数据`);
|
|
278
258
|
let bugs = [];
|
|
279
259
|
if (Array.isArray(response)) {
|
|
280
260
|
bugs = response;
|
|
@@ -305,7 +285,6 @@ export class ZentaoAPI {
|
|
|
305
285
|
}
|
|
306
286
|
}
|
|
307
287
|
catch (error) {
|
|
308
|
-
console.error('获取Bug列表失败:', error);
|
|
309
288
|
throw error;
|
|
310
289
|
}
|
|
311
290
|
}
|
|
@@ -329,7 +308,6 @@ export class ZentaoAPI {
|
|
|
329
308
|
const finalBranch = branch || 'all';
|
|
330
309
|
const finalOrder = order || 'id_desc';
|
|
331
310
|
const finalFields = fields || 'basic';
|
|
332
|
-
console.log(`正在获取产品 ${productId} 的Bug列表 (status=${status || 'all'}, branch=${finalBranch}, page=${finalPage}, limit=${finalLimit}, order=${finalOrder}, fields=${finalFields})...`);
|
|
333
311
|
// 构建查询参数
|
|
334
312
|
const queryParams = new URLSearchParams();
|
|
335
313
|
queryParams.append('branch', finalBranch);
|
|
@@ -341,7 +319,6 @@ export class ZentaoAPI {
|
|
|
341
319
|
queryParams.append('status', status);
|
|
342
320
|
}
|
|
343
321
|
const response = await this.request('GET', `/products/${productId}/bugs?${queryParams.toString()}`);
|
|
344
|
-
console.log(`产品Bug列表响应: 获取到 ${response.bugs?.length || 0} 条数据`);
|
|
345
322
|
let bugs = [];
|
|
346
323
|
if (Array.isArray(response)) {
|
|
347
324
|
bugs = response;
|
|
@@ -372,15 +349,12 @@ export class ZentaoAPI {
|
|
|
372
349
|
}
|
|
373
350
|
}
|
|
374
351
|
catch (error) {
|
|
375
|
-
console.error('获取产品Bug列表失败:', error);
|
|
376
352
|
throw error;
|
|
377
353
|
}
|
|
378
354
|
}
|
|
379
355
|
async getBugDetail(bugId, fields) {
|
|
380
356
|
try {
|
|
381
|
-
console.log(`正在获取Bug ${bugId} 的详情 (fields=${fields || 'full'})...`);
|
|
382
357
|
const response = await this.request('GET', `/bugs/${bugId}`);
|
|
383
|
-
console.log('Bug详情响应:', response);
|
|
384
358
|
// 根据 fields 参数过滤返回的字段
|
|
385
359
|
const fieldLevel = fields || 'full';
|
|
386
360
|
if (fieldLevel === 'basic') {
|
|
@@ -411,48 +385,39 @@ export class ZentaoAPI {
|
|
|
411
385
|
}
|
|
412
386
|
}
|
|
413
387
|
catch (error) {
|
|
414
|
-
console.error('获取Bug详情失败:', error);
|
|
415
388
|
throw error;
|
|
416
389
|
}
|
|
417
390
|
}
|
|
418
391
|
async resolveBug(bugId, resolution) {
|
|
419
392
|
try {
|
|
420
|
-
console.log(`正在解决Bug ${bugId}...`);
|
|
421
393
|
// 验证必填字段并设置默认值
|
|
422
394
|
if (resolution.resolution === 'fixed' && !resolution.resolvedBuild) {
|
|
423
|
-
console.log('解决方案为"fixed"时未提供resolvedBuild,自动设置为"trunk"');
|
|
424
395
|
resolution.resolvedBuild = 'trunk';
|
|
425
396
|
}
|
|
426
397
|
if (resolution.resolution === 'duplicate' && !resolution.duplicateBug) {
|
|
427
398
|
throw new Error('当解决方案为"重复Bug(duplicate)"时,必须提供重复Bug的ID(duplicateBug)');
|
|
428
399
|
}
|
|
429
400
|
const response = await this.request('POST', `/bugs/${bugId}/resolve`, undefined, resolution);
|
|
430
|
-
console.log('Bug解决响应:', response);
|
|
431
401
|
return response;
|
|
432
402
|
}
|
|
433
403
|
catch (error) {
|
|
434
|
-
console.error('解决Bug失败:', error);
|
|
435
404
|
throw error;
|
|
436
405
|
}
|
|
437
406
|
}
|
|
438
407
|
async updateTask(taskId, update) {
|
|
439
408
|
try {
|
|
440
|
-
console.log(`正在更新任务 ${taskId}...`);
|
|
441
409
|
const response = await this.request('PUT', `/tasks/${taskId}`, undefined, {
|
|
442
410
|
...update,
|
|
443
411
|
assignedTo: this.config.username,
|
|
444
412
|
});
|
|
445
|
-
console.log('任务更新响应:', response);
|
|
446
413
|
return response;
|
|
447
414
|
}
|
|
448
415
|
catch (error) {
|
|
449
|
-
console.error('更新任务失败:', error);
|
|
450
416
|
throw error;
|
|
451
417
|
}
|
|
452
418
|
}
|
|
453
419
|
async finishTask(taskId, update = {}) {
|
|
454
420
|
try {
|
|
455
|
-
console.log(`正在完成任务 ${taskId}...`);
|
|
456
421
|
const finalUpdate = {
|
|
457
422
|
status: 'done',
|
|
458
423
|
finishedDate: new Date().toISOString(),
|
|
@@ -461,13 +426,11 @@ export class ZentaoAPI {
|
|
|
461
426
|
return await this.updateTask(taskId, finalUpdate);
|
|
462
427
|
}
|
|
463
428
|
catch (error) {
|
|
464
|
-
console.error('完成任务失败:', error);
|
|
465
429
|
throw error;
|
|
466
430
|
}
|
|
467
431
|
}
|
|
468
432
|
async createTask(task) {
|
|
469
433
|
try {
|
|
470
|
-
console.log('正在创建新任务...');
|
|
471
434
|
if (!task.execution) {
|
|
472
435
|
throw new Error('创建任务需要指定执行ID');
|
|
473
436
|
}
|
|
@@ -488,20 +451,16 @@ export class ZentaoAPI {
|
|
|
488
451
|
});
|
|
489
452
|
// 在URL中添加执行ID
|
|
490
453
|
const response = await this.request('POST', `/executions/${task.execution}/tasks`, undefined, formData);
|
|
491
|
-
console.log('创建任务响应:', response);
|
|
492
454
|
return response;
|
|
493
455
|
}
|
|
494
456
|
catch (error) {
|
|
495
|
-
console.error('创建任务失败:', error);
|
|
496
457
|
throw error;
|
|
497
458
|
}
|
|
498
459
|
}
|
|
499
460
|
async getPrograms(order) {
|
|
500
461
|
try {
|
|
501
|
-
console.log('正在获取项目集列表...');
|
|
502
462
|
const params = order ? { order } : undefined;
|
|
503
463
|
const response = await this.request('GET', '/programs', params);
|
|
504
|
-
console.log('项目集列表响应:', response);
|
|
505
464
|
if (Array.isArray(response)) {
|
|
506
465
|
return response;
|
|
507
466
|
}
|
|
@@ -513,13 +472,11 @@ export class ZentaoAPI {
|
|
|
513
472
|
throw new Error(`获取项目集列表失败: 响应格式不正确 ${JSON.stringify(response)}`);
|
|
514
473
|
}
|
|
515
474
|
catch (error) {
|
|
516
|
-
console.error('获取项目集列表失败:', error);
|
|
517
475
|
throw error;
|
|
518
476
|
}
|
|
519
477
|
}
|
|
520
478
|
async getProductPlans(productId, branch, begin, end, status, parent) {
|
|
521
479
|
try {
|
|
522
|
-
console.log(`正在获取产品 ${productId} 的计划列表...`);
|
|
523
480
|
const data = {};
|
|
524
481
|
if (branch !== undefined)
|
|
525
482
|
data.branch = branch;
|
|
@@ -532,7 +489,6 @@ export class ZentaoAPI {
|
|
|
532
489
|
if (parent !== undefined)
|
|
533
490
|
data.parent = parent;
|
|
534
491
|
const response = await this.request('POST', `/products/${productId}/plans`, undefined, data);
|
|
535
|
-
console.log('产品计划列表响应:', response);
|
|
536
492
|
if (Array.isArray(response)) {
|
|
537
493
|
return response;
|
|
538
494
|
}
|
|
@@ -544,119 +500,92 @@ export class ZentaoAPI {
|
|
|
544
500
|
throw new Error(`获取产品计划列表失败: 响应格式不正确 ${JSON.stringify(response)}`);
|
|
545
501
|
}
|
|
546
502
|
catch (error) {
|
|
547
|
-
console.error('获取产品计划列表失败:', error);
|
|
548
503
|
throw error;
|
|
549
504
|
}
|
|
550
505
|
}
|
|
551
506
|
async createStory(story) {
|
|
552
507
|
try {
|
|
553
|
-
console.log('正在创建新需求...');
|
|
554
508
|
const response = await this.request('POST', '/stories', undefined, story);
|
|
555
|
-
console.log('创建需求响应:', response);
|
|
556
509
|
return response;
|
|
557
510
|
}
|
|
558
511
|
catch (error) {
|
|
559
|
-
console.error('创建需求失败:', error);
|
|
560
512
|
throw error;
|
|
561
513
|
}
|
|
562
514
|
}
|
|
563
515
|
async getPlanDetail(planId) {
|
|
564
516
|
try {
|
|
565
|
-
console.log(`正在获取计划 ${planId} 的详情...`);
|
|
566
517
|
const response = await this.request('GET', `/productplans/${planId}`);
|
|
567
|
-
console.log('计划详情响应:', response);
|
|
568
518
|
return response;
|
|
569
519
|
}
|
|
570
520
|
catch (error) {
|
|
571
|
-
console.error('获取计划详情失败:', error);
|
|
572
521
|
throw error;
|
|
573
522
|
}
|
|
574
523
|
}
|
|
575
524
|
async updatePlan(planId, update) {
|
|
576
525
|
try {
|
|
577
|
-
console.log(`正在更新计划 ${planId}...`);
|
|
578
526
|
const response = await this.request('PUT', `/products/plans/${planId}`, undefined, update);
|
|
579
|
-
console.log('更新计划响应:', response);
|
|
580
527
|
return response;
|
|
581
528
|
}
|
|
582
529
|
catch (error) {
|
|
583
|
-
console.error('更新计划失败:', error);
|
|
584
530
|
throw error;
|
|
585
531
|
}
|
|
586
532
|
}
|
|
587
533
|
async deletePlan(planId) {
|
|
588
534
|
try {
|
|
589
|
-
console.log(`正在删除计划 ${planId}...`);
|
|
590
535
|
const response = await this.request('DELETE', `/products/plans/${planId}`);
|
|
591
|
-
console.log('删除计划响应:', response);
|
|
592
536
|
return response;
|
|
593
537
|
}
|
|
594
538
|
catch (error) {
|
|
595
|
-
console.error('删除计划失败:', error);
|
|
596
539
|
throw error;
|
|
597
540
|
}
|
|
598
541
|
}
|
|
599
542
|
async linkStoriesToPlan(planId, storyIds) {
|
|
600
543
|
try {
|
|
601
|
-
console.log(`正在为计划 ${planId} 关联需求...`);
|
|
602
544
|
const response = await this.request('POST', `/productplans/${planId}/linkstories`, undefined, {
|
|
603
545
|
stories: storyIds
|
|
604
546
|
});
|
|
605
|
-
console.log('关联需求响应:', response);
|
|
606
547
|
return response;
|
|
607
548
|
}
|
|
608
549
|
catch (error) {
|
|
609
|
-
console.error('关联需求失败:', error);
|
|
610
550
|
throw error;
|
|
611
551
|
}
|
|
612
552
|
}
|
|
613
553
|
async unlinkStoriesFromPlan(planId, storyIds) {
|
|
614
554
|
try {
|
|
615
|
-
console.log(`正在为计划 ${planId} 取消关联需求...`);
|
|
616
555
|
const response = await this.request('POST', `/productplans/${planId}/unlinkstories`, undefined, {
|
|
617
556
|
stories: storyIds
|
|
618
557
|
});
|
|
619
|
-
console.log('取消关联需求响应:', response);
|
|
620
558
|
return response;
|
|
621
559
|
}
|
|
622
560
|
catch (error) {
|
|
623
|
-
console.error('取消关联需求失败:', error);
|
|
624
561
|
throw error;
|
|
625
562
|
}
|
|
626
563
|
}
|
|
627
564
|
async linkBugsToPlan(planId, bugIds) {
|
|
628
565
|
try {
|
|
629
|
-
console.log(`正在为计划 ${planId} 关联Bug...`);
|
|
630
566
|
const response = await this.request('POST', `/products/${planId}/linkBugs`, undefined, {
|
|
631
567
|
bugs: bugIds
|
|
632
568
|
});
|
|
633
|
-
console.log('关联Bug响应:', response);
|
|
634
569
|
return response;
|
|
635
570
|
}
|
|
636
571
|
catch (error) {
|
|
637
|
-
console.error('关联Bug失败:', error);
|
|
638
572
|
throw error;
|
|
639
573
|
}
|
|
640
574
|
}
|
|
641
575
|
async unlinkBugsFromPlan(planId, bugIds) {
|
|
642
576
|
try {
|
|
643
|
-
console.log(`正在为计划 ${planId} 取消关联Bug...`);
|
|
644
577
|
const response = await this.request('POST', `/productplans/${planId}/unlinkbugs`, undefined, {
|
|
645
578
|
bugs: bugIds
|
|
646
579
|
});
|
|
647
|
-
console.log('取消关联Bug响应:', response);
|
|
648
580
|
return response;
|
|
649
581
|
}
|
|
650
582
|
catch (error) {
|
|
651
|
-
console.error('取消关联Bug失败:', error);
|
|
652
583
|
throw error;
|
|
653
584
|
}
|
|
654
585
|
}
|
|
655
586
|
async getProjectReleases(projectId) {
|
|
656
587
|
try {
|
|
657
|
-
console.log(`正在获取项目 ${projectId} 的发布列表...`);
|
|
658
588
|
const response = await this.request('GET', `/projects/${projectId}/releases`);
|
|
659
|
-
console.log('发布列表响应:', response);
|
|
660
589
|
if (Array.isArray(response)) {
|
|
661
590
|
return response;
|
|
662
591
|
}
|
|
@@ -668,15 +597,12 @@ export class ZentaoAPI {
|
|
|
668
597
|
throw new Error(`获取发布列表失败: 响应格式不正确 ${JSON.stringify(response)}`);
|
|
669
598
|
}
|
|
670
599
|
catch (error) {
|
|
671
|
-
console.error('获取发布列表失败:', error);
|
|
672
600
|
throw error;
|
|
673
601
|
}
|
|
674
602
|
}
|
|
675
603
|
async getStoryDetail(storyId, fields) {
|
|
676
604
|
try {
|
|
677
|
-
console.log(`正在获取需求 ${storyId} 的详情 (fields=${fields || 'full'})...`);
|
|
678
605
|
const response = await this.request('GET', `/stories/${storyId}`);
|
|
679
|
-
console.log('需求详情响应:', response);
|
|
680
606
|
// 根据 fields 参数过滤返回的字段
|
|
681
607
|
const fieldLevel = fields || 'full';
|
|
682
608
|
if (fieldLevel === 'basic') {
|
|
@@ -707,27 +633,21 @@ export class ZentaoAPI {
|
|
|
707
633
|
}
|
|
708
634
|
}
|
|
709
635
|
catch (error) {
|
|
710
|
-
console.error('获取需求详情失败:', error);
|
|
711
636
|
throw error;
|
|
712
637
|
}
|
|
713
638
|
}
|
|
714
639
|
async createBug(productId, bug) {
|
|
715
640
|
try {
|
|
716
|
-
console.log(`正在为产品 ${productId} 创建Bug...`);
|
|
717
641
|
const response = await this.request('POST', `/products/${productId}/bugs`, undefined, bug);
|
|
718
|
-
console.log('创建Bug响应:', response);
|
|
719
642
|
return response;
|
|
720
643
|
}
|
|
721
644
|
catch (error) {
|
|
722
|
-
console.error('创建Bug失败:', error);
|
|
723
645
|
throw error;
|
|
724
646
|
}
|
|
725
647
|
}
|
|
726
648
|
async getProjectExecutions(projectId) {
|
|
727
649
|
try {
|
|
728
|
-
console.log(`正在获取项目 ${projectId} 的执行列表...`);
|
|
729
650
|
const response = await this.request('GET', `/projects/${projectId}/executions`);
|
|
730
|
-
console.log('执行列表响应:', response);
|
|
731
651
|
if (Array.isArray(response)) {
|
|
732
652
|
return response;
|
|
733
653
|
}
|
|
@@ -739,32 +659,26 @@ export class ZentaoAPI {
|
|
|
739
659
|
throw new Error(`获取执行列表失败: 响应格式不正确 ${JSON.stringify(response)}`);
|
|
740
660
|
}
|
|
741
661
|
catch (error) {
|
|
742
|
-
console.error('获取执行列表失败:', error);
|
|
743
662
|
throw error;
|
|
744
663
|
}
|
|
745
664
|
}
|
|
746
665
|
async createPlan(productId, plan) {
|
|
747
666
|
try {
|
|
748
|
-
console.log(`正在为产品 ${productId} 创建计划...`);
|
|
749
667
|
const response = await this.request('POST', `/products/${productId}/plans`, undefined, plan);
|
|
750
|
-
console.log('创建计划响应:', response);
|
|
751
668
|
return response;
|
|
752
669
|
}
|
|
753
670
|
catch (error) {
|
|
754
|
-
console.error('创建计划失败:', error);
|
|
755
671
|
throw error;
|
|
756
672
|
}
|
|
757
673
|
}
|
|
758
674
|
async getProjects(page, limit) {
|
|
759
675
|
try {
|
|
760
|
-
console.log('正在获取项目列表...');
|
|
761
676
|
const params = {};
|
|
762
677
|
if (page)
|
|
763
678
|
params.page = page;
|
|
764
679
|
if (limit)
|
|
765
680
|
params.limit = limit;
|
|
766
681
|
const response = await this.request('GET', '/projects', params);
|
|
767
|
-
console.log('项目列表响应:', response);
|
|
768
682
|
if (Array.isArray(response)) {
|
|
769
683
|
return response;
|
|
770
684
|
}
|
|
@@ -776,7 +690,6 @@ export class ZentaoAPI {
|
|
|
776
690
|
throw new Error(`获取项目列表失败: 响应格式不正确 ${JSON.stringify(response)}`);
|
|
777
691
|
}
|
|
778
692
|
catch (error) {
|
|
779
|
-
console.error('获取项目列表失败:', error);
|
|
780
693
|
throw error;
|
|
781
694
|
}
|
|
782
695
|
}
|
|
@@ -792,33 +705,26 @@ export class ZentaoAPI {
|
|
|
792
705
|
*/
|
|
793
706
|
async changeStory(storyId, update) {
|
|
794
707
|
try {
|
|
795
|
-
console.log(`正在更新需求 ${storyId}...`);
|
|
796
708
|
// 自动处理评审人问题
|
|
797
709
|
const updateData = { ...update };
|
|
798
710
|
// 如果用户没有设置评审人,也没有指定无需评审,则自动跳过评审
|
|
799
711
|
if (!updateData.reviewer && updateData.needNotReview !== true) {
|
|
800
712
|
updateData.needNotReview = true;
|
|
801
|
-
console.log('自动设置needNotReview=true以跳过评审要求');
|
|
802
713
|
}
|
|
803
714
|
// 使用 PUT /stories/:id 接口
|
|
804
715
|
const response = await this.request('PUT', `/stories/${storyId}`, undefined, updateData);
|
|
805
|
-
console.log('更新需求响应:', response);
|
|
806
716
|
return response;
|
|
807
717
|
}
|
|
808
718
|
catch (error) {
|
|
809
|
-
console.error('更新需求失败:', error);
|
|
810
719
|
throw error;
|
|
811
720
|
}
|
|
812
721
|
}
|
|
813
722
|
async deleteTask(taskId) {
|
|
814
723
|
try {
|
|
815
|
-
console.log(`正在删除任务 ${taskId}...`);
|
|
816
724
|
const response = await this.request('DELETE', `/tasks/${taskId}`);
|
|
817
|
-
console.log('删除任务响应:', response);
|
|
818
725
|
return response;
|
|
819
726
|
}
|
|
820
727
|
catch (error) {
|
|
821
|
-
console.error('删除任务失败:', error);
|
|
822
728
|
throw error;
|
|
823
729
|
}
|
|
824
730
|
}
|
|
@@ -835,14 +741,12 @@ export class ZentaoAPI {
|
|
|
835
741
|
// 默认每页20条,最多100条
|
|
836
742
|
const finalLimit = limit ? Math.min(limit, 100) : 20;
|
|
837
743
|
const finalPage = page || 1;
|
|
838
|
-
const finalFields = fields || 'basic';
|
|
839
|
-
console.log(`正在获取产品 ${productId} 的需求列表 (page=${finalPage}, limit=${finalLimit}, fields=${finalFields})...`);
|
|
744
|
+
const finalFields = fields || 'basic';
|
|
840
745
|
// 构建查询参数
|
|
841
746
|
const queryParams = new URLSearchParams();
|
|
842
747
|
queryParams.append('page', finalPage.toString());
|
|
843
748
|
queryParams.append('limit', finalLimit.toString());
|
|
844
749
|
const response = await this.request('GET', `/products/${productId}/stories?${queryParams.toString()}`);
|
|
845
|
-
console.log(`产品需求列表响应: 获取到 ${response.stories?.length || 0} 条数据`);
|
|
846
750
|
let stories = [];
|
|
847
751
|
if (Array.isArray(response)) {
|
|
848
752
|
stories = response;
|
|
@@ -873,594 +777,449 @@ export class ZentaoAPI {
|
|
|
873
777
|
}
|
|
874
778
|
}
|
|
875
779
|
catch (error) {
|
|
876
|
-
console.error('获取产品需求列表失败:', error);
|
|
877
780
|
throw error;
|
|
878
781
|
}
|
|
879
782
|
}
|
|
880
783
|
// 项目集相关接口
|
|
881
784
|
async getProgramDetail(programId) {
|
|
882
785
|
try {
|
|
883
|
-
console.log(`正在获取项目集 ${programId} 的详情...`);
|
|
884
786
|
const response = await this.request('GET', `/programs/${programId}`);
|
|
885
|
-
console.log('项目集详情响应:', response);
|
|
886
787
|
return response;
|
|
887
788
|
}
|
|
888
789
|
catch (error) {
|
|
889
|
-
console.error('获取项目集详情失败:', error);
|
|
890
790
|
throw error;
|
|
891
791
|
}
|
|
892
792
|
}
|
|
893
793
|
async createProgram(program) {
|
|
894
794
|
try {
|
|
895
|
-
console.log('正在创建项目集...');
|
|
896
795
|
const response = await this.request('POST', '/programs', undefined, program);
|
|
897
|
-
console.log('创建项目集响应:', response);
|
|
898
796
|
return response;
|
|
899
797
|
}
|
|
900
798
|
catch (error) {
|
|
901
|
-
console.error('创建项目集失败:', error);
|
|
902
799
|
throw error;
|
|
903
800
|
}
|
|
904
801
|
}
|
|
905
802
|
async updateProgram(programId, update) {
|
|
906
803
|
try {
|
|
907
|
-
console.log(`正在更新项目集 ${programId}...`);
|
|
908
804
|
const response = await this.request('PUT', `/programs/${programId}`, undefined, update);
|
|
909
|
-
console.log('更新项目集响应:', response);
|
|
910
805
|
return response;
|
|
911
806
|
}
|
|
912
807
|
catch (error) {
|
|
913
|
-
console.error('更新项目集失败:', error);
|
|
914
808
|
throw error;
|
|
915
809
|
}
|
|
916
810
|
}
|
|
917
811
|
async deleteProgram(programId) {
|
|
918
812
|
try {
|
|
919
|
-
console.log(`正在删除项目集 ${programId}...`);
|
|
920
813
|
const response = await this.request('DELETE', `/programs/${programId}`);
|
|
921
|
-
console.log('删除项目集响应:', response);
|
|
922
814
|
return response;
|
|
923
815
|
}
|
|
924
816
|
catch (error) {
|
|
925
|
-
console.error('删除项目集失败:', error);
|
|
926
817
|
throw error;
|
|
927
818
|
}
|
|
928
819
|
}
|
|
929
820
|
// 产品相关接口
|
|
930
821
|
async getProductDetail(productId) {
|
|
931
822
|
try {
|
|
932
|
-
console.log(`正在获取产品 ${productId} 的详情...`);
|
|
933
823
|
const response = await this.request('GET', `/products/${productId}`);
|
|
934
|
-
console.log('产品详情响应:', response);
|
|
935
824
|
return response;
|
|
936
825
|
}
|
|
937
826
|
catch (error) {
|
|
938
|
-
console.error('获取产品详情失败:', error);
|
|
939
827
|
throw error;
|
|
940
828
|
}
|
|
941
829
|
}
|
|
942
830
|
async createProduct(product) {
|
|
943
831
|
try {
|
|
944
|
-
console.log('正在创建产品...');
|
|
945
832
|
const response = await this.request('POST', '/products', undefined, product);
|
|
946
|
-
console.log('创建产品响应:', response);
|
|
947
833
|
return response;
|
|
948
834
|
}
|
|
949
835
|
catch (error) {
|
|
950
|
-
console.error('创建产品失败:', error);
|
|
951
836
|
throw error;
|
|
952
837
|
}
|
|
953
838
|
}
|
|
954
839
|
async updateProduct(productId, update) {
|
|
955
840
|
try {
|
|
956
|
-
console.log(`正在更新产品 ${productId}...`);
|
|
957
841
|
const response = await this.request('PUT', `/product/${productId}`, undefined, update);
|
|
958
|
-
console.log('更新产品响应:', response);
|
|
959
842
|
return response;
|
|
960
843
|
}
|
|
961
844
|
catch (error) {
|
|
962
|
-
console.error('更新产品失败:', error);
|
|
963
845
|
throw error;
|
|
964
846
|
}
|
|
965
847
|
}
|
|
966
848
|
async deleteProduct(productId) {
|
|
967
849
|
try {
|
|
968
|
-
console.log(`正在删除产品 ${productId}...`);
|
|
969
850
|
const response = await this.request('DELETE', `/product/${productId}`);
|
|
970
|
-
console.log('删除产品响应:', response);
|
|
971
851
|
return response;
|
|
972
852
|
}
|
|
973
853
|
catch (error) {
|
|
974
|
-
console.error('删除产品失败:', error);
|
|
975
854
|
throw error;
|
|
976
855
|
}
|
|
977
856
|
}
|
|
978
857
|
// 项目相关接口
|
|
979
858
|
async getProjectDetail(projectId) {
|
|
980
859
|
try {
|
|
981
|
-
console.log(`正在获取项目 ${projectId} 的详情...`);
|
|
982
860
|
const response = await this.request('GET', `/projects/${projectId}`);
|
|
983
|
-
console.log('项目详情响应:', response);
|
|
984
861
|
return response;
|
|
985
862
|
}
|
|
986
863
|
catch (error) {
|
|
987
|
-
console.error('获取项目详情失败:', error);
|
|
988
864
|
throw error;
|
|
989
865
|
}
|
|
990
866
|
}
|
|
991
867
|
async createProject(project) {
|
|
992
868
|
try {
|
|
993
|
-
console.log('正在创建项目...');
|
|
994
869
|
const response = await this.request('POST', '/projects', undefined, project);
|
|
995
|
-
console.log('创建项目响应:', response);
|
|
996
870
|
return response;
|
|
997
871
|
}
|
|
998
872
|
catch (error) {
|
|
999
|
-
console.error('创建项目失败:', error);
|
|
1000
873
|
throw error;
|
|
1001
874
|
}
|
|
1002
875
|
}
|
|
1003
876
|
async updateProject(projectId, update) {
|
|
1004
877
|
try {
|
|
1005
|
-
console.log(`正在更新项目 ${projectId}...`);
|
|
1006
878
|
const response = await this.request('PUT', `/projects/${projectId}`, undefined, update);
|
|
1007
|
-
console.log('更新项目响应:', response);
|
|
1008
879
|
return response;
|
|
1009
880
|
}
|
|
1010
881
|
catch (error) {
|
|
1011
|
-
console.error('更新项目失败:', error);
|
|
1012
882
|
throw error;
|
|
1013
883
|
}
|
|
1014
884
|
}
|
|
1015
885
|
async deleteProject(projectId) {
|
|
1016
886
|
try {
|
|
1017
|
-
console.log(`正在删除项目 ${projectId}...`);
|
|
1018
887
|
const response = await this.request('DELETE', `/projects/${projectId}`);
|
|
1019
|
-
console.log('删除项目响应:', response);
|
|
1020
888
|
return response;
|
|
1021
889
|
}
|
|
1022
890
|
catch (error) {
|
|
1023
|
-
console.error('删除项目失败:', error);
|
|
1024
891
|
throw error;
|
|
1025
892
|
}
|
|
1026
893
|
}
|
|
1027
894
|
// 执行相关接口
|
|
1028
895
|
async createExecution(projectId, execution) {
|
|
1029
896
|
try {
|
|
1030
|
-
console.log(`正在为项目 ${projectId} 创建执行...`);
|
|
1031
897
|
const response = await this.request('POST', `/projects/${projectId}/executions`, undefined, execution);
|
|
1032
|
-
console.log('创建执行响应:', response);
|
|
1033
898
|
return response;
|
|
1034
899
|
}
|
|
1035
900
|
catch (error) {
|
|
1036
|
-
console.error('创建执行失败:', error);
|
|
1037
901
|
throw error;
|
|
1038
902
|
}
|
|
1039
903
|
}
|
|
1040
904
|
async getExecutionDetail(executionId) {
|
|
1041
905
|
try {
|
|
1042
|
-
console.log(`正在获取执行 ${executionId} 的详情...`);
|
|
1043
906
|
const response = await this.request('GET', `/executions/${executionId}`);
|
|
1044
|
-
console.log('执行详情响应:', response);
|
|
1045
907
|
return response;
|
|
1046
908
|
}
|
|
1047
909
|
catch (error) {
|
|
1048
|
-
console.error('获取执行详情失败:', error);
|
|
1049
910
|
throw error;
|
|
1050
911
|
}
|
|
1051
912
|
}
|
|
1052
913
|
async updateExecution(executionId, update) {
|
|
1053
914
|
try {
|
|
1054
|
-
console.log(`正在更新执行 ${executionId}...`);
|
|
1055
915
|
const response = await this.request('PUT', `/executions/${executionId}`, undefined, update);
|
|
1056
|
-
console.log('更新执行响应:', response);
|
|
1057
916
|
return response;
|
|
1058
917
|
}
|
|
1059
918
|
catch (error) {
|
|
1060
|
-
console.error('更新执行失败:', error);
|
|
1061
919
|
throw error;
|
|
1062
920
|
}
|
|
1063
921
|
}
|
|
1064
922
|
async deleteExecution(executionId) {
|
|
1065
923
|
try {
|
|
1066
|
-
console.log(`正在删除执行 ${executionId}...`);
|
|
1067
924
|
const response = await this.request('DELETE', `/executions/${executionId}`);
|
|
1068
|
-
console.log('删除执行响应:', response);
|
|
1069
925
|
return response;
|
|
1070
926
|
}
|
|
1071
927
|
catch (error) {
|
|
1072
|
-
console.error('删除执行失败:', error);
|
|
1073
928
|
throw error;
|
|
1074
929
|
}
|
|
1075
930
|
}
|
|
1076
931
|
// 需求相关接口
|
|
1077
932
|
async deleteStory(storyId) {
|
|
1078
933
|
try {
|
|
1079
|
-
console.log(`正在删除需求 ${storyId}...`);
|
|
1080
934
|
const response = await this.request('DELETE', `/stories/${storyId}`);
|
|
1081
|
-
console.log('删除需求响应:', response);
|
|
1082
935
|
return response;
|
|
1083
936
|
}
|
|
1084
937
|
catch (error) {
|
|
1085
|
-
console.error('删除需求失败:', error);
|
|
1086
938
|
throw error;
|
|
1087
939
|
}
|
|
1088
940
|
}
|
|
1089
941
|
// Bug相关接口
|
|
1090
942
|
async updateBug(bugId, update) {
|
|
1091
943
|
try {
|
|
1092
|
-
console.log(`正在更新Bug ${bugId}...`);
|
|
1093
944
|
const response = await this.request('PUT', `/bugs/${bugId}`, undefined, update);
|
|
1094
|
-
console.log('更新Bug响应:', response);
|
|
1095
945
|
return response;
|
|
1096
946
|
}
|
|
1097
947
|
catch (error) {
|
|
1098
|
-
console.error('更新Bug失败:', error);
|
|
1099
948
|
throw error;
|
|
1100
949
|
}
|
|
1101
950
|
}
|
|
1102
951
|
async deleteBug(bugId) {
|
|
1103
952
|
try {
|
|
1104
|
-
console.log(`正在删除Bug ${bugId}...`);
|
|
1105
953
|
const response = await this.request('DELETE', `/bugs/${bugId}`);
|
|
1106
|
-
console.log('删除Bug响应:', response);
|
|
1107
954
|
return response;
|
|
1108
955
|
}
|
|
1109
956
|
catch (error) {
|
|
1110
|
-
console.error('删除Bug失败:', error);
|
|
1111
957
|
throw error;
|
|
1112
958
|
}
|
|
1113
959
|
}
|
|
1114
960
|
// 反馈模块接口
|
|
1115
961
|
async getFeedbacks(params) {
|
|
1116
962
|
try {
|
|
1117
|
-
console.log('正在获取反馈列表...');
|
|
1118
963
|
const response = await this.request('GET', '/feedbacks', params);
|
|
1119
|
-
console.log('获取反馈列表响应:', response);
|
|
1120
964
|
return response;
|
|
1121
965
|
}
|
|
1122
966
|
catch (error) {
|
|
1123
|
-
console.error('获取反馈列表失败:', error);
|
|
1124
967
|
throw error;
|
|
1125
968
|
}
|
|
1126
969
|
}
|
|
1127
970
|
async getFeedbackDetail(feedbackId) {
|
|
1128
971
|
try {
|
|
1129
|
-
console.log(`正在获取反馈 ${feedbackId} 的详情...`);
|
|
1130
972
|
const response = await this.request('GET', `/feedbacks/${feedbackId}`);
|
|
1131
|
-
console.log('获取反馈详情响应:', response);
|
|
1132
973
|
return response;
|
|
1133
974
|
}
|
|
1134
975
|
catch (error) {
|
|
1135
|
-
console.error('获取反馈详情失败:', error);
|
|
1136
976
|
throw error;
|
|
1137
977
|
}
|
|
1138
978
|
}
|
|
1139
979
|
async createFeedback(feedback) {
|
|
1140
980
|
try {
|
|
1141
|
-
console.log('正在创建反馈...');
|
|
1142
981
|
const response = await this.request('POST', '/feedbacks', undefined, feedback);
|
|
1143
|
-
console.log('创建反馈响应:', response);
|
|
1144
982
|
return response;
|
|
1145
983
|
}
|
|
1146
984
|
catch (error) {
|
|
1147
|
-
console.error('创建反馈失败:', error);
|
|
1148
985
|
throw error;
|
|
1149
986
|
}
|
|
1150
987
|
}
|
|
1151
988
|
async updateFeedback(feedbackId, update) {
|
|
1152
989
|
try {
|
|
1153
|
-
console.log(`正在更新反馈 ${feedbackId}...`);
|
|
1154
990
|
const response = await this.request('PUT', `/feedbacks/${feedbackId}`, undefined, update);
|
|
1155
|
-
console.log('更新反馈响应:', response);
|
|
1156
991
|
return response;
|
|
1157
992
|
}
|
|
1158
993
|
catch (error) {
|
|
1159
|
-
console.error('更新反馈失败:', error);
|
|
1160
994
|
throw error;
|
|
1161
995
|
}
|
|
1162
996
|
}
|
|
1163
997
|
async deleteFeedback(feedbackId) {
|
|
1164
998
|
try {
|
|
1165
|
-
console.log(`正在删除反馈 ${feedbackId}...`);
|
|
1166
999
|
const response = await this.request('DELETE', `/feedbacks/${feedbackId}`);
|
|
1167
|
-
console.log('删除反馈响应:', response);
|
|
1168
1000
|
return response;
|
|
1169
1001
|
}
|
|
1170
1002
|
catch (error) {
|
|
1171
|
-
console.error('删除反馈失败:', error);
|
|
1172
1003
|
throw error;
|
|
1173
1004
|
}
|
|
1174
1005
|
}
|
|
1175
1006
|
async assignFeedback(feedbackId, assign) {
|
|
1176
1007
|
try {
|
|
1177
|
-
console.log(`正在指派反馈 ${feedbackId}...`);
|
|
1178
1008
|
const response = await this.request('POST', `/feedbacks/${feedbackId}/assign`, undefined, assign);
|
|
1179
|
-
console.log('指派反馈响应:', response);
|
|
1180
1009
|
return response;
|
|
1181
1010
|
}
|
|
1182
1011
|
catch (error) {
|
|
1183
|
-
console.error('指派反馈失败:', error);
|
|
1184
1012
|
throw error;
|
|
1185
1013
|
}
|
|
1186
1014
|
}
|
|
1187
1015
|
async closeFeedback(feedbackId, close) {
|
|
1188
1016
|
try {
|
|
1189
|
-
console.log(`正在关闭反馈 ${feedbackId}...`);
|
|
1190
1017
|
const response = await this.request('POST', `/feedbacks/${feedbackId}/close`, undefined, close);
|
|
1191
|
-
console.log('关闭反馈响应:', response);
|
|
1192
1018
|
return response;
|
|
1193
1019
|
}
|
|
1194
1020
|
catch (error) {
|
|
1195
|
-
console.error('关闭反馈失败:', error);
|
|
1196
1021
|
throw error;
|
|
1197
1022
|
}
|
|
1198
1023
|
}
|
|
1199
1024
|
// 测试用例模块接口
|
|
1200
1025
|
async getProductTestCases(productId) {
|
|
1201
1026
|
try {
|
|
1202
|
-
console.log(`正在获取产品 ${productId} 的测试用例列表...`);
|
|
1203
1027
|
const response = await this.request('GET', `/products/${productId}/testcases`);
|
|
1204
|
-
console.log('获取测试用例列表响应:', response);
|
|
1205
1028
|
return response;
|
|
1206
1029
|
}
|
|
1207
1030
|
catch (error) {
|
|
1208
|
-
console.error('获取测试用例列表失败:', error);
|
|
1209
1031
|
throw error;
|
|
1210
1032
|
}
|
|
1211
1033
|
}
|
|
1212
1034
|
async createTestCase(productId, testCase) {
|
|
1213
1035
|
try {
|
|
1214
|
-
console.log(`正在为产品 ${productId} 创建测试用例...`);
|
|
1215
1036
|
const response = await this.request('POST', `/products/${productId}/testcases`, undefined, testCase);
|
|
1216
|
-
console.log('创建测试用例响应:', response);
|
|
1217
1037
|
return response;
|
|
1218
1038
|
}
|
|
1219
1039
|
catch (error) {
|
|
1220
|
-
console.error('创建测试用例失败:', error);
|
|
1221
1040
|
throw error;
|
|
1222
1041
|
}
|
|
1223
1042
|
}
|
|
1224
1043
|
async getTestCaseDetail(testCaseId) {
|
|
1225
1044
|
try {
|
|
1226
|
-
console.log(`正在获取测试用例 ${testCaseId} 的详情...`);
|
|
1227
1045
|
const response = await this.request('GET', `/testcases/${testCaseId}`);
|
|
1228
|
-
console.log('获取测试用例详情响应:', response);
|
|
1229
1046
|
return response;
|
|
1230
1047
|
}
|
|
1231
1048
|
catch (error) {
|
|
1232
|
-
console.error('获取测试用例详情失败:', error);
|
|
1233
1049
|
throw error;
|
|
1234
1050
|
}
|
|
1235
1051
|
}
|
|
1236
1052
|
async updateTestCase(testCaseId, update) {
|
|
1237
1053
|
try {
|
|
1238
|
-
console.log(`正在更新测试用例 ${testCaseId}...`);
|
|
1239
1054
|
const response = await this.request('PUT', `/testcases/${testCaseId}`, undefined, update);
|
|
1240
|
-
console.log('更新测试用例响应:', response);
|
|
1241
1055
|
return response;
|
|
1242
1056
|
}
|
|
1243
1057
|
catch (error) {
|
|
1244
|
-
console.error('更新测试用例失败:', error);
|
|
1245
1058
|
throw error;
|
|
1246
1059
|
}
|
|
1247
1060
|
}
|
|
1248
1061
|
async deleteTestCase(testCaseId) {
|
|
1249
1062
|
try {
|
|
1250
|
-
console.log(`正在删除测试用例 ${testCaseId}...`);
|
|
1251
1063
|
const response = await this.request('DELETE', `/testcases/${testCaseId}`);
|
|
1252
|
-
console.log('删除测试用例响应:', response);
|
|
1253
1064
|
return response;
|
|
1254
1065
|
}
|
|
1255
1066
|
catch (error) {
|
|
1256
|
-
console.error('删除测试用例失败:', error);
|
|
1257
1067
|
throw error;
|
|
1258
1068
|
}
|
|
1259
1069
|
}
|
|
1260
1070
|
// 版本/构建模块接口
|
|
1261
1071
|
async getProjectBuilds(projectId) {
|
|
1262
1072
|
try {
|
|
1263
|
-
console.log(`正在获取项目 ${projectId} 的版本列表...`);
|
|
1264
1073
|
const response = await this.request('GET', `/projects/${projectId}/builds`);
|
|
1265
|
-
console.log('获取版本列表响应:', response);
|
|
1266
1074
|
return response;
|
|
1267
1075
|
}
|
|
1268
1076
|
catch (error) {
|
|
1269
|
-
console.error('获取版本列表失败:', error);
|
|
1270
1077
|
throw error;
|
|
1271
1078
|
}
|
|
1272
1079
|
}
|
|
1273
1080
|
async getExecutionBuilds(executionId) {
|
|
1274
1081
|
try {
|
|
1275
|
-
console.log(`正在获取执行 ${executionId} 的版本列表...`);
|
|
1276
1082
|
const response = await this.request('GET', `/executions/${executionId}/builds`);
|
|
1277
|
-
console.log('获取版本列表响应:', response);
|
|
1278
1083
|
return response;
|
|
1279
1084
|
}
|
|
1280
1085
|
catch (error) {
|
|
1281
|
-
console.error('获取版本列表失败:', error);
|
|
1282
1086
|
throw error;
|
|
1283
1087
|
}
|
|
1284
1088
|
}
|
|
1285
1089
|
async createBuild(projectId, build) {
|
|
1286
1090
|
try {
|
|
1287
|
-
console.log(`正在为项目 ${projectId} 创建版本...`);
|
|
1288
1091
|
const response = await this.request('POST', `/projects/${projectId}/builds`, undefined, build);
|
|
1289
|
-
console.log('创建版本响应:', response);
|
|
1290
1092
|
return response;
|
|
1291
1093
|
}
|
|
1292
1094
|
catch (error) {
|
|
1293
|
-
console.error('创建版本失败:', error);
|
|
1294
1095
|
throw error;
|
|
1295
1096
|
}
|
|
1296
1097
|
}
|
|
1297
1098
|
async getBuildDetail(buildId) {
|
|
1298
1099
|
try {
|
|
1299
|
-
console.log(`正在获取版本 ${buildId} 的详情...`);
|
|
1300
1100
|
const response = await this.request('GET', `/builds/${buildId}`);
|
|
1301
|
-
console.log('获取版本详情响应:', response);
|
|
1302
1101
|
return response;
|
|
1303
1102
|
}
|
|
1304
1103
|
catch (error) {
|
|
1305
|
-
console.error('获取版本详情失败:', error);
|
|
1306
1104
|
throw error;
|
|
1307
1105
|
}
|
|
1308
1106
|
}
|
|
1309
1107
|
async updateBuild(buildId, update) {
|
|
1310
1108
|
try {
|
|
1311
|
-
console.log(`正在更新版本 ${buildId}...`);
|
|
1312
1109
|
const response = await this.request('PUT', `/builds/${buildId}`, undefined, update);
|
|
1313
|
-
console.log('更新版本响应:', response);
|
|
1314
1110
|
return response;
|
|
1315
1111
|
}
|
|
1316
1112
|
catch (error) {
|
|
1317
|
-
console.error('更新版本失败:', error);
|
|
1318
1113
|
throw error;
|
|
1319
1114
|
}
|
|
1320
1115
|
}
|
|
1321
1116
|
async deleteBuild(buildId) {
|
|
1322
1117
|
try {
|
|
1323
|
-
console.log(`正在删除版本 ${buildId}...`);
|
|
1324
1118
|
const response = await this.request('DELETE', `/builds/${buildId}`);
|
|
1325
|
-
console.log('删除版本响应:', response);
|
|
1326
1119
|
return response;
|
|
1327
1120
|
}
|
|
1328
1121
|
catch (error) {
|
|
1329
|
-
console.error('删除版本失败:', error);
|
|
1330
1122
|
throw error;
|
|
1331
1123
|
}
|
|
1332
1124
|
}
|
|
1333
1125
|
// 用户模块接口
|
|
1334
1126
|
async getUserDetail(userId) {
|
|
1335
1127
|
try {
|
|
1336
|
-
console.log(`正在获取用户 ${userId} 的详情...`);
|
|
1337
1128
|
const response = await this.request('GET', `/users/${userId}`);
|
|
1338
|
-
console.log('获取用户详情响应:', response);
|
|
1339
1129
|
return response;
|
|
1340
1130
|
}
|
|
1341
1131
|
catch (error) {
|
|
1342
|
-
console.error('获取用户详情失败:', error);
|
|
1343
1132
|
throw error;
|
|
1344
1133
|
}
|
|
1345
1134
|
}
|
|
1346
1135
|
async getMyProfile() {
|
|
1347
1136
|
try {
|
|
1348
|
-
console.log('正在获取我的个人信息...');
|
|
1349
1137
|
const response = await this.request('GET', '/user');
|
|
1350
|
-
console.log('获取个人信息响应:', response);
|
|
1351
1138
|
return response;
|
|
1352
1139
|
}
|
|
1353
1140
|
catch (error) {
|
|
1354
|
-
console.error('获取个人信息失败:', error);
|
|
1355
1141
|
throw error;
|
|
1356
1142
|
}
|
|
1357
1143
|
}
|
|
1358
1144
|
async getUsers(params) {
|
|
1359
1145
|
try {
|
|
1360
|
-
console.log('正在获取用户列表...');
|
|
1361
1146
|
const response = await this.request('GET', '/users', params);
|
|
1362
|
-
console.log('获取用户列表响应:', response);
|
|
1363
1147
|
return response;
|
|
1364
1148
|
}
|
|
1365
1149
|
catch (error) {
|
|
1366
|
-
console.error('获取用户列表失败:', error);
|
|
1367
1150
|
throw error;
|
|
1368
1151
|
}
|
|
1369
1152
|
}
|
|
1370
1153
|
async createUser(user) {
|
|
1371
1154
|
try {
|
|
1372
|
-
console.log('正在创建用户...');
|
|
1373
1155
|
const response = await this.request('POST', '/users', undefined, user);
|
|
1374
|
-
console.log('创建用户响应:', response);
|
|
1375
1156
|
return response;
|
|
1376
1157
|
}
|
|
1377
1158
|
catch (error) {
|
|
1378
|
-
console.error('创建用户失败:', error);
|
|
1379
1159
|
throw error;
|
|
1380
1160
|
}
|
|
1381
1161
|
}
|
|
1382
1162
|
async updateUser(userId, update) {
|
|
1383
1163
|
try {
|
|
1384
|
-
console.log(`正在更新用户 ${userId}...`);
|
|
1385
1164
|
const response = await this.request('PUT', `/users/${userId}`, undefined, update);
|
|
1386
|
-
console.log('更新用户响应:', response);
|
|
1387
1165
|
return response;
|
|
1388
1166
|
}
|
|
1389
1167
|
catch (error) {
|
|
1390
|
-
console.error('更新用户失败:', error);
|
|
1391
1168
|
throw error;
|
|
1392
1169
|
}
|
|
1393
1170
|
}
|
|
1394
1171
|
async deleteUser(userId) {
|
|
1395
1172
|
try {
|
|
1396
|
-
console.log(`正在删除用户 ${userId}...`);
|
|
1397
1173
|
const response = await this.request('DELETE', `/users/${userId}`);
|
|
1398
|
-
console.log('删除用户响应:', response);
|
|
1399
1174
|
return response;
|
|
1400
1175
|
}
|
|
1401
1176
|
catch (error) {
|
|
1402
|
-
console.error('删除用户失败:', error);
|
|
1403
1177
|
throw error;
|
|
1404
1178
|
}
|
|
1405
1179
|
}
|
|
1406
1180
|
// 工单模块接口
|
|
1407
1181
|
async getTickets(params) {
|
|
1408
1182
|
try {
|
|
1409
|
-
console.log('正在获取工单列表...');
|
|
1410
1183
|
const response = await this.request('GET', '/tickets', params);
|
|
1411
|
-
console.log('获取工单列表响应:', response);
|
|
1412
1184
|
return response;
|
|
1413
1185
|
}
|
|
1414
1186
|
catch (error) {
|
|
1415
|
-
console.error('获取工单列表失败:', error);
|
|
1416
1187
|
throw error;
|
|
1417
1188
|
}
|
|
1418
1189
|
}
|
|
1419
1190
|
async getTicketDetail(ticketId) {
|
|
1420
1191
|
try {
|
|
1421
|
-
console.log(`正在获取工单 ${ticketId} 的详情...`);
|
|
1422
1192
|
const response = await this.request('GET', `/tickets/${ticketId}`);
|
|
1423
|
-
console.log('获取工单详情响应:', response);
|
|
1424
1193
|
return response;
|
|
1425
1194
|
}
|
|
1426
1195
|
catch (error) {
|
|
1427
|
-
console.error('获取工单详情失败:', error);
|
|
1428
1196
|
throw error;
|
|
1429
1197
|
}
|
|
1430
1198
|
}
|
|
1431
1199
|
async createTicket(ticket) {
|
|
1432
1200
|
try {
|
|
1433
|
-
console.log('正在创建工单...');
|
|
1434
1201
|
const response = await this.request('POST', '/tickets', undefined, ticket);
|
|
1435
|
-
console.log('创建工单响应:', response);
|
|
1436
1202
|
return response;
|
|
1437
1203
|
}
|
|
1438
1204
|
catch (error) {
|
|
1439
|
-
console.error('创建工单失败:', error);
|
|
1440
1205
|
throw error;
|
|
1441
1206
|
}
|
|
1442
1207
|
}
|
|
1443
1208
|
async updateTicket(ticketId, update) {
|
|
1444
1209
|
try {
|
|
1445
|
-
console.log(`正在更新工单 ${ticketId}...`);
|
|
1446
1210
|
const response = await this.request('PUT', `/tickets/${ticketId}`, undefined, update);
|
|
1447
|
-
console.log('更新工单响应:', response);
|
|
1448
1211
|
return response;
|
|
1449
1212
|
}
|
|
1450
1213
|
catch (error) {
|
|
1451
|
-
console.error('更新工单失败:', error);
|
|
1452
1214
|
throw error;
|
|
1453
1215
|
}
|
|
1454
1216
|
}
|
|
1455
1217
|
async deleteTicket(ticketId) {
|
|
1456
1218
|
try {
|
|
1457
|
-
console.log(`正在删除工单 ${ticketId}...`);
|
|
1458
1219
|
const response = await this.request('DELETE', `/tickets/${ticketId}`);
|
|
1459
|
-
console.log('删除工单响应:', response);
|
|
1460
1220
|
return response;
|
|
1461
1221
|
}
|
|
1462
1222
|
catch (error) {
|
|
1463
|
-
console.error('删除工单失败:', error);
|
|
1464
1223
|
throw error;
|
|
1465
1224
|
}
|
|
1466
1225
|
}
|
|
@@ -1474,25 +1233,21 @@ export class ZentaoAPI {
|
|
|
1474
1233
|
*/
|
|
1475
1234
|
async getModules(type, id, fields) {
|
|
1476
1235
|
try {
|
|
1477
|
-
console.log(`正在获取模块列表,类型: ${type}, ID: ${id}, 字段: ${fields || '默认'}...`);
|
|
1478
1236
|
const params = { type, id };
|
|
1479
1237
|
if (fields) {
|
|
1480
1238
|
params.fields = fields;
|
|
1481
1239
|
}
|
|
1482
1240
|
// 使用新的自定义接口路径
|
|
1483
1241
|
const response = await this.request('GET', '/custom/modules', params);
|
|
1484
|
-
console.log(`获取模块列表成功,共 ${response.total} 个模块`);
|
|
1485
1242
|
return response;
|
|
1486
1243
|
}
|
|
1487
1244
|
catch (error) {
|
|
1488
|
-
console.error('获取模块列表失败:', error);
|
|
1489
1245
|
throw error;
|
|
1490
1246
|
}
|
|
1491
1247
|
}
|
|
1492
1248
|
// 文件相关API
|
|
1493
1249
|
async uploadFile(uploadRequest) {
|
|
1494
1250
|
try {
|
|
1495
|
-
console.log(`正在上传文件: ${uploadRequest.filename}...`);
|
|
1496
1251
|
const token = await this.getToken();
|
|
1497
1252
|
// 创建FormData
|
|
1498
1253
|
const FormData = (await import('form-data')).default;
|
|
@@ -1509,17 +1264,14 @@ export class ZentaoAPI {
|
|
|
1509
1264
|
...formData.getHeaders()
|
|
1510
1265
|
},
|
|
1511
1266
|
});
|
|
1512
|
-
console.log('上传文件响应:', response.data);
|
|
1513
1267
|
return response.data;
|
|
1514
1268
|
}
|
|
1515
1269
|
catch (error) {
|
|
1516
|
-
console.error('上传文件失败:', error);
|
|
1517
1270
|
throw error;
|
|
1518
1271
|
}
|
|
1519
1272
|
}
|
|
1520
1273
|
async downloadFile(fileId) {
|
|
1521
1274
|
try {
|
|
1522
|
-
console.log(`正在下载文件 ${fileId}...`);
|
|
1523
1275
|
const token = await this.getToken();
|
|
1524
1276
|
const response = await this.client.request({
|
|
1525
1277
|
method: 'GET',
|
|
@@ -1527,11 +1279,9 @@ export class ZentaoAPI {
|
|
|
1527
1279
|
headers: { Token: token },
|
|
1528
1280
|
responseType: 'arraybuffer'
|
|
1529
1281
|
});
|
|
1530
|
-
console.log('下载文件成功');
|
|
1531
1282
|
return Buffer.from(response.data);
|
|
1532
1283
|
}
|
|
1533
1284
|
catch (error) {
|
|
1534
|
-
console.error('下载文件失败:', error);
|
|
1535
1285
|
throw error;
|
|
1536
1286
|
}
|
|
1537
1287
|
}
|
|
@@ -1542,13 +1292,10 @@ export class ZentaoAPI {
|
|
|
1542
1292
|
*/
|
|
1543
1293
|
async getComments(objectType, objectID) {
|
|
1544
1294
|
try {
|
|
1545
|
-
console.log(`正在获取 ${objectType} ${objectID} 的评论列表...`);
|
|
1546
1295
|
const response = await this.request('GET', `/comments/${objectType}/${objectID}`);
|
|
1547
|
-
console.log('获取评论列表响应:', response);
|
|
1548
1296
|
return response;
|
|
1549
1297
|
}
|
|
1550
1298
|
catch (error) {
|
|
1551
|
-
console.error('获取评论列表失败:', error);
|
|
1552
1299
|
throw error;
|
|
1553
1300
|
}
|
|
1554
1301
|
}
|
|
@@ -1558,13 +1305,10 @@ export class ZentaoAPI {
|
|
|
1558
1305
|
*/
|
|
1559
1306
|
async getCommentDetail(commentId) {
|
|
1560
1307
|
try {
|
|
1561
|
-
console.log(`正在获取评论 ${commentId} 的详情...`);
|
|
1562
1308
|
const response = await this.request('GET', `/comment/${commentId}`);
|
|
1563
|
-
console.log('获取评论详情响应:', response);
|
|
1564
1309
|
return response;
|
|
1565
1310
|
}
|
|
1566
1311
|
catch (error) {
|
|
1567
|
-
console.error('获取评论详情失败:', error);
|
|
1568
1312
|
throw error;
|
|
1569
1313
|
}
|
|
1570
1314
|
}
|
|
@@ -1574,13 +1318,10 @@ export class ZentaoAPI {
|
|
|
1574
1318
|
*/
|
|
1575
1319
|
async addComment(request) {
|
|
1576
1320
|
try {
|
|
1577
|
-
console.log(`正在为 ${request.objectType} ${request.objectID} 添加评论...`);
|
|
1578
1321
|
const response = await this.request('POST', '/comment', undefined, request);
|
|
1579
|
-
console.log('添加评论响应:', response);
|
|
1580
1322
|
return response;
|
|
1581
1323
|
}
|
|
1582
1324
|
catch (error) {
|
|
1583
|
-
console.error('添加评论失败:', error);
|
|
1584
1325
|
throw error;
|
|
1585
1326
|
}
|
|
1586
1327
|
}
|
|
@@ -1590,13 +1331,10 @@ export class ZentaoAPI {
|
|
|
1590
1331
|
*/
|
|
1591
1332
|
async updateComment(commentId, update) {
|
|
1592
1333
|
try {
|
|
1593
|
-
console.log(`正在更新评论 ${commentId}...`);
|
|
1594
1334
|
const response = await this.request('PUT', `/comment/${commentId}`, undefined, update);
|
|
1595
|
-
console.log('更新评论响应:', response);
|
|
1596
1335
|
return response;
|
|
1597
1336
|
}
|
|
1598
1337
|
catch (error) {
|
|
1599
|
-
console.error('更新评论失败:', error);
|
|
1600
1338
|
throw error;
|
|
1601
1339
|
}
|
|
1602
1340
|
}
|
|
@@ -1606,13 +1344,10 @@ export class ZentaoAPI {
|
|
|
1606
1344
|
*/
|
|
1607
1345
|
async deleteComment(commentId) {
|
|
1608
1346
|
try {
|
|
1609
|
-
console.log(`正在删除评论 ${commentId}...`);
|
|
1610
1347
|
const response = await this.request('DELETE', `/comment/${commentId}`);
|
|
1611
|
-
console.log('删除评论响应:', response);
|
|
1612
1348
|
return response;
|
|
1613
1349
|
}
|
|
1614
1350
|
catch (error) {
|
|
1615
|
-
console.error('删除评论失败:', error);
|
|
1616
1351
|
throw error;
|
|
1617
1352
|
}
|
|
1618
1353
|
}
|