Code Generation Advanced
Core Positioning
The code generator is RuoYi’s “nuclear weapon” for development efficiency. Regular single-table CRUD can no longer satisfy complex business scenarios. Here we introduce three advanced generation modes, covering the most common complex page patterns in enterprise development.
With these capabilities, a complex business page containing master-child tables and approval flows goes from “days of coding” to “minutes of configuration.”
Suitable Users
| Scenario | Recommended Mode | Effect |
|---|---|---|
| Order + Line Items | Master-Child Standard Mode | Same dialog, master-child tables edited together |
| Work Order + Processes | Master-Child Embedded Mode | Expand child table directly in list |
| Purchase Order + Details | Master-Child ERP Mode | Independent master and child lists, independent forms |
| Department Tree/Category Tree | Tree Table Mode | Auto-generate tree table |
| Mobile Pages | uni-app Mode | Generate pages compatible with H5/Mini Programs |
Three Master-Child Table Generation Modes
graph TB
subgraph StandardMode["Mode 1: Standard Mode"]
S1["Master Table List Page"]
S2["Click Add → Dialog"]
S3["Dialog: Master Form + Child Table
Edit in same dialog"] S1 --> S2 --> S3 end subgraph EmbeddedMode["Mode 2: Embedded Mode"] I1["Master Table List Page"] I2["Expand Row → Embedded Child Table
Child table shown directly below master row"] I1 --> I2 end subgraph ERPMode["Mode 3: ERP Mode"] E1["Master Table Independent List"] E2["Child Table Independent List
(Linked by master table ID)"] E3["Master Table Independent Form"] E4["Child Table Independent Form"] E1 --> E2 E3 --> E4 end
Edit in same dialog"] S1 --> S2 --> S3 end subgraph EmbeddedMode["Mode 2: Embedded Mode"] I1["Master Table List Page"] I2["Expand Row → Embedded Child Table
Child table shown directly below master row"] I1 --> I2 end subgraph ERPMode["Mode 3: ERP Mode"] E1["Master Table Independent List"] E2["Child Table Independent List
(Linked by master table ID)"] E3["Master Table Independent Form"] E4["Child Table Independent Form"] E1 --> E2 E3 --> E4 end
Mode Applicable Scenarios
| Mode | Use Case | User Experience | Representative Business |
|---|---|---|---|
| Standard Mode | Small master-child data volume, master+child need to be filled together | ⭐⭐⭐⭐ Smooth operation | Surveys+Questions, Config+Config Items |
| Embedded Mode | Need to quickly view child data without navigating away | ⭐⭐⭐⭐⭐ High info density | Work Orders+Processes, Tasks+Subtasks |
| ERP Mode | Master and child each have independent business logic, large data volume | ⭐⭐⭐ High flexibility | Purchase Orders+Details, Sales Orders+Details |
Tree Table Code Generation
graph LR
DEPT["Department Table
id / parent_id / name"] GEN["Code Generator
Recognizes parent_id field"] OUT["Generate Tree Table Page
el-tree + Drag & Drop Sorting"] DEPT --> GEN --> OUT
id / parent_id / name"] GEN["Code Generator
Recognizes parent_id field"] OUT["Generate Tree Table Page
el-tree + Drag & Drop Sorting"] DEPT --> GEN --> OUT
Supports unlimited levels, auto-generates expand/collapse, drag-and-drop sorting, add child node, and other features.
uni-app Code Generation
Generate complete page code for mobile, supporting:
- List pages (pull-to-refresh, load more)
- Form pages
- Detail pages
- API request encapsulation
Frontend Version Support
| Generation Target | Vue3 Admin | Vben5 | Vue2 | uni-app |
|---|---|---|---|---|
| Single Table CRUD | ✅ | ✅ | ✅ | ✅ |
| Master-Child Standard | ✅ | ✅ | ✅ | ❌ |
| Master-Child Embedded | ✅ | ✅ | ✅ | ❌ |
| Master-Child ERP | ✅ | ✅ | ✅ | ❌ |
| Tree Table | ✅ | ✅ | ✅ | ❌ |
Usage Process
- Create table structure in the database
- Import tables in the “Code Generation” menu
- Configure generation options (module name, business name, class name, generation mode)
- Preview and generate code
- Copy code to the project, configure menu to use