122 lines
4.6 KiB
Markdown
122 lines
4.6 KiB
Markdown
# CISD Init Request Schema DTO Implementation Plan
|
|
|
|
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task.
|
|
|
|
**Goal:** Replace placeholder init preview request with a production-ready CISD initialization request DTO and server-side rule validation based on preset product type.
|
|
|
|
**Architecture:** Keep the current single-module Spring Boot structure. Introduce strong-typed nested DTOs for init request payload, centralize preset version/product-type sourcing in configuration properties (as current phase baseline), and enforce cross-field conditional rules in `InitService` before preview generation. Surface preset product type in `/api/v1/device/info` for frontend auto-rendering.
|
|
|
|
**Tech Stack:** JDK 17, Spring Boot 3.5, Jakarta Bean Validation, JUnit 5.
|
|
|
|
---
|
|
|
|
### Task 1: Add failing tests for init request rule validation
|
|
|
|
**Files:**
|
|
- Create: `src/test/java/com/cisd/tms/modules/init/service/InitServiceTest.java`
|
|
|
|
**Step 1: Write failing tests**
|
|
- Add tests for:
|
|
- missing preset product type should reject init preview.
|
|
- enterprise + TLQ should require `tlqLicenseFileId`.
|
|
- direct + `RABBITMQ_CFMQ` should require `cfmqConfigFileId`, `cfgZipFileId`, and sign server fields.
|
|
- valid enterprise request should pass and generate summary.
|
|
|
|
**Step 2: Run targeted tests to verify red**
|
|
- Run: `mvn -q -Dtest=InitServiceTest test`
|
|
- Expected: FAIL because `InitService` still uses old DTO and has no rule engine.
|
|
|
|
### Task 2: Implement strong-typed init request DTO model
|
|
|
|
**Files:**
|
|
- Modify: `src/main/java/com/cisd/tms/modules/init/dto/InitPreviewRequest.java`
|
|
|
|
**Step 1: Replace old placeholder fields**
|
|
- Remove `version/nodeCount`.
|
|
- Add nested models for:
|
|
- basic institution fields
|
|
- deploy mode + nodes
|
|
- mq settings
|
|
- licenses
|
|
- sign server
|
|
|
|
**Step 2: Add validation annotations**
|
|
- Add required constraints for common fields (`orgCodeType`, `orgCode`, `orgNameCn`, `deployMode`, `node01Ip`, `mqType`, `channelUsername`, `channelPassword`, `receiverLicenseFileId`).
|
|
|
|
**Step 3: Keep model minimal and serializable**
|
|
- Use static inner classes with getters/setters only.
|
|
|
|
### Task 3: Add preset product type source and expose in device info
|
|
|
|
**Files:**
|
|
- Create: `src/main/java/com/cisd/tms/common/config/properties/CisdPresetProperties.java`
|
|
- Modify: `src/main/java/com/cisd/tms/modules/device/dto/DeviceInfoResponse.java`
|
|
- Modify: `src/main/java/com/cisd/tms/modules/device/service/DeviceService.java`
|
|
- Modify: `src/main/resources/application.yml`
|
|
|
|
**Step 1: Add configuration properties bean**
|
|
- Prefix: `tms.cisd.preset`
|
|
- Fields: `productType`, `version`, `source`.
|
|
|
|
**Step 2: Extend device status response**
|
|
- Add `presetProductType`, `presetVersion`, `presetSource`.
|
|
|
|
**Step 3: Populate response from preset config**
|
|
- Inject `CisdPresetProperties` into `DeviceService` and map values.
|
|
|
|
### Task 4: Implement rule validation in InitService
|
|
|
|
**Files:**
|
|
- Modify: `src/main/java/com/cisd/tms/modules/init/service/InitService.java`
|
|
- Modify: `src/main/java/com/cisd/tms/modules/init/dto/InitPreviewResponse.java`
|
|
- Modify: `src/main/java/com/cisd/tms/modules/init/dto/InitPlanTemplateResponse.java`
|
|
|
|
**Step 1: Add preset guard**
|
|
- If preset product type missing/invalid, throw `BizException` and block preview/template.
|
|
|
|
**Step 2: Add product-type conditional validation**
|
|
- Enterprise/Indirect:
|
|
- deploy mode only `SINGLE/DUAL`
|
|
- mq type only `RABBITMQ/TLQ`
|
|
- TLQ requires `tlqLicenseFileId`
|
|
- DUAL requires `node02Ip`
|
|
- Direct:
|
|
- deploy mode `SINGLE/DUAL/QUAD`
|
|
- mq type `RABBITMQ_TLQ/RABBITMQ_CFMQ`
|
|
- `cfgZipFileId` required
|
|
- sign server fields required
|
|
- TLQ requires `tlqLicenseFileId`
|
|
- CFMQ requires `cfmqConfigFileId`
|
|
- DUAL/QUAD require `node02Ip`; QUAD require `node03Ip/node04Ip`
|
|
|
|
**Step 3: Produce meaningful preview summary**
|
|
- Set response fields: resolved product type, step count estimate, and concise summary.
|
|
|
|
### Task 5: Add developer-facing validation spec doc
|
|
|
|
**Files:**
|
|
- Create: `docs/plans/2026-03-02-cisd-init-request-schema-spec.md`
|
|
|
|
**Step 1: Document payload JSON schema shape**
|
|
- Include common object structure and conditional fields by product type.
|
|
|
|
**Step 2: Document prefilled vs user-input fields**
|
|
- Explicitly list DB creds and RabbitMQ admin creds as prefilled-only.
|
|
|
|
### Task 6: Verify and stabilize
|
|
|
|
**Files:**
|
|
- N/A
|
|
|
|
**Step 1: Run targeted tests**
|
|
- `mvn -q -Dtest=InitServiceTest test`
|
|
|
|
**Step 2: Run compile check**
|
|
- `mvn -q -DskipTests compile`
|
|
|
|
**Step 3: Run full test suite if stable**
|
|
- `mvn -q test`
|
|
|
|
**Step 4: Record results in response**
|
|
- Include changed files, command outputs summary, remaining risks.
|