@zeyue0329/xiaoma-cli 1.0.20 → 1.0.22

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.
Files changed (40) hide show
  1. package/XIAOMA-CLI/345/267/245/344/275/234/346/265/201/344/270/216/346/231/272/350/203/275/344/275/223/347/274/226/346/216/222/350/257/246/347/273/206/346/226/207/346/241/243.md +18 -18
  2. package/XIAOMA-CLI/346/231/272/350/203/275/344/275/223/344/270/216/345/221/275/344/273/244/345/256/214/346/225/264/346/226/207/346/241/243.md +5 -5
  3. package/dist/agents/analyst.txt +1 -1
  4. package/dist/agents/architect.txt +5 -5
  5. package/dist/agents/automation-orchestrator.txt +396 -0
  6. package/dist/agents/database-architect.txt +1 -1
  7. package/dist/agents/pm.txt +7 -7
  8. package/dist/agents/po.txt +1 -1
  9. package/dist/agents/sm.txt +1395 -0
  10. package/dist/agents/xiaoma-master.txt +11 -11
  11. package/dist/expansion-packs/bmad-2d-phaser-game-dev/teams/phaser-2d-nodejs-game-team.txt +1 -1
  12. package/dist/expansion-packs/bmad-2d-unity-game-dev/teams/unity-2d-game-team.txt +1 -1
  13. package/dist/teams/team-all.txt +1766 -15
  14. package/dist/teams/team-fullstack-with-database.txt +2116 -22
  15. package/dist/teams/team-fullstack.txt +14 -14
  16. package/dist/teams/team-ide-minimal.txt +1396 -1
  17. package/dist/teams/team-no-ui.txt +14 -14
  18. package/package.json +1 -1
  19. package/tools/installer/package.json +1 -1
  20. package/xiaoma-core/agent-teams/team-fullstack-with-database.yaml +3 -1
  21. package/xiaoma-core/agents/analyst.md +1 -1
  22. package/xiaoma-core/agents/automation-orchestrator.md +353 -0
  23. package/xiaoma-core/agents/database-architect.md +1 -1
  24. package/xiaoma-core/agents/pm.md +1 -1
  25. package/xiaoma-core/agents/po.md +1 -1
  26. package/xiaoma-core/agents/sm.md +4 -0
  27. package/xiaoma-core/checklists/dev-completion-checklist.md +324 -0
  28. package/xiaoma-core/checklists/po-story-validation-checklist.md +219 -0
  29. package/xiaoma-core/checklists/qa-approval-checklist.md +393 -0
  30. package/xiaoma-core/tasks/automated-story-cycle.md +370 -0
  31. package/xiaoma-core/tasks/create-database-design.md +2 -2
  32. package/xiaoma-core/tasks/create-enhanced-story-with-database.md +250 -0
  33. package/xiaoma-core/templates/api-design-tmpl.yaml +704 -0
  34. package/xiaoma-core/templates/brownfield-architecture-tmpl.yaml +5 -5
  35. package/xiaoma-core/templates/brownfield-prd-tmpl.yaml +6 -6
  36. package/xiaoma-core/templates/enhanced-story-with-database-tmpl.yaml +428 -0
  37. package/xiaoma-core/workflows/automated-story-development.yaml +331 -0
  38. package/xiaoma-core/workflows/enhanced-fullstack-with-database.yaml +13 -6
  39. package//346/225/260/346/215/256/345/272/223/350/256/276/350/256/241/345/242/236/345/274/272/345/212/237/350/203/275/344/275/277/347/224/250/346/214/207/345/215/227.md +1 -1
  40. package//350/207/252/345/212/250/345/214/226/347/224/250/346/210/267/346/225/205/344/272/213/345/274/200/345/217/221/346/265/201/347/250/213/344/275/277/347/224/250/346/214/207/345/215/227.md +377 -0
@@ -70,6 +70,7 @@ commands:
70
70
  - help: 显示以下命令的编号列表以供选择
71
71
  - correct-course: 执行任务 correct-course.md
72
72
  - draft: 执行任务 create-next-story.md
73
+ - draft-enhanced: 执行任务 create-enhanced-story-with-database.md (增强版用户故事,包含数据库和API设计)
73
74
  - story-checklist: 使用清单 story-draft-checklist.md 执行任务 execute-checklist.md
74
75
  - exit: 作为 Scrum Master 道别,然后放弃扮演此角色
75
76
  dependencies:
@@ -78,9 +79,12 @@ dependencies:
78
79
  tasks:
79
80
  - correct-course.md
80
81
  - create-next-story.md
82
+ - create-enhanced-story-with-database.md
81
83
  - execute-checklist.md
82
84
  templates:
83
85
  - story-tmpl.yaml
86
+ - enhanced-story-with-database-tmpl.yaml
87
+ - api-design-tmpl.yaml
84
88
  ```
85
89
  ==================== END: .xiaoma-core/agents/sm.md ====================
86
90
 
@@ -276,6 +280,259 @@ ALWAYS cite source documents: `[Source: architecture/{filename}.md#{section}]`
276
280
  - Next steps: For Complex stories, suggest the user carefully review the story draft and also optionally have the PO run the task `.xiaoma-core/tasks/validate-next-story`
277
281
  ==================== END: .xiaoma-core/tasks/create-next-story.md ====================
278
282
 
283
+ ==================== START: .xiaoma-core/tasks/create-enhanced-story-with-database.md ====================
284
+ # 创建增强用户故事(包含数据库和API设计)
285
+
286
+ ## 任务概述
287
+
288
+ 基于Epic分解,结合数据库设计和API接口规范,创建详细的用户故事文档。此任务要求深度集成database-architect生成的数据库设计和API接口设计。
289
+
290
+ ## 前置条件
291
+
292
+ - 已完成Epic分解和优先级排序
293
+ - 已有数据库设计文档 (`docs/database/database-design.md`)
294
+ - 已有API接口设计文档
295
+ - 已完成架构设计
296
+
297
+ ## 输入要求
298
+
299
+ - Epic文档
300
+ - 数据库设计文档
301
+ - API接口设计文档
302
+ - 架构设计文档
303
+
304
+ ## 执行步骤
305
+
306
+ ### 1. 分析Epic和设计文档
307
+
308
+ #### 1.1 Epic分析
309
+
310
+ - 确定用户故事的业务价值和优先级
311
+ - 识别涉及的用户角色
312
+ - 明确功能边界和范围
313
+
314
+ #### 1.2 数据库设计分析
315
+
316
+ - 从`docs/database/database-design.md`中识别相关实体
317
+ - 确定涉及的数据表和字段
318
+ - 分析数据操作类型(增删改查)
319
+ - 理解业务规则和约束
320
+
321
+ #### 1.3 API接口分析
322
+
323
+ - 从API设计文档中识别相关接口
324
+ - 确定HTTP方法和路径
325
+ - 分析请求参数和响应格式
326
+ - 理解错误处理机制
327
+
328
+ ### 2. 使用增强模板创建用户故事
329
+
330
+ 使用模板:`enhanced-story-with-database-tmpl.yaml`
331
+
332
+ #### 2.1 基础信息填写
333
+
334
+ ```yaml
335
+ epic_num: '{{epic_number}}'
336
+ story_num: '{{story_number}}'
337
+ story_title_short: '{{story_title}}'
338
+ role: '{{user_role}}'
339
+ action: '{{user_action}}'
340
+ benefit: '{{user_benefit}}'
341
+ ```
342
+
343
+ #### 2.2 数据库设计部分填写
344
+
345
+ **相关实体表格**:
346
+
347
+ ```markdown
348
+ | 实体名称 | 表名 | 主要用途 | 关键字段 |
349
+ | -------- | -------- | ------------ | ---------------------------- |
350
+ | User | users | 用户信息管理 | id, username, email |
351
+ | Product | products | 产品信息管理 | id, name, price, category_id |
352
+ ```
353
+
354
+ **数据操作清单**:
355
+
356
+ - 查询操作:明确需要的查询条件和返回字段
357
+ - 插入操作:明确需要插入的数据和验证规则
358
+ - 更新操作:明确可更新的字段和业务规则
359
+ - 删除操作:明确删除条件和级联规则
360
+
361
+ **业务规则约束**:
362
+
363
+ - 数据验证规则(长度、格式、范围)
364
+ - 外键约束和引用完整性
365
+ - 唯一性约束
366
+ - 业务逻辑约束(状态转换等)
367
+
368
+ #### 2.3 API接口规范部分填写
369
+
370
+ **API端点列表**:
371
+
372
+ ```markdown
373
+ | 序号 | 接口名称 | HTTP方法 | 路径 | 说明 | 状态 |
374
+ | ---- | ------------ | -------- | --------------- | ------------------ | ------ |
375
+ | 1 | 创建用户 | POST | /api/users | 创建新用户账户 | 待实现 |
376
+ | 2 | 查询用户详情 | GET | /api/users/{id} | 根据ID查询用户信息 | 待实现 |
377
+ ```
378
+
379
+ **API详细设计**:
380
+ 为每个API提供:
381
+
382
+ - 完整的请求参数说明
383
+ - 响应数据结构定义
384
+ - 具体的请求示例(curl命令)
385
+ - 成功和错误响应示例
386
+ - 错误码定义和处理建议
387
+
388
+ **数据映射关系**:
389
+
390
+ ```markdown
391
+ #### 请求参数 -> 数据库字段映射
392
+
393
+ | API参数 | 数据库表 | 数据库字段 | 数据类型 | 说明 |
394
+ | -------- | -------- | ---------- | ------------ | -------- |
395
+ | username | users | username | VARCHAR(50) | 用户名 |
396
+ | email | users | email | VARCHAR(100) | 邮箱地址 |
397
+ ```
398
+
399
+ #### 2.4 任务分解
400
+
401
+ **后端开发任务**:
402
+
403
+ - 数据库相关:Mapper方法实现、Service业务逻辑、数据验证
404
+ - API接口实现:Controller方法、参数验证、响应格式化、异常处理
405
+ - 测试相关:单元测试、集成测试、数据库测试
406
+
407
+ **前端开发任务**(如需要):
408
+
409
+ - 页面组件实现
410
+ - API调用集成
411
+ - 表单验证
412
+ - 用户交互
413
+
414
+ #### 2.5 开发者说明
415
+
416
+ **数据库上下文**:
417
+
418
+ - 实体类位置:`src/main/java/{package}/entity/`
419
+ - Mapper接口位置:`src/main/java/{package}/mapper/`
420
+ - Service层位置:`src/main/java/{package}/service/`
421
+ - 业务逻辑要求和数据验证规则
422
+
423
+ **API接口上下文**:
424
+
425
+ - Controller位置:`src/main/java/{package}/controller/`
426
+ - 请求响应格式标准
427
+ - 错误处理机制
428
+ - 接口版本控制
429
+
430
+ **集成上下文**:
431
+
432
+ - 与其他模块的依赖关系
433
+ - 外部系统调用要求
434
+ - 缓存策略和事务处理
435
+ - 性能要求
436
+
437
+ ### 3. 质量检查清单
438
+
439
+ #### 3.1 完整性检查
440
+
441
+ - [ ] 所有涉及的数据库实体都已识别
442
+ - [ ] 所有需要的API接口都已定义
443
+ - [ ] 请求参数和响应格式完整
444
+ - [ ] 错误处理机制明确
445
+ - [ ] 数据映射关系清晰
446
+
447
+ #### 3.2 一致性检查
448
+
449
+ - [ ] API参数与数据库字段对应
450
+ - [ ] 数据类型一致
451
+ - [ ] 业务规则与数据库约束匹配
452
+ - [ ] 接口设计符合RESTful规范
453
+
454
+ #### 3.3 可实现性检查
455
+
456
+ - [ ] 任务分解合理可执行
457
+ - [ ] 技术实现方案可行
458
+ - [ ] 测试覆盖充分
459
+ - [ ] 开发者说明详细
460
+
461
+ ### 4. 输出文件
462
+
463
+ 生成的用户故事文件:`docs/stories/{{epic_num}}.{{story_num}}.{{story_title_short}}.md`
464
+
465
+ ### 5. 后续协作
466
+
467
+ #### 5.1 与开发者协作
468
+
469
+ - 确保开发者理解数据库设计和API规范
470
+ - 提供必要的技术支持和澄清
471
+ - 跟踪开发进度和问题解决
472
+
473
+ #### 5.2 与QA协作
474
+
475
+ - 明确测试重点和验收标准
476
+ - 提供API测试用例和数据
477
+ - 确保质量标准得到执行
478
+
479
+ ## 模板使用示例
480
+
481
+ ### 示例:用户注册功能
482
+
483
+ **用户故事**:
484
+
485
+ > 作为新用户,我希望能够注册账户,以便使用系统的各项功能。
486
+
487
+ **相关实体**:
488
+
489
+ - Users表:存储用户基本信息
490
+ - UserProfiles表:存储用户详细资料
491
+
492
+ **涉及API**:
493
+
494
+ - POST /api/users:创建用户账户
495
+ - POST /api/users/verify-email:验证邮箱
496
+ - GET /api/users/check-username:检查用户名可用性
497
+
498
+ **数据操作**:
499
+
500
+ - 插入用户基本信息到users表
501
+ - 验证用户名和邮箱的唯一性
502
+ - 创建用户会话信息
503
+
504
+ **API详细设计**:
505
+
506
+ ```json
507
+ // POST /api/users
508
+ {
509
+ "username": "johndoe",
510
+ "email": "john@example.com",
511
+ "password": "hashedPassword"
512
+ }
513
+
514
+ // 响应
515
+ {
516
+ "code": 200,
517
+ "message": "用户创建成功",
518
+ "data": {
519
+ "userId": 12345,
520
+ "username": "johndoe",
521
+ "email": "john@example.com",
522
+ "status": "active"
523
+ }
524
+ }
525
+ ```
526
+
527
+ ## 注意事项
528
+
529
+ 1. **数据一致性**:确保API设计与数据库设计保持一致
530
+ 2. **安全性**:考虑数据验证、权限控制和敏感信息保护
531
+ 3. **性能**:关注查询效率和接口响应时间
532
+ 4. **可维护性**:保持代码结构清晰和文档完整
533
+ 5. **可测试性**:确保功能可以被充分测试
534
+ ==================== END: .xiaoma-core/tasks/create-enhanced-story-with-database.md ====================
535
+
279
536
  ==================== START: .xiaoma-core/tasks/execute-checklist.md ====================
280
537
  <!-- Powered by XIAOMA™ Core -->
281
538
 
@@ -507,6 +764,1144 @@ sections:
507
764
  editors: [qa-agent]
508
765
  ==================== END: .xiaoma-core/templates/story-tmpl.yaml ====================
509
766
 
767
+ ==================== START: .xiaoma-core/templates/enhanced-story-with-database-tmpl.yaml ====================
768
+ template:
769
+ id: enhanced-story-with-database-template-v1
770
+ name: 增强用户故事文档 (包含数据库和API设计)
771
+ version: 1.0
772
+ output:
773
+ format: markdown
774
+ filename: docs/stories/{{epic_num}}.{{story_num}}.{{story_title_short}}.md
775
+ title: "story {{epic_num}}.{{story_num}}: {{story_title_short}}"
776
+
777
+ workflow:
778
+ mode: interactive
779
+ elicitation: advanced-elicitation
780
+
781
+ agent_config:
782
+ editable_sections:
783
+ - Status
784
+ - Story
785
+ - Acceptance Criteria
786
+ - Database Design
787
+ - API Specifications
788
+ - Tasks / Subtasks
789
+ - Dev Notes
790
+ - Testing
791
+ - Change Log
792
+
793
+ sections:
794
+ - id: status
795
+ title: 状态
796
+ type: choice
797
+ choices: [Draft, Approved, InProgress, Review, Done]
798
+ instruction: 选择此用户故事的当前状态
799
+ owner: scrum-master
800
+ editors: [scrum-master, po-agent, dev-agent]
801
+
802
+ - id: story
803
+ title: 用户故事
804
+ type: template-text
805
+ template: |
806
+ **作为** {{role}},
807
+ **我希望** {{action}},
808
+ **以便** {{benefit}}
809
+ instruction: 使用包含角色、行动和收益的标准格式来定义用户故事
810
+ elicit: true
811
+ owner: scrum-master
812
+ editors: [scrum-master]
813
+
814
+ - id: acceptance-criteria
815
+ title: 验收标准
816
+ type: numbered-list
817
+ instruction: 从 Epic 文件中复制验收标准的编号列表
818
+ elicit: true
819
+ owner: scrum-master
820
+ editors: [scrum-master]
821
+
822
+ - id: database-design
823
+ title: 数据库设计相关
824
+ instruction: |
825
+ 基于database-architect生成的数据库设计,明确此用户故事涉及的数据库相关内容。
826
+ 从docs/database/database-design.md中提取相关信息。
827
+ elicit: true
828
+ owner: scrum-master
829
+ editors: [scrum-master]
830
+ sections:
831
+ - id: related-entities
832
+ title: 相关实体
833
+ instruction: |
834
+ 列出此用户故事涉及的所有数据库实体(表):
835
+ - 实体名称
836
+ - 表名
837
+ - 主要用途
838
+ - 关键字段
839
+ template: |
840
+ ### 涉及的数据库实体
841
+
842
+ | 实体名称 | 表名 | 主要用途 | 关键字段 |
843
+ |---------|------|----------|----------|
844
+ | {{entity_name}} | {{table_name}} | {{purpose}} | {{key_fields}} |
845
+ elicit: true
846
+ owner: scrum-master
847
+ editors: [scrum-master]
848
+
849
+ - id: data-operations
850
+ title: 数据操作
851
+ instruction: |
852
+ 明确此用户故事需要进行的数据操作:
853
+ - 查询操作 (SELECT)
854
+ - 插入操作 (INSERT)
855
+ - 更新操作 (UPDATE)
856
+ - 删除操作 (DELETE)
857
+ template: |
858
+ ### 数据操作清单
859
+
860
+ **查询操作**:
861
+ - [ ] {{query_description}} (表: {{table_name}})
862
+
863
+ **插入操作**:
864
+ - [ ] {{insert_description}} (表: {{table_name}})
865
+
866
+ **更新操作**:
867
+ - [ ] {{update_description}} (表: {{table_name}})
868
+
869
+ **删除操作**:
870
+ - [ ] {{delete_description}} (表: {{table_name}})
871
+ elicit: true
872
+ owner: scrum-master
873
+ editors: [scrum-master]
874
+
875
+ - id: business-rules
876
+ title: 业务规则约束
877
+ instruction: |
878
+ 列出此用户故事涉及的数据业务规则和约束:
879
+ - 数据验证规则
880
+ - 外键约束
881
+ - 唯一性约束
882
+ - 业务逻辑约束
883
+ elicit: true
884
+ owner: scrum-master
885
+ editors: [scrum-master]
886
+
887
+ - id: api-specifications
888
+ title: API接口规范
889
+ instruction: |
890
+ 基于database-architect创建的API设计,详细定义此用户故事涉及的API接口。
891
+ 每个接口必须包含完整的接口名称、入参、出参、传参示例和响应示例。
892
+ elicit: true
893
+ owner: scrum-master
894
+ editors: [scrum-master]
895
+ sections:
896
+ - id: api-endpoints
897
+ title: API端点列表
898
+ instruction: |
899
+ 列出此用户故事需要实现或调用的所有API端点
900
+ template: |
901
+ ### API端点清单
902
+
903
+ | 序号 | 接口名称 | HTTP方法 | 路径 | 说明 | 状态 |
904
+ |------|----------|----------|------|------|------|
905
+ | 1 | {{api_name}} | {{http_method}} | {{api_path}} | {{description}} | {{status}} |
906
+ elicit: true
907
+ owner: scrum-master
908
+ editors: [scrum-master]
909
+
910
+ - id: api-details
911
+ title: API详细设计
912
+ instruction: |
913
+ 为每个API端点提供详细的接口设计,包括:
914
+ - 接口名称和描述
915
+ - 请求参数详细说明
916
+ - 响应数据结构
917
+ - 请求示例
918
+ - 响应示例
919
+ - 错误码定义
920
+ template: |
921
+ ### API详细设计
922
+
923
+ #### {{api_name}}
924
+
925
+ **接口描述**: {{api_description}}
926
+ **HTTP方法**: {{http_method}}
927
+ **请求路径**: {{api_path}}
928
+
929
+ **请求参数**:
930
+ ```json
931
+ {
932
+ "param1": "string // 参数说明",
933
+ "param2": "integer // 参数说明",
934
+ "param3": {
935
+ "nested_param": "string // 嵌套参数说明"
936
+ }
937
+ }
938
+ ```
939
+
940
+ **响应数据结构**:
941
+ ```json
942
+ {
943
+ "code": "integer // 状态码",
944
+ "message": "string // 响应消息",
945
+ "data": {
946
+ "field1": "string // 字段说明",
947
+ "field2": "integer // 字段说明"
948
+ }
949
+ }
950
+ ```
951
+
952
+ **请求示例**:
953
+ ```bash
954
+ curl -X {{http_method}} "{{base_url}}{{api_path}}" \
955
+ -H "Content-Type: application/json" \
956
+ -H "Authorization: Bearer {{token}}" \
957
+ -d '{
958
+ "param1": "示例值",
959
+ "param2": 123
960
+ }'
961
+ ```
962
+
963
+ **成功响应示例**:
964
+ ```json
965
+ {
966
+ "code": 200,
967
+ "message": "操作成功",
968
+ "data": {
969
+ "field1": "返回值示例",
970
+ "field2": 456
971
+ }
972
+ }
973
+ ```
974
+
975
+ **错误响应示例**:
976
+ ```json
977
+ {
978
+ "code": 400,
979
+ "message": "参数错误",
980
+ "data": null
981
+ }
982
+ ```
983
+
984
+ **错误码定义**:
985
+ | 错误码 | 说明 | 处理建议 |
986
+ |--------|------|----------|
987
+ | 400 | 参数错误 | 检查请求参数格式 |
988
+ | 401 | 未授权 | 检查token有效性 |
989
+ | 404 | 资源不存在 | 检查资源ID |
990
+ | 500 | 服务器错误 | 联系技术支持 |
991
+ elicit: true
992
+ owner: scrum-master
993
+ editors: [scrum-master]
994
+
995
+ - id: data-mapping
996
+ title: 数据映射关系
997
+ instruction: |
998
+ 定义API参数与数据库字段的映射关系
999
+ template: |
1000
+ ### 数据映射关系
1001
+
1002
+ #### 请求参数 -> 数据库字段映射
1003
+ | API参数 | 数据库表 | 数据库字段 | 数据类型 | 说明 |
1004
+ |---------|----------|------------|----------|------|
1005
+ | {{api_param}} | {{table_name}} | {{db_field}} | {{data_type}} | {{description}} |
1006
+
1007
+ #### 数据库字段 -> 响应参数映射
1008
+ | 数据库表 | 数据库字段 | API响应字段 | 数据类型 | 说明 |
1009
+ |----------|------------|-------------|----------|------|
1010
+ | {{table_name}} | {{db_field}} | {{api_field}} | {{data_type}} | {{description}} |
1011
+ elicit: true
1012
+ owner: scrum-master
1013
+ editors: [scrum-master]
1014
+
1015
+ - id: tasks-subtasks
1016
+ title: 任务 / 子任务
1017
+ type: bullet-list
1018
+ instruction: |
1019
+ 将用户故事分解为实施所需的具体任务和子任务。
1020
+ 在相关处引用适用的验收标准编号。
1021
+ 结合数据库设计和API规范,确保任务覆盖:
1022
+ - 数据库相关操作(Mapper、Service层)
1023
+ - API接口实现(Controller层)
1024
+ - 数据验证和业务逻辑
1025
+ - 单元测试和集成测试
1026
+ template: |
1027
+ ### 后端开发任务
1028
+ - [ ] 数据库相关 (AC: # 如果适用)
1029
+ - [ ] 实现{{entity_name}}Mapper接口方法
1030
+ - [ ] 编写{{entity_name}}Service业务逻辑
1031
+ - [ ] 添加数据验证和业务规则
1032
+ - [ ] API接口实现 (AC: # 如果适用)
1033
+ - [ ] 实现{{api_name}}接口 ({{http_method}} {{api_path}})
1034
+ - [ ] 添加请求参数验证
1035
+ - [ ] 实现响应数据格式化
1036
+ - [ ] 添加异常处理和错误码
1037
+ - [ ] 测试相关 (AC: # 如果适用)
1038
+ - [ ] 编写Service层单元测试
1039
+ - [ ] 编写API接口集成测试
1040
+ - [ ] 数据库操作测试
1041
+ - [ ] 边界条件和异常测试
1042
+
1043
+ ### 前端开发任务(如果需要)
1044
+ - [ ] 前端界面 (AC: # 如果适用)
1045
+ - [ ] 实现相关页面组件
1046
+ - [ ] 集成API调用
1047
+ - [ ] 添加表单验证
1048
+ - [ ] 用户交互和反馈
1049
+ elicit: true
1050
+ owner: scrum-master
1051
+ editors: [scrum-master, dev-agent]
1052
+
1053
+ - id: dev-notes
1054
+ title: 开发者说明
1055
+ instruction: |
1056
+ 填充相关信息,且仅限从 docs 文件夹中的实际工件中提取的、与此用户故事相关的内容:
1057
+ - 数据库设计文档的相关部分
1058
+ - 生成的Entity、Mapper、Service代码位置
1059
+ - API接口设计的相关规范
1060
+ - 架构设计中的相关约束
1061
+ - 与前一个用户故事的关联信息
1062
+ 在此部分提供足够的信息,以确保开发者代理永远不需要阅读完整的设计文档。
1063
+ elicit: true
1064
+ owner: scrum-master
1065
+ editors: [scrum-master]
1066
+ sections:
1067
+ - id: database-context
1068
+ title: 数据库上下文
1069
+ instruction: |
1070
+ 提供数据库相关的开发上下文:
1071
+ - 相关实体类的位置和结构
1072
+ - Mapper接口需要实现的方法
1073
+ - Service层的业务逻辑要求
1074
+ - 数据验证规则
1075
+ elicit: true
1076
+ owner: scrum-master
1077
+ editors: [scrum-master]
1078
+
1079
+ - id: api-context
1080
+ title: API接口上下文
1081
+ instruction: |
1082
+ 提供API接口相关的开发上下文:
1083
+ - Controller类的位置和结构
1084
+ - 接口路径和HTTP方法
1085
+ - 请求响应的数据格式
1086
+ - 错误处理要求
1087
+ elicit: true
1088
+ owner: scrum-master
1089
+ editors: [scrum-master]
1090
+
1091
+ - id: integration-context
1092
+ title: 集成上下文
1093
+ instruction: |
1094
+ 提供系统集成相关的开发上下文:
1095
+ - 与其他模块的接口依赖
1096
+ - 外部系统调用要求
1097
+ - 缓存策略
1098
+ - 事务处理要求
1099
+ elicit: true
1100
+ owner: scrum-master
1101
+ editors: [scrum-master]
1102
+
1103
+ - id: testing-standards
1104
+ title: 测试
1105
+ instruction: |
1106
+ 列出开发者需要遵守的、源自架构文档的相关测试标准:
1107
+ - 测试文件位置
1108
+ - 测试标准
1109
+ - 要使用的测试框架和模式
1110
+ - 针对此用户故事的特定测试要求
1111
+ - 数据库测试和API测试要求
1112
+ elicit: true
1113
+ owner: scrum-master
1114
+ editors: [scrum-master]
1115
+
1116
+ - id: change-log
1117
+ title: 变更日志
1118
+ type: table
1119
+ columns: [日期, 版本, 描述, 作者]
1120
+ instruction: 跟踪此用户故事文档的变更
1121
+ owner: scrum-master
1122
+ editors: [scrum-master, dev-agent, qa-agent]
1123
+
1124
+ - id: dev-agent-record
1125
+ title: 开发者代理记录
1126
+ instruction: 此部分由开发代理在实施过程中填充
1127
+ owner: dev-agent
1128
+ editors: [dev-agent]
1129
+ sections:
1130
+ - id: agent-model
1131
+ title: 使用的代理模型
1132
+ template: "{{agent_model_name_version}}"
1133
+ instruction: 记录用于开发的特定 AI 代理模型和版本
1134
+ owner: dev-agent
1135
+ editors: [dev-agent]
1136
+
1137
+ - id: database-implementation
1138
+ title: 数据库实现记录
1139
+ instruction: |
1140
+ 记录数据库相关的实现细节:
1141
+ - 实现的Mapper方法
1142
+ - Service层业务逻辑
1143
+ - 数据验证实现
1144
+ - 数据库测试结果
1145
+ owner: dev-agent
1146
+ editors: [dev-agent]
1147
+
1148
+ - id: api-implementation
1149
+ title: API实现记录
1150
+ instruction: |
1151
+ 记录API接口的实现细节:
1152
+ - 实现的Controller方法
1153
+ - 参数验证逻辑
1154
+ - 响应格式处理
1155
+ - 错误处理实现
1156
+ - API测试结果
1157
+ owner: dev-agent
1158
+ editors: [dev-agent]
1159
+
1160
+ - id: debug-log-references
1161
+ title: 调试日志参考
1162
+ instruction: 引用开发过程中生成的任何调试日志或跟踪信息
1163
+ owner: dev-agent
1164
+ editors: [dev-agent]
1165
+
1166
+ - id: completion-notes
1167
+ title: 完成说明列表
1168
+ instruction: 关于任务完成情况和遇到的任何问题的说明
1169
+ owner: dev-agent
1170
+ editors: [dev-agent]
1171
+
1172
+ - id: file-list
1173
+ title: 文件列表
1174
+ instruction: |
1175
+ 列出在用户故事实施过程中创建、修改或影响的所有文件,
1176
+ 特别注意数据库和API相关文件:
1177
+ - Entity类文件
1178
+ - Mapper接口和XML文件
1179
+ - Service接口和实现文件
1180
+ - Controller文件
1181
+ - 测试文件
1182
+ owner: dev-agent
1183
+ editors: [dev-agent]
1184
+
1185
+ - id: qa-results
1186
+ title: QA 结果
1187
+ instruction: |
1188
+ QA 代理对已完成的用户故事实施进行 QA 审查的结果,
1189
+ 特别关注:
1190
+ - 数据库操作的正确性
1191
+ - API接口的功能性
1192
+ - 数据一致性验证
1193
+ - 性能测试结果
1194
+ owner: qa-agent
1195
+ editors: [qa-agent]
1196
+ ==================== END: .xiaoma-core/templates/enhanced-story-with-database-tmpl.yaml ====================
1197
+
1198
+ ==================== START: .xiaoma-core/templates/api-design-tmpl.yaml ====================
1199
+ name: API接口设计文档模板
1200
+ version: 1.0.0
1201
+ description: 基于数据库设计的RESTful API接口规范模板
1202
+
1203
+ sections:
1204
+ - id: overview
1205
+ title: API设计概述
1206
+ required: true
1207
+ template: |
1208
+ ## API设计概述
1209
+
1210
+ ### 项目信息
1211
+ - **项目名称**: {project_name}
1212
+ - **API版本**: {api_version}
1213
+ - **设计日期**: {design_date}
1214
+ - **设计人员**: Database Architect
1215
+ - **基础URL**: {base_url}
1216
+
1217
+ ### 设计原则
1218
+ - **RESTful**: 遵循REST架构风格
1219
+ - **统一响应**: 统一的响应数据格式
1220
+ - **版本控制**: 支持API版本管理
1221
+ - **安全性**: 完整的认证和授权机制
1222
+ - **文档化**: 完整的接口文档和示例
1223
+
1224
+ - id: global_standards
1225
+ title: 全局规范
1226
+ required: true
1227
+ template: |
1228
+ ## 全局规范
1229
+
1230
+ ### HTTP状态码规范
1231
+ | 状态码 | 含义 | 使用场景 |
1232
+ |--------|------|----------|
1233
+ | 200 | OK | 请求成功 |
1234
+ | 201 | Created | 资源创建成功 |
1235
+ | 204 | No Content | 删除成功,无返回内容 |
1236
+ | 400 | Bad Request | 请求参数错误 |
1237
+ | 401 | Unauthorized | 未认证 |
1238
+ | 403 | Forbidden | 无权限 |
1239
+ | 404 | Not Found | 资源不存在 |
1240
+ | 409 | Conflict | 资源冲突 |
1241
+ | 422 | Unprocessable Entity | 参数验证失败 |
1242
+ | 500 | Internal Server Error | 服务器内部错误 |
1243
+
1244
+ ### 统一响应格式
1245
+ ```json
1246
+ {
1247
+ "code": "integer // HTTP状态码",
1248
+ "message": "string // 响应消息",
1249
+ "data": "object|array|null // 响应数据",
1250
+ "timestamp": "string // 时间戳",
1251
+ "path": "string // 请求路径"
1252
+ }
1253
+ ```
1254
+
1255
+ ### 分页响应格式
1256
+ ```json
1257
+ {
1258
+ "code": 200,
1259
+ "message": "查询成功",
1260
+ "data": {
1261
+ "records": [], // 数据列表
1262
+ "total": 100, // 总记录数
1263
+ "size": 10, // 每页大小
1264
+ "current": 1, // 当前页码
1265
+ "pages": 10 // 总页数
1266
+ }
1267
+ }
1268
+ ```
1269
+
1270
+ ### 请求头规范
1271
+ | 请求头 | 必填 | 说明 |
1272
+ |--------|------|------|
1273
+ | Content-Type | 是 | application/json |
1274
+ | Authorization | 是 | Bearer {token} |
1275
+ | X-Request-ID | 否 | 请求追踪ID |
1276
+ | Accept-Language | 否 | 语言偏好 |
1277
+
1278
+ ### 错误响应格式
1279
+ ```json
1280
+ {
1281
+ "code": 400,
1282
+ "message": "参数验证失败",
1283
+ "data": {
1284
+ "errors": [
1285
+ {
1286
+ "field": "username",
1287
+ "message": "用户名不能为空"
1288
+ }
1289
+ ]
1290
+ },
1291
+ "timestamp": "2024-01-01T12:00:00Z",
1292
+ "path": "/api/users"
1293
+ }
1294
+ ```
1295
+
1296
+ - id: authentication
1297
+ title: 认证授权
1298
+ required: true
1299
+ template: |
1300
+ ## 认证授权
1301
+
1302
+ ### JWT Token规范
1303
+ ```
1304
+ Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
1305
+ ```
1306
+
1307
+ ### Token结构
1308
+ ```json
1309
+ {
1310
+ "header": {
1311
+ "alg": "HS256",
1312
+ "typ": "JWT"
1313
+ },
1314
+ "payload": {
1315
+ "sub": "user_id",
1316
+ "username": "johndoe",
1317
+ "roles": ["USER", "ADMIN"],
1318
+ "exp": 1640995200,
1319
+ "iat": 1640908800
1320
+ }
1321
+ }
1322
+ ```
1323
+
1324
+ ### 权限控制
1325
+ | 角色 | 权限描述 | 可访问资源 |
1326
+ |------|----------|------------|
1327
+ | ADMIN | 管理员权限 | 所有资源 |
1328
+ | USER | 普通用户权限 | 用户相关资源 |
1329
+ | GUEST | 访客权限 | 公开资源 |
1330
+
1331
+ - id: api_endpoints
1332
+ title: API端点设计
1333
+ required: true
1334
+ template: |
1335
+ ## API端点设计
1336
+
1337
+ {for_each_entity}
1338
+ ### {entity_name} API
1339
+
1340
+ #### 基础信息
1341
+ - **资源名称**: {entity_name}
1342
+ - **数据库表**: {table_name}
1343
+ - **基础路径**: /api/{entity_lowercase}
1344
+
1345
+ #### 端点列表
1346
+ | HTTP方法 | 路径 | 操作 | 说明 |
1347
+ |----------|------|------|------|
1348
+ | GET | /api/{entity_lowercase} | 查询列表 | 分页查询{entity_name}列表 |
1349
+ | GET | /api/{entity_lowercase}/{id} | 查询详情 | 根据ID查询{entity_name}详情 |
1350
+ | POST | /api/{entity_lowercase} | 创建 | 创建新的{entity_name} |
1351
+ | PUT | /api/{entity_lowercase}/{id} | 更新 | 更新{entity_name}信息 |
1352
+ | DELETE | /api/{entity_lowercase}/{id} | 删除 | 删除{entity_name} |
1353
+
1354
+ #### 1. 查询{entity_name}列表
1355
+
1356
+ **接口描述**: 分页查询{entity_name}列表,支持条件筛选
1357
+ **HTTP方法**: GET
1358
+ **请求路径**: /api/{entity_lowercase}
1359
+ **权限要求**: {required_permissions}
1360
+
1361
+ **请求参数**:
1362
+ ```
1363
+ Query Parameters:
1364
+ - page: integer (可选, 默认1) // 页码
1365
+ - size: integer (可选, 默认10) // 每页大小
1366
+ - sort: string (可选) // 排序字段,格式:field,direction
1367
+ {query_parameters}
1368
+ ```
1369
+
1370
+ **请求示例**:
1371
+ ```bash
1372
+ curl -X GET "{base_url}/api/{entity_lowercase}?page=1&size=10&sort=createdAt,desc" \
1373
+ -H "Authorization: Bearer {token}" \
1374
+ -H "Content-Type: application/json"
1375
+ ```
1376
+
1377
+ **成功响应** (200):
1378
+ ```json
1379
+ {
1380
+ "code": 200,
1381
+ "message": "查询成功",
1382
+ "data": {
1383
+ "records": [
1384
+ {
1385
+ {response_fields}
1386
+ }
1387
+ ],
1388
+ "total": 100,
1389
+ "size": 10,
1390
+ "current": 1,
1391
+ "pages": 10
1392
+ },
1393
+ "timestamp": "2024-01-01T12:00:00Z",
1394
+ "path": "/api/{entity_lowercase}"
1395
+ }
1396
+ ```
1397
+
1398
+ #### 2. 查询{entity_name}详情
1399
+
1400
+ **接口描述**: 根据ID查询{entity_name}详细信息
1401
+ **HTTP方法**: GET
1402
+ **请求路径**: /api/{entity_lowercase}/{id}
1403
+ **权限要求**: {required_permissions}
1404
+
1405
+ **路径参数**:
1406
+ ```
1407
+ - id: integer (必填) // {entity_name}的唯一标识
1408
+ ```
1409
+
1410
+ **请求示例**:
1411
+ ```bash
1412
+ curl -X GET "{base_url}/api/{entity_lowercase}/123" \
1413
+ -H "Authorization: Bearer {token}" \
1414
+ -H "Content-Type: application/json"
1415
+ ```
1416
+
1417
+ **成功响应** (200):
1418
+ ```json
1419
+ {
1420
+ "code": 200,
1421
+ "message": "查询成功",
1422
+ "data": {
1423
+ {detail_response_fields}
1424
+ },
1425
+ "timestamp": "2024-01-01T12:00:00Z",
1426
+ "path": "/api/{entity_lowercase}/123"
1427
+ }
1428
+ ```
1429
+
1430
+ **错误响应** (404):
1431
+ ```json
1432
+ {
1433
+ "code": 404,
1434
+ "message": "{entity_name}不存在",
1435
+ "data": null,
1436
+ "timestamp": "2024-01-01T12:00:00Z",
1437
+ "path": "/api/{entity_lowercase}/123"
1438
+ }
1439
+ ```
1440
+
1441
+ #### 3. 创建{entity_name}
1442
+
1443
+ **接口描述**: 创建新的{entity_name}记录
1444
+ **HTTP方法**: POST
1445
+ **请求路径**: /api/{entity_lowercase}
1446
+ **权限要求**: {required_permissions}
1447
+
1448
+ **请求体**:
1449
+ ```json
1450
+ {
1451
+ {create_request_fields}
1452
+ }
1453
+ ```
1454
+
1455
+ **请求示例**:
1456
+ ```bash
1457
+ curl -X POST "{base_url}/api/{entity_lowercase}" \
1458
+ -H "Authorization: Bearer {token}" \
1459
+ -H "Content-Type: application/json" \
1460
+ -d '{
1461
+ {create_request_example}
1462
+ }'
1463
+ ```
1464
+
1465
+ **成功响应** (201):
1466
+ ```json
1467
+ {
1468
+ "code": 201,
1469
+ "message": "创建成功",
1470
+ "data": {
1471
+ {create_response_fields}
1472
+ },
1473
+ "timestamp": "2024-01-01T12:00:00Z",
1474
+ "path": "/api/{entity_lowercase}"
1475
+ }
1476
+ ```
1477
+
1478
+ **参数验证失败** (422):
1479
+ ```json
1480
+ {
1481
+ "code": 422,
1482
+ "message": "参数验证失败",
1483
+ "data": {
1484
+ "errors": [
1485
+ {
1486
+ "field": "{field_name}",
1487
+ "message": "{validation_message}"
1488
+ }
1489
+ ]
1490
+ },
1491
+ "timestamp": "2024-01-01T12:00:00Z",
1492
+ "path": "/api/{entity_lowercase}"
1493
+ }
1494
+ ```
1495
+
1496
+ #### 4. 更新{entity_name}
1497
+
1498
+ **接口描述**: 更新{entity_name}信息
1499
+ **HTTP方法**: PUT
1500
+ **请求路径**: /api/{entity_lowercase}/{id}
1501
+ **权限要求**: {required_permissions}
1502
+
1503
+ **路径参数**:
1504
+ ```
1505
+ - id: integer (必填) // {entity_name}的唯一标识
1506
+ ```
1507
+
1508
+ **请求体**:
1509
+ ```json
1510
+ {
1511
+ {update_request_fields}
1512
+ }
1513
+ ```
1514
+
1515
+ **请求示例**:
1516
+ ```bash
1517
+ curl -X PUT "{base_url}/api/{entity_lowercase}/123" \
1518
+ -H "Authorization: Bearer {token}" \
1519
+ -H "Content-Type: application/json" \
1520
+ -d '{
1521
+ {update_request_example}
1522
+ }'
1523
+ ```
1524
+
1525
+ **成功响应** (200):
1526
+ ```json
1527
+ {
1528
+ "code": 200,
1529
+ "message": "更新成功",
1530
+ "data": {
1531
+ {update_response_fields}
1532
+ },
1533
+ "timestamp": "2024-01-01T12:00:00Z",
1534
+ "path": "/api/{entity_lowercase}/123"
1535
+ }
1536
+ ```
1537
+
1538
+ #### 5. 删除{entity_name}
1539
+
1540
+ **接口描述**: 删除{entity_name}记录(软删除)
1541
+ **HTTP方法**: DELETE
1542
+ **请求路径**: /api/{entity_lowercase}/{id}
1543
+ **权限要求**: {required_permissions}
1544
+
1545
+ **路径参数**:
1546
+ ```
1547
+ - id: integer (必填) // {entity_name}的唯一标识
1548
+ ```
1549
+
1550
+ **请求示例**:
1551
+ ```bash
1552
+ curl -X DELETE "{base_url}/api/{entity_lowercase}/123" \
1553
+ -H "Authorization: Bearer {token}" \
1554
+ -H "Content-Type: application/json"
1555
+ ```
1556
+
1557
+ **成功响应** (204):
1558
+ ```
1559
+ HTTP/1.1 204 No Content
1560
+ ```
1561
+
1562
+ **错误响应** (404):
1563
+ ```json
1564
+ {
1565
+ "code": 404,
1566
+ "message": "{entity_name}不存在",
1567
+ "data": null,
1568
+ "timestamp": "2024-01-01T12:00:00Z",
1569
+ "path": "/api/{entity_lowercase}/123"
1570
+ }
1571
+ ```
1572
+
1573
+ #### 数据字段映射
1574
+
1575
+ **数据库字段 -> API响应字段映射**:
1576
+ | 数据库字段 | API字段 | 数据类型 | 说明 |
1577
+ |------------|---------|----------|------|
1578
+ {field_mappings}
1579
+
1580
+ **API请求字段 -> 数据库字段映射**:
1581
+ | API字段 | 数据库字段 | 数据类型 | 验证规则 |
1582
+ |---------|------------|----------|----------|
1583
+ {request_field_mappings}
1584
+
1585
+ #### 业务规则说明
1586
+ {business_rules}
1587
+
1588
+ {end_for_each}
1589
+
1590
+ - id: data_types
1591
+ title: 数据类型规范
1592
+ required: true
1593
+ template: |
1594
+ ## 数据类型规范
1595
+
1596
+ ### 基础数据类型
1597
+ | API类型 | JSON类型 | 数据库类型 | 说明 | 示例 |
1598
+ |---------|----------|------------|------|------|
1599
+ | integer | number | INT/BIGINT | 整数 | 123 |
1600
+ | decimal | number | DECIMAL | 小数 | 123.45 |
1601
+ | string | string | VARCHAR/TEXT | 字符串 | "hello" |
1602
+ | boolean | boolean | TINYINT | 布尔值 | true/false |
1603
+ | datetime | string | DATETIME | 日期时间 | "2024-01-01T12:00:00Z" |
1604
+ | date | string | DATE | 日期 | "2024-01-01" |
1605
+ | time | string | TIME | 时间 | "12:00:00" |
1606
+ | array | array | JSON | 数组 | [1,2,3] |
1607
+ | object | object | JSON | 对象 | {"key":"value"} |
1608
+
1609
+ ### 特殊字段规范
1610
+ | 字段类型 | 字段名 | 数据类型 | 说明 |
1611
+ |----------|--------|----------|------|
1612
+ | 主键 | id | integer | 自增主键 |
1613
+ | 创建时间 | createdAt | datetime | 记录创建时间 |
1614
+ | 更新时间 | updatedAt | datetime | 记录更新时间 |
1615
+ | 删除时间 | deletedAt | datetime | 软删除时间 |
1616
+ | 版本号 | version | integer | 乐观锁版本 |
1617
+
1618
+ ### 日期时间格式
1619
+ - **标准格式**: ISO 8601 (2024-01-01T12:00:00Z)
1620
+ - **时区**: UTC时间
1621
+ - **精度**: 秒级
1622
+
1623
+ - id: validation_rules
1624
+ title: 参数验证规则
1625
+ required: true
1626
+ template: |
1627
+ ## 参数验证规则
1628
+
1629
+ ### 通用验证规则
1630
+ | 规则类型 | 说明 | 示例 |
1631
+ |----------|------|------|
1632
+ | required | 必填字段 | @NotNull, @NotBlank |
1633
+ | length | 长度限制 | @Size(min=1, max=50) |
1634
+ | pattern | 格式验证 | @Pattern(regexp="^[a-zA-Z0-9]+$") |
1635
+ | range | 数值范围 | @Min(0), @Max(100) |
1636
+ | email | 邮箱格式 | @Email |
1637
+ | phone | 手机号格式 | @Pattern(regexp="^1[3-9]\\d{9}$") |
1638
+
1639
+ ### 业务验证规则
1640
+ {business_validation_rules}
1641
+
1642
+ ### 错误信息国际化
1643
+ ```properties
1644
+ validation.required=字段不能为空
1645
+ validation.length=字段长度必须在{min}到{max}之间
1646
+ validation.pattern=字段格式不正确
1647
+ validation.email=邮箱格式不正确
1648
+ validation.phone=手机号格式不正确
1649
+ ```
1650
+
1651
+ - id: error_codes
1652
+ title: 错误码定义
1653
+ required: true
1654
+ template: |
1655
+ ## 错误码定义
1656
+
1657
+ ### 系统级错误码 (1000-1999)
1658
+ | 错误码 | 错误信息 | 说明 | 处理建议 |
1659
+ |--------|----------|------|----------|
1660
+ | 1000 | 系统错误 | 未知系统错误 | 联系技术支持 |
1661
+ | 1001 | 参数错误 | 请求参数不正确 | 检查参数格式 |
1662
+ | 1002 | 认证失败 | 身份认证失败 | 重新登录 |
1663
+ | 1003 | 权限不足 | 无访问权限 | 联系管理员 |
1664
+ | 1004 | 资源不存在 | 请求的资源不存在 | 检查资源ID |
1665
+ | 1005 | 资源冲突 | 资源已存在或冲突 | 检查数据唯一性 |
1666
+
1667
+ ### 业务级错误码 (2000+)
1668
+ {business_error_codes}
1669
+
1670
+ ### 错误响应示例
1671
+ ```json
1672
+ {
1673
+ "code": 1001,
1674
+ "message": "参数错误",
1675
+ "data": {
1676
+ "errorCode": "PARAM_INVALID",
1677
+ "errorDetails": "用户名格式不正确"
1678
+ },
1679
+ "timestamp": "2024-01-01T12:00:00Z",
1680
+ "path": "/api/users"
1681
+ }
1682
+ ```
1683
+
1684
+ - id: performance
1685
+ title: 性能规范
1686
+ required: true
1687
+ template: |
1688
+ ## 性能规范
1689
+
1690
+ ### 响应时间要求
1691
+ | 接口类型 | 响应时间要求 | 说明 |
1692
+ |----------|--------------|------|
1693
+ | 查询接口 | < 200ms | 简单查询 |
1694
+ | 复杂查询 | < 1s | 包含关联查询 |
1695
+ | 创建接口 | < 500ms | 数据创建 |
1696
+ | 更新接口 | < 500ms | 数据更新 |
1697
+ | 删除接口 | < 300ms | 数据删除 |
1698
+
1699
+ ### 分页限制
1700
+ - 默认页大小: 10
1701
+ - 最大页大小: 100
1702
+ - 支持的排序字段: {sortable_fields}
1703
+
1704
+ ### 缓存策略
1705
+ | 数据类型 | 缓存时间 | 缓存键规则 |
1706
+ |----------|----------|------------|
1707
+ | 用户信息 | 30分钟 | user:{user_id} |
1708
+ | 配置信息 | 1小时 | config:{config_key} |
1709
+ | 静态数据 | 24小时 | static:{data_type} |
1710
+
1711
+ - id: security
1712
+ title: 安全规范
1713
+ required: true
1714
+ template: |
1715
+ ## 安全规范
1716
+
1717
+ ### 数据安全
1718
+ - **敏感数据加密**: 密码、身份证号等
1719
+ - **数据脱敏**: 日志中的敏感信息
1720
+ - **SQL注入防护**: 使用参数化查询
1721
+ - **XSS防护**: 输入数据过滤和转义
1722
+
1723
+ ### 接口安全
1724
+ - **HTTPS传输**: 强制使用HTTPS
1725
+ - **请求签名**: 关键接口要求签名验证
1726
+ - **频率限制**: 防止恶意请求
1727
+ - **IP白名单**: 敏感接口IP限制
1728
+
1729
+ ### 认证安全
1730
+ - **Token过期**: JWT token有效期控制
1731
+ - **刷新机制**: Token自动刷新
1732
+ - **会话管理**: 用户会话状态管理
1733
+ - **密码策略**: 密码复杂度要求
1734
+
1735
+ - id: testing
1736
+ title: 测试规范
1737
+ required: true
1738
+ template: |
1739
+ ## 测试规范
1740
+
1741
+ ### API测试用例
1742
+
1743
+ **测试用例模板**:
1744
+ ```yaml
1745
+ test_case:
1746
+ name: "创建用户成功"
1747
+ method: POST
1748
+ url: "/api/users"
1749
+ headers:
1750
+ Authorization: "Bearer {valid_token}"
1751
+ Content-Type: "application/json"
1752
+ body:
1753
+ username: "testuser"
1754
+ email: "test@example.com"
1755
+ password: "Test123456!"
1756
+ expected:
1757
+ status: 201
1758
+ body:
1759
+ code: 201
1760
+ message: "创建成功"
1761
+ data:
1762
+ id: "{integer}"
1763
+ username: "testuser"
1764
+ email: "test@example.com"
1765
+ ```
1766
+
1767
+ ### 测试数据
1768
+ ```yaml
1769
+ test_data:
1770
+ valid_user:
1771
+ username: "validuser"
1772
+ email: "valid@example.com"
1773
+ password: "Valid123456!"
1774
+ invalid_user:
1775
+ username: "" # 空用户名
1776
+ email: "invalid-email" # 无效邮箱
1777
+ password: "123" # 密码过短
1778
+ ```
1779
+
1780
+ ### 性能测试
1781
+ - **并发用户数**: 100
1782
+ - **测试时长**: 10分钟
1783
+ - **响应时间**: 95%请求 < 1s
1784
+ - **成功率**: > 99.9%
1785
+
1786
+ - id: documentation
1787
+ title: 文档规范
1788
+ required: true
1789
+ template: |
1790
+ ## 文档规范
1791
+
1792
+ ### Swagger/OpenAPI规范
1793
+ ```yaml
1794
+ openapi: 3.0.0
1795
+ info:
1796
+ title: {project_name} API
1797
+ version: {api_version}
1798
+ description: {project_description}
1799
+ servers:
1800
+ - url: {base_url}
1801
+ description: 生产环境
1802
+ paths:
1803
+ /api/{entity_lowercase}:
1804
+ get:
1805
+ summary: 查询{entity_name}列表
1806
+ tags: [{entity_name}]
1807
+ parameters:
1808
+ - name: page
1809
+ in: query
1810
+ schema:
1811
+ type: integer
1812
+ default: 1
1813
+ responses:
1814
+ '200':
1815
+ description: 查询成功
1816
+ content:
1817
+ application/json:
1818
+ schema:
1819
+ $ref: '#/components/schemas/PageResult'
1820
+ ```
1821
+
1822
+ ### 接口文档要求
1823
+ - **完整性**: 包含所有接口信息
1824
+ - **准确性**: 与实际实现保持一致
1825
+ - **实时性**: 及时更新文档内容
1826
+ - **可读性**: 清晰的描述和示例
1827
+
1828
+ ### 示例代码
1829
+ ```javascript
1830
+ // JavaScript调用示例
1831
+ const response = await fetch('/api/users', {
1832
+ method: 'POST',
1833
+ headers: {
1834
+ 'Content-Type': 'application/json',
1835
+ 'Authorization': 'Bearer ' + token
1836
+ },
1837
+ body: JSON.stringify({
1838
+ username: 'johndoe',
1839
+ email: 'john@example.com'
1840
+ })
1841
+ });
1842
+ const result = await response.json();
1843
+ ```
1844
+
1845
+ - id: versioning
1846
+ title: 版本管理
1847
+ required: true
1848
+ template: |
1849
+ ## 版本管理
1850
+
1851
+ ### 版本号规范
1852
+ - **格式**: v{major}.{minor}.{patch}
1853
+ - **示例**: v1.0.0, v1.1.0, v2.0.0
1854
+
1855
+ ### 版本策略
1856
+ | 版本类型 | 变更说明 | 兼容性 |
1857
+ |----------|----------|--------|
1858
+ | Major | 重大功能变更,API不兼容 | 不兼容 |
1859
+ | Minor | 新增功能,向后兼容 | 向后兼容 |
1860
+ | Patch | Bug修复,向后兼容 | 向后兼容 |
1861
+
1862
+ ### 版本控制方式
1863
+ 1. **URL路径版本**: /api/v1/users
1864
+ 2. **请求头版本**: API-Version: v1
1865
+ 3. **参数版本**: /api/users?version=v1
1866
+
1867
+ ### 版本生命周期
1868
+ - **开发版本**: v1.0.0-dev
1869
+ - **测试版本**: v1.0.0-beta
1870
+ - **发布版本**: v1.0.0
1871
+ - **废弃版本**: 提前3个月通知
1872
+
1873
+ - id: changelog
1874
+ title: 变更记录
1875
+ required: true
1876
+ template: |
1877
+ ## 变更记录
1878
+
1879
+ ### v1.0.0 (2024-01-01)
1880
+ **新增功能**:
1881
+ - 初始API设计
1882
+ - 用户管理接口
1883
+ - 认证授权机制
1884
+
1885
+ **修复问题**:
1886
+ - 无
1887
+
1888
+ **破坏性变更**:
1889
+ - 无
1890
+
1891
+ ### 变更记录模板
1892
+ ```markdown
1893
+ ### v{version} ({date})
1894
+ **新增功能**:
1895
+ - 功能描述
1896
+
1897
+ **修复问题**:
1898
+ - 问题描述
1899
+
1900
+ **破坏性变更**:
1901
+ - 变更描述
1902
+ ```
1903
+ ==================== END: .xiaoma-core/templates/api-design-tmpl.yaml ====================
1904
+
510
1905
  ==================== START: .xiaoma-core/checklists/story-draft-checklist.md ====================
511
1906
  <!-- Powered by XiaoMa™ Core -->
512
1907