52 lines
2.7 KiB
Markdown
52 lines
2.7 KiB
Markdown
# Home Business Block Auto Composition 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:** Automatically add carousel, notice, and news business blocks to the generated frontend home page when matching tables exist.
|
|
|
|
**Architecture:** Keep `home` as a `business-blocks-v1` page. Add a focused composer that detects table intent from table names/comments and field names/comments, builds valid business block instances, and merges only missing auto-generated blocks into home `layoutJson`.
|
|
|
|
**Tech Stack:** Java, Fastjson2, RuoYi generator services, Velocity business block templates, Vue 2/Element UI generated frontend.
|
|
|
|
---
|
|
|
|
### Task 1: Add Home Composer
|
|
|
|
**Files:**
|
|
- Create: `ruoyi-generator/src/main/java/com/ruoyi/generator/service/front/HomeBusinessBlockComposer.java`
|
|
|
|
- [x] Implement table classification for carousel, notice, and news.
|
|
- [x] Implement field matching for required and optional block config fields.
|
|
- [x] Merge generated blocks into existing home layout without overwriting user-authored block ids.
|
|
|
|
### Task 2: Wire Composer Into Frontend Home Initialization
|
|
|
|
**Files:**
|
|
- Modify: `ruoyi-generator/src/main/java/com/ruoyi/generator/service/front/FrontendPageDesignService.java`
|
|
|
|
- [x] Inject composer with a lazy fallback for unit-style construction.
|
|
- [x] Call composer after the home design is created or loaded.
|
|
- [x] Persist the home design only when layout JSON changes.
|
|
|
|
### Task 3: Add News Business Block
|
|
|
|
**Files:**
|
|
- Create: `ruoyi-generator/src/main/resources/business-blocks/news/block.json`
|
|
- Create: `ruoyi-generator/src/main/resources/business-blocks/news/templates/frontend/NewsBlock.vue.vm`
|
|
- Create: `ruoyi-generator/src/main/resources/business-blocks/news/templates/frontend/newsApi.js.vm`
|
|
- Create backend template files under `ruoyi-generator/src/main/resources/business-blocks/news/templates/backend/`
|
|
- Modify: `ruoyi-generator/src/main/resources/business-blocks/carousel/block.json`
|
|
- Modify: `ruoyi-generator/src/main/resources/business-blocks/notice/block.json`
|
|
|
|
- [x] Add news config fields for title, content, summary, cover image, status, and publish time.
|
|
- [x] Generate list endpoint files following the notice block pattern.
|
|
- [x] Mark carousel and notice as valid for both page and embedded placements.
|
|
|
|
### Task 4: Verify Without Automated Tests
|
|
|
|
**Files:**
|
|
- Review changed files and run a compile-level command if local dependencies permit.
|
|
|
|
- [x] Inspect generated JSON and Velocity variables for consistency.
|
|
- [x] Run `mvn -pl ruoyi-generator -am -DskipTests compile` unless the local environment blocks it.
|