Files
yidaima/RuoYi-Vue/docs/superpowers/plans/2026-05-26-frontend-action-slots.md

4.1 KiB

Frontend Action Slots Implementation Plan

For agentic workers: REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (- [ ]) syntax for tracking.

Goal: Add a generic page-slot binding layer so generated frontend menus can receive specific business actions on list rows or detail page buttons.

Architecture: Extend the existing blueprint DTOs and safe business-action DSL. Keep backend action generation table-owned, but add frontend slot grouping for Velocity templates and compatibility fallback for legacy projects.

Tech Stack: Java 8, Spring Boot, Jackson/Fastjson2, Velocity, JUnit 4, Mockito, Vue3, Element Plus.


Task 1: Add DTOs And Request Propagation

Files:

  • Create: ruoyi-generator/src/main/java/com/ruoyi/generator/domain/front/dto/AppPageDesign.java

  • Create: ruoyi-generator/src/main/java/com/ruoyi/generator/domain/front/dto/BusinessActionUiBindingDesign.java

  • Modify: ruoyi-generator/src/main/java/com/ruoyi/generator/domain/front/dto/AppBlueprintDesign.java

  • Modify: ruoyi-generator/src/main/java/com/ruoyi/generator/domain/front/dto/BusinessActionDesign.java

  • Modify: ruoyi-generator/src/main/java/com/ruoyi/generator/domain/front/dto/GenerateBusinessBlueprintRequest.java

  • Modify: ruoyi-generator/src/main/java/com/ruoyi/generator/service/front/AiGenerationTaskWorker.java

  • Test: ruoyi-generator/src/test/java/com/ruoyi/generator/service/front/AiGenerationTaskServiceImplTest.java

  • Add failing test that proves app blueprint is available when a business_blueprint task executes.

  • Run mvn -pl ruoyi-generator -Dtest=AiGenerationTaskServiceImplTest test and verify RED.

  • Add DTO fields and copy source.getAppBlueprint() into GenerateBusinessBlueprintRequest.

  • Re-run the targeted test and verify GREEN.

Task 2: Prompt And Validation

Files:

  • Modify: ruoyi-generator/src/main/java/com/ruoyi/generator/service/front/AiGenerateServiceImpl.java

  • Modify: ruoyi-generator/src/main/java/com/ruoyi/generator/service/front/AiBusinessBlueprintValidator.java

  • Test: ruoyi-generator/src/test/java/com/ruoyi/generator/service/front/AiGenerateServiceImplTest.java

  • Add failing tests for valid uiBindings and unknown pageCode.

  • Run mvn -pl ruoyi-generator -Dtest=AiGenerateServiceImplTest test and verify RED.

  • Include app blueprint JSON and page-slot instructions in the business blueprint prompt.

  • Normalize empty binding collections and validate page codes, slots, components, targets, and input mappings.

  • Re-run targeted tests and verify GREEN.

Task 3: Slot Grouping For Velocity

Files:

  • Modify: ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenProjectServiceImpl.java

  • Test: ruoyi-generator/src/test/java/com/ruoyi/generator/service/GenProjectServiceImplTest.java

  • Add failing test that expects slotBusinessActions to group actions by pageCode:slot.

  • Run mvn -pl ruoyi-generator -Dtest=GenProjectServiceImplTest test and verify RED.

  • Build slotBusinessActions in prepareVelocityContext for table templates.

  • Keep tableBusinessActions as compatibility fallback.

  • Re-run targeted tests and verify GREEN.

Task 4: Vue3 Template Slots

Files:

  • Modify: sql/business_blueprint_templates.sql

  • Modify: sql/db.sql

  • Test: ruoyi-generator/src/test/java/com/ruoyi/generator/service/GenProjectServiceImplTest.java

  • Add failing template assertions for list.rowActions and detail.primaryActions.

  • Run mvn -pl ruoyi-generator -Dtest=GenProjectServiceImplTest test and verify RED.

  • Update Vue3 list template to render row slot actions.

  • Update Vue3 detail template to render detail primary actions.

  • Sync the same template seed into sql/db.sql.

  • Re-run targeted tests and verify GREEN.

Task 5: Verification

  • Run mvn -pl ruoyi-generator -Dtest=AiGenerateServiceImplTest,AiGenerationTaskServiceImplTest,GenProjectServiceImplTest test.
  • Run relevant frontend unit tests if changed files require it.
  • Inspect git diff --stat to ensure only expected files changed.