Commit Graph

11 Commits

Author SHA1 Message Date
12faa04a7e fix: route issues 2025-12-17 23:42:40 +08:00
Rogee
13e721532d feat: 检查路径参数是否包含模型字段并相应地导入字段包 2025-09-23 15:40:09 +08:00
Rogee
439456b6ad fix: 恢复 gen route 的 model 参数渲染到 f2a8b98 实现
- 恢复 buildParamToken 函数的直接实现,移除复杂的 builder 模式
- 恢复 buildRenderData 函数的简单实现,提高代码可读性
- 恢复 Render 函数的基础实现,移除过度工程化的验证逻辑
- 修复路由分组路径问题:移除 buildResult 中错误的路径覆盖逻辑
- 当使用 model() 绑定时生成完整的数据库查询函数代码

此提交将 gen route 功能恢复到 commit f2a8b9876e
的实现方式,确保 model 参数渲染符合原始设计。

修复问题:
- 修复路由生成时 "open /v1/medias/routes.gen.go: no such file or directory" 错误
- 确保 model 参数正确生成完整的数据库查询代码而非简化接口
2025-09-22 19:01:40 +08:00
Rogee
07e70a80ea feat: 优化参数构建逻辑,简化模型接口,移除不必要的字段导入 2025-09-22 13:22:03 +08:00
Rogee
824861c27c feat: Refactor AST generation routes workflow
- Introduced a comprehensive data model for route definitions, parameters, and validation rules.
- Established component interfaces for route parsing, comment parsing, import resolution, route building, validation, and rendering.
- Developed a detailed implementation plan outlining execution flow, user requirements, and compliance with design principles.
- Created a quickstart guide to assist users in utilizing the refactored system effectively.
- Conducted thorough research on existing architecture, identifying key improvements and establishing a refactoring strategy.
- Specified functional requirements and user scenarios to ensure clarity and testability.
- Generated a task list for implementation, emphasizing test-driven development and parallel execution where applicable.
2025-09-22 11:33:13 +08:00
Rogee
e1f83ae469 feat: 重构 pkg/ast/provider 模块,优化代码组织逻辑和功能实现
## 主要改进

### 架构重构
- 将单体 provider.go 拆分为多个专门的模块文件
- 实现了清晰的职责分离和模块化设计
- 遵循 SOLID 原则,提高代码可维护性

### 新增功能
- **验证规则系统**: 实现了完整的 provider 验证框架
- **报告生成器**: 支持多种格式的验证报告 (JSON/HTML/Markdown/Text)
- **解析器优化**: 重新设计了解析流程,提高性能和可扩展性
- **错误处理**: 增强了错误处理和诊断能力

### 修复关键 Bug
- 修复 @provider(job) 注解缺失 __job 注入参数的问题
- 统一了 job 和 cronjob 模式的处理逻辑
- 确保了 provider 生成的正确性和一致性

### 代码质量提升
- 添加了完整的测试套件
- 引入了 golangci-lint 代码质量检查
- 优化了代码格式和结构
- 增加了详细的文档和规范

### 文件结构优化
```
pkg/ast/provider/
├── types.go              # 类型定义
├── parser.go             # 解析器实现
├── validator.go          # 验证规则
├── report_generator.go   # 报告生成
├── renderer.go           # 渲染器
├── comment_parser.go     # 注解解析
├── modes.go             # 模式定义
├── errors.go            # 错误处理
└── validator_test.go    # 测试文件
```

### 兼容性
- 保持向后兼容性
- 支持现有的所有 provider 模式
- 优化了 API 设计和用户体验

This completes the implementation of T025-T029 tasks following TDD principles,
including validation rules implementation and critical bug fixes.
2025-09-19 18:58:30 +08:00
Rogee
82c94d5a29 complete route generator 2025-09-11 22:43:52 +08:00
Rogee
f2a8b9876e update route 2025-09-11 22:40:00 +08:00
Rogee
76c7592f26 feat: 添加对 @Bind 注释中 model 字段的支持,优化路径参数绑定逻辑并更新文档 2025-09-11 20:10:24 +08:00
Rogee
9c910b6ede refactor: 统一代码格式,优化代码可读性 2025-09-11 19:22:47 +08:00
Rogee
344798163b feat: 重构路由渲染逻辑,添加构建渲染数据和模板渲染功能,优化代码结构 2025-09-11 19:14:44 +08:00