development-workflow.mdc 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. ---
  2. description:
  3. globs:
  4. alwaysApply: false
  5. ---
  6. # Development Workflow
  7. ## Using CGTM Templates
  8. ### 1. Template Selection
  9. Choose the appropriate template group based on your needs:
  10. - **单表增删改查** - For simple CRUD operations on a single table
  11. - **主子表增删改查** - For parent-child relationships (e.g., Order-OrderItems)
  12. - **vform** - For visual form designer integration
  13. ### 2. Configuration Setup
  14. Before generating code, ensure these variables are configured:
  15. **Basic Information:**
  16. - `author` - Developer name
  17. - `package` - Base package (e.g., com.pigx.app)
  18. - `moduleName` - Module identifier (e.g., system, business)
  19. - `functionName` - Feature name (e.g., user, product)
  20. **Database Configuration:**
  21. - `tableName` - Database table name
  22. - `tableComment` - Table description
  23. - `fieldList` - Field definitions from database
  24. **Path Configuration:**
  25. - `backendPath` - Backend project root path
  26. - `frontendPath` - Frontend project root path
  27. ### 3. Code Generation Process
  28. 1. **Analyze Database Schema**
  29. - Primary keys are marked with `primaryPk = '1'`
  30. - Auto-fill fields configured (INSERT, UPDATE, INSERT_UPDATE)
  31. - Logical deletion field is `del_flag`
  32. 2. **Generate Backend Code**
  33. - Entity with proper annotations
  34. - Mapper interface and XML
  35. - Service interface and implementation
  36. - Controller with REST endpoints
  37. 3. **Generate Frontend Code**
  38. - API client in TypeScript
  39. - Table component for data display
  40. - Form component for data entry
  41. - i18n translations if needed
  42. 4. **Generate SQL Scripts**
  43. - Permission entries
  44. - Menu configuration
  45. ### 4. Post-Generation Tasks
  46. After code generation:
  47. 1. **Review Generated Code**
  48. - Check import statements
  49. - Verify field mappings
  50. - Ensure proper annotations
  51. 2. **Customize Business Logic**
  52. - Add validation rules
  53. - Implement custom queries
  54. - Add business-specific methods
  55. 3. **Configure Permissions**
  56. - Run generated SQL scripts
  57. - Assign roles and permissions
  58. - Test access control
  59. 4. **Frontend Integration**
  60. - Add routes
  61. - Configure menu items
  62. - Test CRUD operations
  63. ### 5. Master-Detail Specifics
  64. For parent-child relationships:
  65. 1. **Define Relationships**
  66. - `mainField` - Parent table foreign key field
  67. - `childField` - Child table reference field
  68. - Configure cascade operations
  69. 2. **Transaction Management**
  70. - All operations wrapped in transactions
  71. - Proper rollback on errors
  72. - Batch operations for children
  73. 3. **UI Considerations**
  74. - Nested forms for data entry
  75. - Inline editing for child records
  76. - Proper validation across levels
  77. ### 6. Best Practices
  78. - Always use logical deletion (`del_flag`) instead of physical deletion
  79. - Implement proper validation at both frontend and backend
  80. - Use dictionaries for standardized dropdowns
  81. - Follow RESTful conventions for APIs
  82. - Maintain consistent naming conventions
  83. - Add comprehensive API documentation with `@Schema` annotations
  84. - Use permission annotations for security
  85. - Implement audit logging with `@SysLog`