Add executable business blueprint workflow

This commit is contained in:
王鹏
2026-05-24 13:29:42 +08:00
parent ecdc015c2f
commit 6682a44a43
40 changed files with 4756 additions and 113 deletions

View File

@@ -0,0 +1,52 @@
# Executable Business Blueprint Design
## Goal
Generate runnable business workflow code from EasyCode business blueprints without allowing AI to emit arbitrary Java source.
## Scope
This phase covers general workflow actions plus inventory and amount style numeric changes. Generated projects should get Controller endpoints, transactional Service methods, rule checks, row inserts, field updates, status updates, numeric increase/decrease helpers, and frontend buttons/API calls.
This phase does not cover arbitrary Java snippets, complex accounting ledgers, permissions beyond the existing generated shell, distributed locks, or idempotency keys.
## Architecture
AI returns a structured DSL in `businessActions`. The backend normalizes and validates that DSL against the saved database schema, stores it in `front_project.business_blueprint`, and passes it into Velocity templates. Templates render deterministic Java and Vue code from the DSL.
Existing `rules: List<String>` remains as human-readable notes. New executable checks live in `ruleChecks`.
## DSL
Each action may include:
- `code`, `name`, `ownerTable`, `method`, `path`, `transaction`, `requestFields`
- `rules`: human-readable notes
- `ruleChecks`: executable checks
- `effects`: executable data mutations
Supported `ruleChecks`:
- `EXISTS`
- `NOT_EXISTS`
- `FIELD_EQUALS`
- `FIELD_NOT_EQUALS`
- `FIELD_IN`
- `NUMBER_GTE`
Supported `effects`:
- `INSERT_ROW`
- `UPDATE_FIELDS`
- `SET_STATUS`
- `INCREASE_NUMBER`
- `DECREASE_NUMBER`
- legacy `UPDATE_FIELD`
## Safety
All table and column identifiers must exist in the saved schema. Effect value placeholders are limited to safe forms: literals, `${param.field}`, and `${now}`. Numeric amounts may be literals or `${param.field}`. SQL fragments from AI are not accepted except the existing legacy `UPDATE_FIELD.value`, which remains bounded by the template helper.
## Testing
Backend tests cover parsing and persistence of structured checks/effects, validation of unknown tables or fields, and template rendering markers for the generated helper methods. Existing tests must remain green.