template-structure.mdc 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ---
  2. description:
  3. globs:
  4. alwaysApply: true
  5. ---
  6. # Template Structure Guide
  7. ## Directory Organization
  8. ```
  9. CGTM/
  10. ├── single/ # Single table CRUD templates
  11. ├── multiple/ # Master-detail table templates
  12. ├── common/ # Shared templates across modules
  13. ├── vform/ # Visual form designer templates
  14. └── config.json # Template configuration mapping
  15. ```
  16. ## Template Configuration
  17. The [config.json](mdc:config.json) file defines template groups and their mappings:
  18. ```json
  19. {
  20. "单表增删改查": [...], // Single table templates
  21. "主子表增删改查": [...], // Master-detail templates
  22. "vform": [...] // VForm templates
  23. }
  24. ```
  25. Each template entry contains:
  26. - `templateName`: Display name of the template
  27. - `generatorPath`: Output path with variable substitution
  28. - `templateFile`: Source template file location
  29. ## Single Table Templates
  30. Located in the [single/](mdc:single) directory:
  31. - [Controller.java](mdc:single/Controller.java) - REST API endpoints
  32. - [Service.java](mdc:single/Service.java) - Business logic interface
  33. - [ServiceImpl.java](mdc:single/ServiceImpl.java) - Service implementation
  34. - [实体.java](mdc:single/实体.java) - JPA/MyBatis entity
  35. - [Mapper.java](mdc:single/Mapper.java) - MyBatis mapper interface
  36. - [Mapper.xml](mdc:single/Mapper.xml) - SQL mappings
  37. - [表格.vue](mdc:single/表格.vue) - Data table component
  38. - [表单.vue](mdc:single/表单.vue) - Form component
  39. ## Master-Detail Templates
  40. Located in the [multiple/](mdc:multiple) directory:
  41. - [主子Contoller.java](mdc:multiple/主子Contoller.java) - Parent-child REST APIs
  42. - [主子Service.java](mdc:multiple/主子Service.java) - Complex business logic
  43. - [主子ServiceImpl.java](mdc:multiple/主子ServiceImpl.java) - Implementation with transactions
  44. - [主实体.java](mdc:multiple/主实体.java) - Parent entity
  45. - [子实体.java](mdc:multiple/子实体.java) - Child entity
  46. - [子Mapper.java](mdc:multiple/子Mapper.java) - Child table mapper
  47. - [主子表格.vue](mdc:multiple/主子表格.vue) - Parent-child data display
  48. - [主子表单.vue](mdc:multiple/主子表单.vue) - Nested form handling
  49. ## Common Templates
  50. Located in the [common/](mdc:common) directory:
  51. - [api.ts](mdc:common/api.ts) - TypeScript API client
  52. - [权限菜单.sql](mdc:common/权限菜单.sql) - Permission and menu SQL
  53. - [i18n中文模板.ts](mdc:common/i18n中文模板.ts) - Chinese translations
  54. - [i18n英文模板.ts](mdc:common/i18n英文模板.ts) - English translations
  55. ## Path Variables
  56. Template paths support these variables:
  57. - `${backendPath}` - Backend project root
  58. - `${frontendPath}` - Frontend project root
  59. - `${packagePath}` - Java package path (com/example/app)
  60. - `${moduleName}` - Module name
  61. - `${ClassName}` - Entity class name
  62. - `${functionName}` - Function/feature name