Files
workutils/docs/superpowers/plans/2026-07-30-mybatis-generator-phase-6.md
T
2026-07-30 22:06:04 +08:00

79 lines
3.8 KiB
Markdown

# MyBatis Generator Phase 6 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:** Remove sensitive database details from the page, prevent database query/generation from freezing JavaFX, and replace the embedded-page “cancel” action with reset.
**Architecture:** Convert raw JDBC configuration into a safe `DatasourceSummary` before rendering. Capture query and generation inputs into immutable requests and execute two independent use cases through separate `AsyncOperationController` instances. Keep existing service callbacks as infrastructure adapters.
**Tech Stack:** Java 17, JavaFX, JUnit 5, Maven.
## Global Constraints
- Never expose database password, username, JDBC query parameters, or raw URL in page labels.
- Query and generate actions must have independent state.
- Preserve database access and generated artifact behavior.
- Directory choosers remain synchronous and do not show loading.
- UI verification must not query a database or generate files.
---
### Task 1: Safe datasource summary
**Files:**
- Create: `src/main/java/com/example/workutils/biz/mybatisgenerator/presentation/DatasourceSummary.java`
- Test: `src/test/java/com/example/workutils/biz/mybatisgenerator/presentation/DatasourceSummaryTest.java`
- Modify: `src/main/java/com/example/workutils/biz/mybatisgenerator/MyBatisGeneratorWindow.java`
**Interfaces:**
- Produces `DatasourceSummary.from(alias, jdbcUrl)`.
- Exposes alias, database type, masked host, and database name only.
- [ ] Test MySQL, OceanBase, query parameters, malformed URL, and blank alias.
- [ ] Observe focused test failure.
- [ ] Implement safe parsing and display text.
- [ ] Replace raw URL/user labels.
- [ ] Confirm focused test passes.
### Task 2: Immutable operation requests
**Files:**
- Create: `src/main/java/com/example/workutils/biz/mybatisgenerator/application/QueryTablesRequest.java`
- Create: `src/main/java/com/example/workutils/biz/mybatisgenerator/application/GenerateArtifactsRequest.java`
- Test: `src/test/java/com/example/workutils/biz/mybatisgenerator/application/GeneratorRequestTest.java`
- [ ] Test trimming, required pattern/table selection, directory defaults, and immutable table copying.
- [ ] Observe focused test failure.
- [ ] Implement both records.
- [ ] Confirm focused test passes.
### Task 3: Independent use cases and loading
**Files:**
- Create: `src/main/java/com/example/workutils/biz/mybatisgenerator/application/QueryTablesUseCase.java`
- Create: `src/main/java/com/example/workutils/biz/mybatisgenerator/application/GenerateArtifactsUseCase.java`
- Modify: `src/main/java/com/example/workutils/biz/mybatisgenerator/MyBatisGeneratorWindow.java`
- Test: `src/test/java/com/example/workutils/biz/mybatisgenerator/application/GeneratorUseCaseTest.java`
- [ ] Test gateway delegation and result immutability.
- [ ] Observe focused test failure.
- [ ] Add two use cases and two async controllers.
- [ ] Bind query/generate buttons independently and add operation status panes.
- [ ] Confirm focused tests pass.
### Task 4: Reset semantics
**Files:**
- Modify: `src/main/java/com/example/workutils/biz/mybatisgenerator/MyBatisGeneratorWindow.java`
- [ ] Rename bottom “取消” to “重置配置”.
- [ ] Reset pattern, table selection, and directory defaults without closing the page.
- [ ] Keep window close behavior only on actual window close.
### Task 5: Verification
- [ ] Run all tests and compile with JDK 17.
- [ ] Run `git diff --check`.
- [ ] Confirm Window no longer directly calls query/generate on the UI thread.
- [ ] Inspect datasource summary, idle query/generate states, and reset label without database or filesystem side effects.