intent-flow 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- intent_flow/__init__.py +1 -0
- intent_flow/_assets/agents/backend-java-ddd-design.yaml +23 -0
- intent_flow/_assets/agents/backend-java-ddd-implementer.yaml +24 -0
- intent_flow/_assets/agents/backend-java-ddd-verify.yaml +26 -0
- intent_flow/_assets/agents/ddd-schema-designer.yaml +21 -0
- intent_flow/_assets/agents/prd-writer.yaml +22 -0
- intent_flow/_assets/agents/project-decomposer.yaml +24 -0
- intent_flow/_assets/agents/requirement-intake.yaml +19 -0
- intent_flow/_assets/flow/stages.yaml +26 -0
- intent_flow/_assets/flow/status.yaml +17 -0
- intent_flow/_assets/flow/transitions.yaml +23 -0
- intent_flow/_assets/intent-flow.yaml.example +33 -0
- intent_flow/_assets/manifest.yaml +13 -0
- intent_flow/_assets/roles/developer.yaml +28 -0
- intent_flow/_assets/roles/fullstack.yaml +35 -0
- intent_flow/_assets/roles/product-manager.yaml +13 -0
- intent_flow/_assets/skills/backend-java-ddd/design/SKILL.md +442 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/SPEC.md +80 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/acceptance/acceptance.md +37 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/application/country-create.md +113 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/application/country-detail.md +97 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/application/country-disable.md +97 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/application/country-enable.md +90 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/application/country-page.md +113 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/application/country-update.md +102 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/change/260227-01-/321/205/320/253/342/225/234/321/205/320/276/342/225/242/321/207/320/276/320/261/321/207/320/240/320/226/321/206/320/270/320/261/321/205/320/255/320/247.md +63 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/change/260315-02-/321/205/320/253/342/225/234/321/205/320/276/342/225/242/321/211/342/225/227/320/250/321/210/320/276/320/264/321/205/342/225/225/320/221/321/207/320/267/320/235/321/205/320/262/320/256/321/205/342/225/235/342/225/221.md +53 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/constraints/ddd-implementation.md +7 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/core/create.md +110 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/core/disable.md +85 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/core/enable.md +85 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/core/object-profile.md +106 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/core/update.md +103 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/rules/application-rules.md +12 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/rules/cross-object-rules.md +11 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/rules/object-rules.md +13 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/scenarios/create-country.md +26 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/scenarios/detail-country.md +22 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/scenarios/disable-country.md +22 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/scenarios/enable-country.md +22 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/scenarios/page-country.md +24 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/country/scenarios/update-country.md +24 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/SPEC.md +79 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/acceptance/acceptance.md +36 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/application/currency-create.md +80 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/application/currency-detail.md +77 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/application/currency-disable.md +77 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/application/currency-enable.md +70 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/application/currency-page.md +89 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/application/currency-update.md +75 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/change/260303-01-/321/205/342/225/225/320/221/321/207/320/267/320/235/321/207/320/276/320/261/321/207/320/240/320/226.md +64 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/constraints/ddd-implementation.md +7 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/core/create.md +94 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/core/disable.md +85 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/core/enable.md +85 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/core/object-profile.md +95 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/core/update.md +90 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/rules/application-rules.md +11 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/rules/cross-object-rules.md +10 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/rules/object-rules.md +13 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/scenarios/create-currency.md +24 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/scenarios/detail-currency.md +22 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/scenarios/disable-currency.md +22 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/scenarios/enable-currency.md +22 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/scenarios/page-currency.md +24 -0
- intent_flow/_assets/skills/backend-java-ddd/design/examples/currency/scenarios/update-currency.md +23 -0
- intent_flow/_assets/skills/backend-java-ddd/design/references/INDEX.md +35 -0
- intent_flow/_assets/skills/backend-java-ddd/design/references/concepts/application-vs-core-behavior.md +54 -0
- intent_flow/_assets/skills/backend-java-ddd/design/references/concepts/business-object.md +43 -0
- intent_flow/_assets/skills/backend-java-ddd/design/references/concepts/object-spec-package.md +45 -0
- intent_flow/_assets/skills/backend-java-ddd/design/references/process/generation-process.md +75 -0
- intent_flow/_assets/skills/backend-java-ddd/design/references/rules/business-object-generation-rules.md +82 -0
- intent_flow/_assets/skills/backend-java-ddd/design/references/rules/change-impact-rules.md +45 -0
- intent_flow/_assets/skills/backend-java-ddd/design/references/rules/consistency-check-rules.md +47 -0
- intent_flow/_assets/skills/backend-java-ddd/design/references/rules/extraction-rules.md +126 -0
- intent_flow/_assets/skills/backend-java-ddd/design/references/rules/file-generation-rules.md +275 -0
- intent_flow/_assets/skills/backend-java-ddd/design/references/rules/output-artifact-checklist.md +328 -0
- intent_flow/_assets/skills/backend-java-ddd/design/templates/INDEX.md +22 -0
- intent_flow/_assets/skills/backend-java-ddd/design/templates/object/SPEC.md +34 -0
- intent_flow/_assets/skills/backend-java-ddd/design/templates/object/acceptance.md +13 -0
- intent_flow/_assets/skills/backend-java-ddd/design/templates/object/application-behavior.md +67 -0
- intent_flow/_assets/skills/backend-java-ddd/design/templates/object/change.md +43 -0
- intent_flow/_assets/skills/backend-java-ddd/design/templates/object/constraints.md +19 -0
- intent_flow/_assets/skills/backend-java-ddd/design/templates/object/core-behavior.md +67 -0
- intent_flow/_assets/skills/backend-java-ddd/design/templates/object/object-profile.md +35 -0
- intent_flow/_assets/skills/backend-java-ddd/design/templates/object/rules.md +17 -0
- intent_flow/_assets/skills/backend-java-ddd/design/templates/object/scenario.md +25 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/00-core/anti-patterns/SKILL.md +488 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/00-core/bootstrap/SKILL.md +171 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/00-core/code-generation-workflow/SKILL.md +755 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/00-core/code-style/code-formatting/SKILL.md +297 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/00-core/code-style/comment-javadoc/SKILL.md +494 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/00-core/code-style/imports/SKILL.md +237 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/00-core/coding-standards/SKILL.md +304 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/00-core/exception-logging/SKILL.md +318 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/00-core/loading-strategy/SKILL.md +193 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/00-core/naming-convention/SKILL.md +223 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/00-core/project-architecture/SKILL.md +132 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/adapter/controller/SKILL.md +488 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/adapter/controller/examples/complete-controller.md +382 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/adapter/controller/examples/pagination.md +103 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/appservice/SKILL.md +216 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/appservice/examples/async.md +446 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/appservice/examples/batch.md +555 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/appservice/examples/conditional.md +549 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/appservice/examples/cross-domain-cmdexe.md +417 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/appservice/examples/cross-domain.md +491 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/appservice/examples/distributed-tx.md +406 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/appservice/examples/mixed.md +470 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/appservice/examples/simple-cmdexe.md +512 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/appservice/examples/simple-qryexe.md +434 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/cmdexe/SKILL.md +288 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/cmdexe/examples/action.md +648 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/cmdexe/examples/create.md +775 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/cmdexe/examples/update.md +721 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/convertor/SKILL.md +231 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/convertor/examples/convertor.md +612 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/dto/SKILL.md +75 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/dto/examples/cmd.md +205 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/dto/examples/co.md +168 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/dto/examples/qry.md +208 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/qryexe/SKILL.md +354 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/qryexe/examples/detail.md +156 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/application/qryexe/examples/pagination.md +145 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/domain/entity/SKILL.md +280 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/domain/entity/examples/aggregate-creation.md +1009 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/domain/entity/examples/aggregate-design.md +728 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/domain/entity/examples/method-design.md +640 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/domain/entity/examples/update-patterns.md +503 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/domain/gateway/SKILL.md +181 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/domain/gateway/examples/gateway-capabilities.md +536 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/domain/gateway/examples/gateway-interface.md +270 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/infrastructure/external/SKILL.md +142 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/infrastructure/gatewayimpl/SKILL.md +197 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/infrastructure/gatewayimpl/examples/cascade-mechanism.md +353 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/infrastructure/gatewayimpl/examples/gateway.md +316 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/infrastructure/repository/SKILL.md +294 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/01-layers/infrastructure/repository/examples/pagination.md +439 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/02-plugins/enum-dict-plugin/SKILL.md +239 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/02-plugins/pagination-backend/SKILL.md +411 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/02-plugins/repository-methods/SKILL.md +229 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/02-plugins/seata-xa/SKILL.md +268 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/02-plugins/spring-cache/SKILL.md +252 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/10-learning/README.md +45 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/10-learning/architecture/ddd-architecture.md +101 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/10-learning/architecture/project-structure.md +143 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/10-learning/ddd-concepts/aggregate-update.md +432 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/10-learning/ddd-concepts/method-design.md +344 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/10-learning/ddd-concepts/parameter-object.md +416 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/10-learning/ddd-concepts/rich-model.md +270 -0
- intent_flow/_assets/skills/backend-java-ddd/implementer/10-learning/ddd-concepts/value-object.md +375 -0
- intent_flow/_assets/skills/backend-java-ddd/scaffold/README.md +17 -0
- intent_flow/_assets/skills/backend-java-ddd/scaffold/add-service-module/SKILL.md +77 -0
- intent_flow/_assets/skills/backend-java-ddd/scaffold/examples/service-basis.md +27 -0
- intent_flow/_assets/skills/backend-java-ddd/scaffold/init-multi-module-project/SKILL.md +137 -0
- intent_flow/_assets/skills/backend-java-ddd/scaffold/init-single-module-project/SKILL.md +115 -0
- intent_flow/_assets/skills/backend-java-ddd/scaffold/references/INDEX.md +19 -0
- intent_flow/_assets/skills/backend-java-ddd/scaffold/references/config-conventions.md +29 -0
- intent_flow/_assets/skills/backend-java-ddd/scaffold/references/input-checklist.md +19 -0
- intent_flow/_assets/skills/backend-java-ddd/scaffold/references/project-structure.md +29 -0
- intent_flow/_assets/skills/backend-java-ddd/scaffold/references/what-is-scaffold.md +18 -0
- intent_flow/_assets/skills/backend-java-ddd/scaffold/templates/INDEX.md +8 -0
- intent_flow/_assets/skills/backend-java-ddd/scaffold/templates/files.md +33 -0
- intent_flow/_assets/skills/backend-java-ddd/scaffold/templates/module-layout.md +23 -0
- intent_flow/_assets/skills/code-repository/commit-changes/SKILL.md +41 -0
- intent_flow/_assets/skills/code-repository/commit-changes/mappings/git.yaml +12 -0
- intent_flow/_assets/skills/code-repository/commit-changes/references/commit.md +19 -0
- intent_flow/_assets/skills/code-repository/create-branch/SKILL.md +41 -0
- intent_flow/_assets/skills/code-repository/create-branch/mappings/git.yaml +12 -0
- intent_flow/_assets/skills/code-repository/create-branch/references/create.md +19 -0
- intent_flow/_assets/skills/code-repository/diff-changes/SKILL.md +41 -0
- intent_flow/_assets/skills/code-repository/diff-changes/mappings/git.yaml +12 -0
- intent_flow/_assets/skills/code-repository/diff-changes/references/diff.md +19 -0
- intent_flow/_assets/skills/code-repository/read-file/SKILL.md +41 -0
- intent_flow/_assets/skills/code-repository/read-file/mappings/git.yaml +12 -0
- intent_flow/_assets/skills/code-repository/read-file/references/read.md +19 -0
- intent_flow/_assets/skills/decomposition/analyze-impact/SKILL.md +41 -0
- intent_flow/_assets/skills/decomposition/analyze-impact/references/analyze.md +19 -0
- intent_flow/_assets/skills/decomposition/create-project-changes/SKILL.md +41 -0
- intent_flow/_assets/skills/decomposition/create-project-changes/references/create.md +19 -0
- intent_flow/_assets/skills/decomposition/normalize-requirement/SKILL.md +41 -0
- intent_flow/_assets/skills/decomposition/normalize-requirement/references/normalize.md +19 -0
- intent_flow/_assets/skills/decomposition/normalize-requirement/templates/normalized-requirement.template.md +34 -0
- intent_flow/_assets/skills/domains.yaml +207 -0
- intent_flow/_assets/skills/local-workspace/list-artifacts/SKILL.md +41 -0
- intent_flow/_assets/skills/local-workspace/list-artifacts/references/list.md +19 -0
- intent_flow/_assets/skills/local-workspace/read-artifact/SKILL.md +41 -0
- intent_flow/_assets/skills/local-workspace/read-artifact/references/read.md +19 -0
- intent_flow/_assets/skills/local-workspace/read-meta/SKILL.md +41 -0
- intent_flow/_assets/skills/local-workspace/read-meta/references/read.md +19 -0
- intent_flow/_assets/skills/local-workspace/write-artifact/SKILL.md +41 -0
- intent_flow/_assets/skills/local-workspace/write-artifact/references/write.md +19 -0
- intent_flow/_assets/skills/local-workspace/write-meta/SKILL.md +41 -0
- intent_flow/_assets/skills/local-workspace/write-meta/references/write.md +19 -0
- intent_flow/_assets/skills/project-management/create-work-item/SKILL.md +43 -0
- intent_flow/_assets/skills/project-management/create-work-item/mappings/jira.yaml +29 -0
- intent_flow/_assets/skills/project-management/create-work-item/mappings/tapd.yaml +29 -0
- intent_flow/_assets/skills/project-management/create-work-item/mappings/yunxiao.yaml +36 -0
- intent_flow/_assets/skills/project-management/create-work-item/references/create.md +22 -0
- intent_flow/_assets/skills/project-management/query-work-item/SKILL.md +41 -0
- intent_flow/_assets/skills/project-management/query-work-item/mappings/jira.yaml +15 -0
- intent_flow/_assets/skills/project-management/query-work-item/mappings/tapd.yaml +15 -0
- intent_flow/_assets/skills/project-management/query-work-item/mappings/yunxiao.yaml +15 -0
- intent_flow/_assets/skills/project-management/query-work-item/references/query.md +19 -0
- intent_flow/_assets/skills/project-management/sync-stage/SKILL.md +41 -0
- intent_flow/_assets/skills/project-management/sync-stage/mappings/jira.yaml +15 -0
- intent_flow/_assets/skills/project-management/sync-stage/mappings/tapd.yaml +15 -0
- intent_flow/_assets/skills/project-management/sync-stage/mappings/yunxiao.yaml +15 -0
- intent_flow/_assets/skills/project-management/sync-stage/references/sync.md +19 -0
- intent_flow/_assets/skills/project-management/update-status/SKILL.md +41 -0
- intent_flow/_assets/skills/project-management/update-status/mappings/jira.yaml +31 -0
- intent_flow/_assets/skills/project-management/update-status/mappings/tapd.yaml +31 -0
- intent_flow/_assets/skills/project-management/update-status/mappings/yunxiao.yaml +32 -0
- intent_flow/_assets/skills/project-management/update-status/references/update.md +19 -0
- intent_flow/_assets/skills/project-management/update-work-item/SKILL.md +41 -0
- intent_flow/_assets/skills/project-management/update-work-item/mappings/jira.yaml +15 -0
- intent_flow/_assets/skills/project-management/update-work-item/mappings/tapd.yaml +15 -0
- intent_flow/_assets/skills/project-management/update-work-item/mappings/yunxiao.yaml +15 -0
- intent_flow/_assets/skills/project-management/update-work-item/references/update.md +19 -0
- intent_flow/_assets/skills/remote-document/create-doc/SKILL.md +41 -0
- intent_flow/_assets/skills/remote-document/create-doc/mappings/feishu.yaml +12 -0
- intent_flow/_assets/skills/remote-document/create-doc/mappings/yuque.yaml +12 -0
- intent_flow/_assets/skills/remote-document/create-doc/references/create.md +19 -0
- intent_flow/_assets/skills/remote-document/publish-doc/SKILL.md +41 -0
- intent_flow/_assets/skills/remote-document/publish-doc/mappings/feishu.yaml +12 -0
- intent_flow/_assets/skills/remote-document/publish-doc/mappings/yuque.yaml +12 -0
- intent_flow/_assets/skills/remote-document/publish-doc/references/publish.md +19 -0
- intent_flow/_assets/skills/remote-document/read-doc/SKILL.md +41 -0
- intent_flow/_assets/skills/remote-document/read-doc/mappings/feishu.yaml +12 -0
- intent_flow/_assets/skills/remote-document/read-doc/mappings/yuque.yaml +12 -0
- intent_flow/_assets/skills/remote-document/read-doc/references/read.md +19 -0
- intent_flow/_assets/skills/remote-document/search-doc/SKILL.md +41 -0
- intent_flow/_assets/skills/remote-document/search-doc/mappings/feishu.yaml +12 -0
- intent_flow/_assets/skills/remote-document/search-doc/mappings/yuque.yaml +12 -0
- intent_flow/_assets/skills/remote-document/search-doc/references/search.md +19 -0
- intent_flow/_assets/skills/remote-document/update-doc/SKILL.md +41 -0
- intent_flow/_assets/skills/remote-document/update-doc/mappings/feishu.yaml +12 -0
- intent_flow/_assets/skills/remote-document/update-doc/mappings/yuque.yaml +12 -0
- intent_flow/_assets/skills/remote-document/update-doc/references/update.md +19 -0
- intent_flow/_assets/skills/requirement/analyze-requirement/SKILL.md +41 -0
- intent_flow/_assets/skills/requirement/analyze-requirement/references/analyze.md +19 -0
- intent_flow/_assets/skills/requirement/generate-prd/SKILL.md +41 -0
- intent_flow/_assets/skills/requirement/generate-prd/references/generate.md +19 -0
- intent_flow/_assets/skills/requirement/generate-prd/templates/prd.template.md +24 -0
- intent_flow/_assets/skills/requirement/generate-prototype/SKILL.md +41 -0
- intent_flow/_assets/skills/requirement/generate-prototype/references/generate.md +19 -0
- intent_flow/_assets/skills/requirement/generate-prototype/templates/prototype.template.md +26 -0
- intent_flow/_assets/skills/requirement/generate-scope/SKILL.md +41 -0
- intent_flow/_assets/skills/requirement/generate-scope/references/generate.md +19 -0
- intent_flow/_assets/skills/requirement/generate-scope/templates/scope.template.md +13 -0
- intent_flow/_assets/skills/requirement/intake-requirement/SKILL.md +41 -0
- intent_flow/_assets/skills/requirement/intake-requirement/references/intake.md +19 -0
- intent_flow/_assets/skills/resolution.yaml +17 -0
- intent_flow/adapters/__init__.py +1 -0
- intent_flow/adapters/opencode/__init__.py +1 -0
- intent_flow/adapters/opencode/adapter.yaml +31 -0
- intent_flow/adapters/opencode/build_runtime.py +1207 -0
- intent_flow/adapters/opencode/intent-flow.plugin.js +161 -0
- intent_flow/cli.py +1067 -0
- intent_flow-0.1.0.dist-info/METADATA +10 -0
- intent_flow-0.1.0.dist-info/RECORD +264 -0
- intent_flow-0.1.0.dist-info/WHEEL +5 -0
- intent_flow-0.1.0.dist-info/entry_points.txt +2 -0
- intent_flow-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
# GatewayImpl - 自动级联机制详解
|
|
2
|
+
|
|
3
|
+
> 💡 **本文档面向**:想深入了解 Gateway 自动级联原理的开发者
|
|
4
|
+
>
|
|
5
|
+
> 💡 **日常开发**:大部分场景只需查看 [GatewayImpl 规范](../SKILL.md) 即可
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## 整存整取原则
|
|
10
|
+
|
|
11
|
+
**核心理念**:聚合根是事务边界,加载聚合根时同时加载所有子实体,保存聚合根时同时保存所有子实体。
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
findById(id) → 加载聚合根 + 所有子实体
|
|
15
|
+
save(aggregate) → 保存聚合根 + 自动处理子实体的增删改
|
|
16
|
+
delete(id) → 删除聚合根 + 所有子实体
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## 自动级联工作流程
|
|
22
|
+
|
|
23
|
+
### 1. findById() - 自动加载子实体
|
|
24
|
+
|
|
25
|
+
```java
|
|
26
|
+
PlatformType platform = platformGateway.findById(1);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
**执行流程**:
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
1. 查询主表:SELECT * FROM bse_platform_type WHERE platform_type_id = 1
|
|
33
|
+
2. 查询子表:SELECT * FROM bse_platform_site WHERE platform_type_id = 1
|
|
34
|
+
3. 组装对象:
|
|
35
|
+
platform.sites = [site1, site2, site3]
|
|
36
|
+
4. 返回聚合根(包含子实体)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
**实现原理**:
|
|
40
|
+
- AbstractAggregateRepository 扫描 Entity 上的 `@OneToMany` 注解
|
|
41
|
+
- 根据 `referencedBy` 和 `mappedBy` 自动构建子表查询条件
|
|
42
|
+
- 使用子实体 Repository 查询并组装到聚合根
|
|
43
|
+
|
|
44
|
+
---
|
|
45
|
+
|
|
46
|
+
### 2. save() - 自动保存/删除子实体
|
|
47
|
+
|
|
48
|
+
```java
|
|
49
|
+
// 修改聚合根和子实体
|
|
50
|
+
platform.updateInfo("亚马逊平台");
|
|
51
|
+
platform.addSite(newSite);
|
|
52
|
+
platform.removeSite(oldSiteId);
|
|
53
|
+
|
|
54
|
+
// 保存(自动处理子实体)
|
|
55
|
+
platformGateway.save(platform);
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**执行流程**:
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
1. 加载原聚合根(包含旧子实体列表)
|
|
62
|
+
oldSites = [site1, site2, site3]
|
|
63
|
+
|
|
64
|
+
2. 对比新旧子实体列表
|
|
65
|
+
newSites = [site1_updated, site2, site4_new]
|
|
66
|
+
|
|
67
|
+
对比结果:
|
|
68
|
+
- 新增:site4(newSites 有,oldSites 没有)
|
|
69
|
+
- 更新:site1、site2(newSites 和 oldSites 都有,通过 ID 匹配)
|
|
70
|
+
- 删除:site3(oldSites 有,newSites 没有)
|
|
71
|
+
|
|
72
|
+
3. 执行 SQL
|
|
73
|
+
UPDATE bse_platform_type SET ... WHERE platform_type_id = 1
|
|
74
|
+
INSERT INTO bse_platform_site VALUES (...) -- site4
|
|
75
|
+
UPDATE bse_platform_site SET ... WHERE site_id = 1 -- site1
|
|
76
|
+
DELETE FROM bse_platform_site WHERE site_id = 3 -- site3 (仅当 orphanRemoval = true)
|
|
77
|
+
|
|
78
|
+
4. 自动设置子实体外键
|
|
79
|
+
site4.setPlatformTypeId(1) -- 自动设置外键
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**实现原理**:
|
|
83
|
+
- AbstractAggregateRepository 对比新旧子实体列表(通过 ID)
|
|
84
|
+
- 根据对比结果调用子实体 Repository 的 insert/update/delete
|
|
85
|
+
- 自动设置子实体的外键值(通过 `@Setter` 反射调用)
|
|
86
|
+
- 当 `orphanRemoval = true` 时,自动删除被移除的子实体
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
### 3. delete() - 自动删除子实体
|
|
91
|
+
|
|
92
|
+
```java
|
|
93
|
+
platformGateway.delete(1);
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
**执行流程**:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
1. 删除子表记录:
|
|
100
|
+
DELETE FROM bse_platform_site WHERE platform_type_id = 1
|
|
101
|
+
|
|
102
|
+
2. 删除主表记录:
|
|
103
|
+
DELETE FROM bse_platform_type WHERE platform_type_id = 1
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**实现原理**:
|
|
107
|
+
- 先删除所有子实体(防止外键约束报错)
|
|
108
|
+
- 再删除聚合根
|
|
109
|
+
|
|
110
|
+
---
|
|
111
|
+
|
|
112
|
+
## 关键技术点
|
|
113
|
+
|
|
114
|
+
### 1. @OneToMany 注解参数详解
|
|
115
|
+
|
|
116
|
+
```java
|
|
117
|
+
@OneToMany(
|
|
118
|
+
referencedBy = "platformTypeId", // 聚合根的 ID 字段名(Java 字段名)
|
|
119
|
+
mappedBy = "platformTypeId", // 子实体的外键字段名(Java 字段名)
|
|
120
|
+
orphanRemoval = true // 是否自动删除孤儿记录
|
|
121
|
+
)
|
|
122
|
+
private List<PlatformSite> sites;
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
| 参数 | 说明 | 示例 |
|
|
126
|
+
|------|------|------|
|
|
127
|
+
| `referencedBy` | 聚合根的 ID 字段名(Java) | `"platformTypeId"` |
|
|
128
|
+
| `mappedBy` | 子实体的外键字段名(Java) | `"platformTypeId"` |
|
|
129
|
+
| `orphanRemoval` | 是否自动删除孤儿记录 | `true` / `false` |
|
|
130
|
+
|
|
131
|
+
**工作原理**:
|
|
132
|
+
```java
|
|
133
|
+
// 根据 referencedBy 获取聚合根 ID 值
|
|
134
|
+
Integer aggregateId = aggregate.getPlatformTypeId(); // 1
|
|
135
|
+
|
|
136
|
+
// 根据 mappedBy 构建子表查询条件
|
|
137
|
+
SELECT * FROM bse_platform_site WHERE platform_type_id = 1
|
|
138
|
+
|
|
139
|
+
// 保存时,根据 mappedBy 设置子实体外键
|
|
140
|
+
site.setPlatformTypeId(1);
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### 2. orphanRemoval 工作原理
|
|
144
|
+
|
|
145
|
+
```java
|
|
146
|
+
// orphanRemoval = true(推荐)
|
|
147
|
+
@OneToMany(referencedBy = "platformTypeId", mappedBy = "platformTypeId", orphanRemoval = true)
|
|
148
|
+
private List<PlatformSite> sites;
|
|
149
|
+
|
|
150
|
+
// Domain 方法
|
|
151
|
+
public void removeSite(Integer siteId) {
|
|
152
|
+
this.sites.removeIf(site -> site.getSiteId().equals(siteId));
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// CmdExe 调用
|
|
156
|
+
platform.removeSite(3);
|
|
157
|
+
platformGateway.save(platform);
|
|
158
|
+
|
|
159
|
+
// 执行的 SQL
|
|
160
|
+
DELETE FROM bse_platform_site WHERE site_id = 3 -- ✅ 自动删除
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
```java
|
|
164
|
+
// orphanRemoval = false(默认)
|
|
165
|
+
@OneToMany(referencedBy = "platformTypeId", mappedBy = "platformTypeId")
|
|
166
|
+
private List<PlatformSite> sites;
|
|
167
|
+
|
|
168
|
+
// Domain 方法
|
|
169
|
+
public void removeSite(Integer siteId) {
|
|
170
|
+
this.sites.removeIf(site -> site.getSiteId().equals(siteId));
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// CmdExe 调用
|
|
174
|
+
platform.removeSite(3);
|
|
175
|
+
platformGateway.save(platform);
|
|
176
|
+
|
|
177
|
+
// 执行的 SQL
|
|
178
|
+
-- ❌ 不会执行 DELETE,site_id=3 的记录成为孤儿记录
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### 3. 子实体外键自动设置
|
|
182
|
+
|
|
183
|
+
```java
|
|
184
|
+
// 子实体外键字段必须有 @Setter
|
|
185
|
+
@Getter
|
|
186
|
+
public class PlatformSite extends BaseEntity<Integer> {
|
|
187
|
+
|
|
188
|
+
@Setter // ⚠️ 必须有 @Setter
|
|
189
|
+
private Integer platformTypeId;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// 保存时,Gateway 自动设置外键
|
|
193
|
+
PlatformSite newSite = PlatformSite.create("US", "美国站");
|
|
194
|
+
platform.addSite(newSite); // 此时 newSite.platformTypeId = null
|
|
195
|
+
|
|
196
|
+
platformGateway.save(platform);
|
|
197
|
+
// ✅ 保存前,Gateway 自动执行:
|
|
198
|
+
// newSite.setPlatformTypeId(platform.getPlatformTypeId());
|
|
199
|
+
// 然后再 INSERT
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
**工作原理**:
|
|
203
|
+
- AbstractAggregateRepository 通过反射调用 `setPlatformTypeId()`
|
|
204
|
+
- 如果没有 `@Setter`,反射调用失败,外键值为 null,导致数据库约束报错
|
|
205
|
+
|
|
206
|
+
### 4. 脏检查(Dirty Check)
|
|
207
|
+
|
|
208
|
+
```java
|
|
209
|
+
// 加载聚合根
|
|
210
|
+
Country country = countryGateway.findById(1);
|
|
211
|
+
|
|
212
|
+
// 修改部分字段
|
|
213
|
+
country.updateName("中华人民共和国"); // 只修改 countryName
|
|
214
|
+
|
|
215
|
+
// 保存
|
|
216
|
+
countryGateway.save(country);
|
|
217
|
+
|
|
218
|
+
// 执行的 SQL(只更新变更字段)
|
|
219
|
+
UPDATE bse_country
|
|
220
|
+
SET country_name = '中华人民共和国', update_time = NOW()
|
|
221
|
+
WHERE country_id = 1
|
|
222
|
+
-- ✅ 只更新 countryName 和 updateTime,其他字段不更新
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
**工作原理**:
|
|
226
|
+
- MyBatis Plus 的 `updateById()` 默认只更新非 null 字段
|
|
227
|
+
- 如果字段值没有变化,不会出现在 UPDATE 语句中
|
|
228
|
+
|
|
229
|
+
---
|
|
230
|
+
|
|
231
|
+
## 对比新旧子实体列表的算法
|
|
232
|
+
|
|
233
|
+
### 伪代码
|
|
234
|
+
|
|
235
|
+
```java
|
|
236
|
+
public void save(T aggregate) {
|
|
237
|
+
// 1. 加载原聚合根
|
|
238
|
+
T oldAggregate = repository.selectById(aggregate.getId());
|
|
239
|
+
List<ChildEntity> oldChildren = oldAggregate.getChildren();
|
|
240
|
+
|
|
241
|
+
// 2. 获取新子实体列表
|
|
242
|
+
List<ChildEntity> newChildren = aggregate.getChildren();
|
|
243
|
+
|
|
244
|
+
// 3. 对比
|
|
245
|
+
Map<ID, ChildEntity> oldMap = oldChildren.stream()
|
|
246
|
+
.collect(Collectors.toMap(ChildEntity::getId, e -> e));
|
|
247
|
+
|
|
248
|
+
Map<ID, ChildEntity> newMap = newChildren.stream()
|
|
249
|
+
.filter(e -> e.getId() != null) // ID 不为 null 的是已存在的
|
|
250
|
+
.collect(Collectors.toMap(ChildEntity::getId, e -> e));
|
|
251
|
+
|
|
252
|
+
// 4. 找出新增的子实体(ID 为 null 或不在 oldMap 中)
|
|
253
|
+
List<ChildEntity> toInsert = newChildren.stream()
|
|
254
|
+
.filter(e -> e.getId() == null || !oldMap.containsKey(e.getId()))
|
|
255
|
+
.toList();
|
|
256
|
+
|
|
257
|
+
// 5. 找出需要更新的子实体(ID 在 oldMap 和 newMap 中都有)
|
|
258
|
+
List<ChildEntity> toUpdate = newChildren.stream()
|
|
259
|
+
.filter(e -> e.getId() != null && oldMap.containsKey(e.getId()))
|
|
260
|
+
.toList();
|
|
261
|
+
|
|
262
|
+
// 6. 找出需要删除的子实体(在 oldMap 中有,但不在 newMap 中)
|
|
263
|
+
List<ChildEntity> toDelete = oldChildren.stream()
|
|
264
|
+
.filter(e -> !newMap.containsKey(e.getId()))
|
|
265
|
+
.toList();
|
|
266
|
+
|
|
267
|
+
// 7. 执行 SQL
|
|
268
|
+
childRepository.insertBatch(toInsert);
|
|
269
|
+
childRepository.updateBatch(toUpdate);
|
|
270
|
+
if (orphanRemoval) {
|
|
271
|
+
childRepository.deleteBatch(toDelete);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
---
|
|
277
|
+
|
|
278
|
+
## GatewayImpl 无需特殊配置
|
|
279
|
+
|
|
280
|
+
**重点**:有子实体的 GatewayImpl 与无子实体的代码完全一样,无需编写额外代码。
|
|
281
|
+
|
|
282
|
+
```java
|
|
283
|
+
// 无子实体的 Gateway
|
|
284
|
+
@Component
|
|
285
|
+
public class CountryGatewayImpl extends AbstractAggregateRepository<Country, Integer> implements CountryGateway {
|
|
286
|
+
// ✅ 无需编写任何代码
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
// 有子实体的 Gateway(代码完全一样)
|
|
290
|
+
@Component
|
|
291
|
+
public class PlatformGatewayImpl extends AbstractAggregateRepository<PlatformType, Integer> implements PlatformGateway {
|
|
292
|
+
// ✅ 无需编写任何代码
|
|
293
|
+
// ✅ save/findById/delete 自动处理子实体
|
|
294
|
+
// ✅ 父类根据 @OneToMany 注解自动级联
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
**原理**:
|
|
299
|
+
- AbstractAggregateRepository 在运行时扫描 Entity 上的 `@OneToMany` 注解
|
|
300
|
+
- 如果没有 `@OneToMany`,按普通实体处理
|
|
301
|
+
- 如果有 `@OneToMany`,自动启用级联机制
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## 性能优化
|
|
306
|
+
|
|
307
|
+
### 1. 批量操作
|
|
308
|
+
|
|
309
|
+
```java
|
|
310
|
+
// ❌ 错误:循环单个保存
|
|
311
|
+
for (Country country : countries) {
|
|
312
|
+
countryGateway.save(country); // ❌ N 次数据库访问
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
// ✅ 正确:批量保存
|
|
316
|
+
countryGateway.saveBatch(countries); // ✅ 批量 INSERT/UPDATE
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
### 2. 子实体懒加载(未实现,预留)
|
|
320
|
+
|
|
321
|
+
当前实现是 `findById()` 自动加载所有子实体。
|
|
322
|
+
|
|
323
|
+
如果需要懒加载,可以:
|
|
324
|
+
1. 在 Gateway 接口中定义 `findByIdWithoutChildren()` 方法
|
|
325
|
+
2. 在 GatewayImpl 中实现,只查询聚合根,不查询子实体
|
|
326
|
+
|
|
327
|
+
---
|
|
328
|
+
|
|
329
|
+
## 常见问题
|
|
330
|
+
|
|
331
|
+
### Q1:为什么子实体外键字段必须有 @Setter?
|
|
332
|
+
|
|
333
|
+
**A**:Gateway 保存时需要自动设置外键值,通过反射调用 setter 方法。
|
|
334
|
+
|
|
335
|
+
### Q2:orphanRemoval = false 会导致什么问题?
|
|
336
|
+
|
|
337
|
+
**A**:从列表移除的子实体不会被删除,成为孤儿记录。
|
|
338
|
+
|
|
339
|
+
### Q3:能否在一个事务中操作多个聚合根?
|
|
340
|
+
|
|
341
|
+
**A**:违反 DDD 原则。应该使用分布式事务(Seata XA)或事件驱动(RocketMQ)。
|
|
342
|
+
|
|
343
|
+
### Q4:如何关闭自动级联?
|
|
344
|
+
|
|
345
|
+
**A**:不使用 `@OneToMany` 注解,手动管理子实体。
|
|
346
|
+
|
|
347
|
+
---
|
|
348
|
+
|
|
349
|
+
## 相关文档
|
|
350
|
+
|
|
351
|
+
- GatewayImpl 规范:[../SKILL.md](../SKILL.md)
|
|
352
|
+
- Gateway 接口规范:[../../domain/gateway/SKILL.md](../../domain/gateway/SKILL.md)
|
|
353
|
+
- 更新模式示例:[../../domain/entity/examples/update-patterns.md](../../domain/entity/examples/update-patterns.md)
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
# GatewayImpl - 聚合根 Gateway 实现示例
|
|
2
|
+
|
|
3
|
+
## 核心原则(⭐ 最重要)
|
|
4
|
+
|
|
5
|
+
**所有聚合根的 GatewayImpl 代码完全一样,无论有没有子实体**
|
|
6
|
+
|
|
7
|
+
| 标准 | 说明 |
|
|
8
|
+
|------|------|
|
|
9
|
+
| 继承 `AbstractAggregateRepository` | ✅ 必须 |
|
|
10
|
+
| 使用 `@Component` 注解 | ✅ 必须 |
|
|
11
|
+
| 实现 Gateway 接口 | ✅ 必须 |
|
|
12
|
+
| findById/save/delete 自动实现 | ✅ 无需编写 |
|
|
13
|
+
| 聚合根使用 `@AggregateRoot` 和 `@AggregateId` | ✅ 必须 |
|
|
14
|
+
|
|
15
|
+
**⚠️ 有没有子实体的区别**:
|
|
16
|
+
- GatewayImpl 代码没有任何区别
|
|
17
|
+
- 区别只在 Entity 的定义(聚合根是否有 `List<子实体>` 字段)
|
|
18
|
+
- 有子实体时,save/findById/delete 会自动级联处理,无需在 GatewayImpl 中编写额外代码
|
|
19
|
+
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
## GatewayImpl 标准示例
|
|
23
|
+
|
|
24
|
+
### 业务场景
|
|
25
|
+
国家(Country)聚合根的 Gateway 实现
|
|
26
|
+
|
|
27
|
+
### CountryGatewayImpl.java
|
|
28
|
+
|
|
29
|
+
**位置**:`infrastructure/gatewayimpl/CountryGatewayImpl.java`
|
|
30
|
+
|
|
31
|
+
```java
|
|
32
|
+
package com.trob4cloud.service.basis.infrastructure.gatewayimpl;
|
|
33
|
+
|
|
34
|
+
import com.trob4cloud.common.mybatis.extension.ddd.repository.AbstractAggregateRepository;
|
|
35
|
+
import com.trob4cloud.service.basis.domain.country.CountryGateway;
|
|
36
|
+
import com.trob4cloud.service.basis.domain.country.model.Country;
|
|
37
|
+
import org.springframework.stereotype.Component;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* 国家 Gateway 实现
|
|
41
|
+
*
|
|
42
|
+
* ⚠️ 继承 AbstractAggregateRepository 后:
|
|
43
|
+
* 1. findById、save、delete、exists 等方法已自动实现
|
|
44
|
+
* 2. 无需手动注入 Repository
|
|
45
|
+
* 3. 无需手动编写 CRUD 方法
|
|
46
|
+
* 4. 大部分场景下,GatewayImpl 是空实现
|
|
47
|
+
*
|
|
48
|
+
* @author AI Generated
|
|
49
|
+
*/
|
|
50
|
+
@Component
|
|
51
|
+
public class CountryGatewayImpl extends AbstractAggregateRepository<Country, Integer> implements CountryGateway {
|
|
52
|
+
|
|
53
|
+
// ==================== 继承的方法(无需编写) ====================
|
|
54
|
+
|
|
55
|
+
// ✅ findById(id) - 自动实现
|
|
56
|
+
// ✅ save(aggregate) - 自动实现
|
|
57
|
+
// ✅ delete(id) - 自动实现
|
|
58
|
+
// ✅ exists(...) - 自动实现
|
|
59
|
+
|
|
60
|
+
// ==================== 大部分场景下无需编写任何代码 ====================
|
|
61
|
+
|
|
62
|
+
// 如果有特殊的查询需求,可以添加自定义方法
|
|
63
|
+
}
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### CountryGateway.java(接口)
|
|
67
|
+
|
|
68
|
+
**位置**:`domain/country/CountryGateway.java`
|
|
69
|
+
|
|
70
|
+
```java
|
|
71
|
+
package com.trob4cloud.service.basis.domain.country;
|
|
72
|
+
|
|
73
|
+
import com.trob4cloud.common.mybatis.extension.ddd.gateway.BaseGateway;
|
|
74
|
+
import com.trob4cloud.service.basis.domain.country.model.Country;
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* 国家 Gateway 接口
|
|
78
|
+
*
|
|
79
|
+
* ⚠️ 继承 BaseGateway 后已自动提供:
|
|
80
|
+
* - findById(id)
|
|
81
|
+
* - save(aggregate)
|
|
82
|
+
* - delete(id)
|
|
83
|
+
* - exists(...)
|
|
84
|
+
*
|
|
85
|
+
* 大部分场景下无需添加额外方法
|
|
86
|
+
*/
|
|
87
|
+
public interface CountryGateway extends BaseGateway<Country, Integer> {
|
|
88
|
+
|
|
89
|
+
// 大部分场景下无需定义额外方法
|
|
90
|
+
// 如果有特殊查询需求,可以在这里添加
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## 自动级联机制(整存整取)
|
|
95
|
+
|
|
96
|
+
### 保存聚合根(自动级联)
|
|
97
|
+
|
|
98
|
+
```java
|
|
99
|
+
// CmdExe 中使用
|
|
100
|
+
PlatformType platform = new PlatformType("Amazon");
|
|
101
|
+
platform.setSites(Arrays.asList(
|
|
102
|
+
new PlatformSite("Amazon US", "US"),
|
|
103
|
+
new PlatformSite("Amazon UK", "UK")
|
|
104
|
+
));
|
|
105
|
+
|
|
106
|
+
// ✅ 一次调用,自动保存聚合根 + 所有子实体
|
|
107
|
+
platformGateway.save(platform);
|
|
108
|
+
|
|
109
|
+
// 自动执行:
|
|
110
|
+
// 1. INSERT INTO bse_platform_type (...)
|
|
111
|
+
// 2. INSERT INTO bse_platform_site (...) -- 自动插入 2 条
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### 查询聚合根(自动级联加载)
|
|
115
|
+
|
|
116
|
+
```java
|
|
117
|
+
// ✅ 自动加载聚合根 + 所有子实体
|
|
118
|
+
PlatformType platform = platformGateway.findById(platformId);
|
|
119
|
+
|
|
120
|
+
// 自动执行:
|
|
121
|
+
// 1. SELECT * FROM bse_platform_type WHERE platform_type_id = ?
|
|
122
|
+
// 2. SELECT * FROM bse_platform_site WHERE platform_type_id = ? -- 自动级联查询
|
|
123
|
+
|
|
124
|
+
// 可以直接访问子实体
|
|
125
|
+
List<PlatformSite> sites = platform.getSites();
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### 删除聚合根(自动级联删除)
|
|
129
|
+
|
|
130
|
+
```java
|
|
131
|
+
// ✅ 自动删除聚合根 + 所有子实体
|
|
132
|
+
platformGateway.delete(platformId);
|
|
133
|
+
|
|
134
|
+
// 自动执行:
|
|
135
|
+
// 1. DELETE FROM bse_platform_site WHERE platform_type_id = ? -- 先删子实体
|
|
136
|
+
// 2. DELETE FROM bse_platform_type WHERE platform_type_id = ? -- 再删聚合根
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## 自定义查询方法示例(可选)
|
|
142
|
+
|
|
143
|
+
**大部分场景下 GatewayImpl 是空实现**,如果确实需要特殊查询,可以添加自定义方法:
|
|
144
|
+
|
|
145
|
+
```java
|
|
146
|
+
@Component
|
|
147
|
+
public class PlatformGatewayImpl extends AbstractAggregateRepository<PlatformType, Integer> implements PlatformGateway {
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* 查询指定平台的所有站点(特殊查询需求)
|
|
151
|
+
*/
|
|
152
|
+
@Override
|
|
153
|
+
public List<PlatformSite> findSitesByPlatformId(Integer platformTypeId) {
|
|
154
|
+
return MapperDb.selectList(PlatformSite.class,
|
|
155
|
+
Wrappers.lambdaQuery(PlatformSite.class)
|
|
156
|
+
.eq(PlatformSite::getPlatformTypeId, platformTypeId));
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* 判断指定平台和国家的站点是否存在(特殊校验需求)
|
|
161
|
+
*/
|
|
162
|
+
@Override
|
|
163
|
+
public boolean existsSiteByPlatformAndCountry(Integer platformTypeId, Integer countryId) {
|
|
164
|
+
return MapperDb.selectCount(PlatformSite.class,
|
|
165
|
+
Wrappers.lambdaQuery(PlatformSite.class)
|
|
166
|
+
.eq(PlatformSite::getPlatformTypeId, platformTypeId)
|
|
167
|
+
.eq(PlatformSite::getCountryId, countryId)) > 0;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## Gateway 的职责
|
|
173
|
+
|
|
174
|
+
| 方法类型 | 职责 | 是否必须编写 |
|
|
175
|
+
|---------|------|-------------|
|
|
176
|
+
| 查询聚合根 | `findById()` | ❌ 自动提供 |
|
|
177
|
+
| 保存聚合根 | `save()` | ❌ 自动提供 |
|
|
178
|
+
| 删除聚合根 | `delete()` | ❌ 自动提供 |
|
|
179
|
+
| 判断存在 | `exists()` | ❌ 自动提供 |
|
|
180
|
+
| 特殊查询 | 自定义方法 | ✅ 按需编写 |
|
|
181
|
+
|
|
182
|
+
**⚠️ 重要**:
|
|
183
|
+
- Gateway 只做数据访问,不包含业务逻辑
|
|
184
|
+
- 大部分场景下 GatewayImpl 是空实现
|
|
185
|
+
- 只在有特殊查询需求时才添加自定义方法
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## 检查清单
|
|
190
|
+
|
|
191
|
+
### GatewayImpl
|
|
192
|
+
|
|
193
|
+
- [ ] 继承 `AbstractAggregateRepository<聚合根, ID类型>`
|
|
194
|
+
- [ ] 使用 `@Component` 注解
|
|
195
|
+
- [ ] 实现 Gateway 接口
|
|
196
|
+
- [ ] **不手动注入** Repository(父类已处理)
|
|
197
|
+
- [ ] **不添加** `@Transactional` 注解(事务在 AppService)
|
|
198
|
+
- [ ] **不重写** findById/save/delete/exists(父类已自动实现)
|
|
199
|
+
- [ ] **大部分场景下是空实现**(无需编写任何代码)
|
|
200
|
+
- [ ] 只在有特殊查询需求时才添加自定义方法
|
|
201
|
+
|
|
202
|
+
### 聚合根(Entity)
|
|
203
|
+
|
|
204
|
+
- [ ] 使用 `@AggregateRoot(aggregateKey = "字段名")` 注解
|
|
205
|
+
- [ ] ID 字段使用 `@AggregateId` 注解
|
|
206
|
+
- [ ] 如果有子实体,添加 `List<子实体>` 字段
|
|
207
|
+
- [ ] 子实体集合字段添加 `@TableField(exist = false)`
|
|
208
|
+
|
|
209
|
+
### 子实体(Entity)
|
|
210
|
+
|
|
211
|
+
- [ ] 外键字段使用 `@AggregateKey` 注解
|
|
212
|
+
- [ ] 继承 `BaseEntity`
|
|
213
|
+
|
|
214
|
+
---
|
|
215
|
+
|
|
216
|
+
## 常见错误
|
|
217
|
+
|
|
218
|
+
### 错误 1:手动注入 Repository
|
|
219
|
+
|
|
220
|
+
```java
|
|
221
|
+
// ❌ 错误:手动注入 Repository
|
|
222
|
+
@Component
|
|
223
|
+
@RequiredArgsConstructor
|
|
224
|
+
public class CountryGatewayImpl extends AbstractAggregateRepository<Country, Integer> implements CountryGateway {
|
|
225
|
+
private final CountryRepository countryRepository; // ❌ 不需要注入
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// ✅ 正确:不注入任何 Repository
|
|
229
|
+
@Component
|
|
230
|
+
public class CountryGatewayImpl extends AbstractAggregateRepository<Country, Integer> implements CountryGateway {
|
|
231
|
+
// 无需注入 Repository,父类已处理
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### 错误 2:重写 save() 方法
|
|
236
|
+
|
|
237
|
+
```java
|
|
238
|
+
// ❌ 错误:手动处理保存逻辑
|
|
239
|
+
@Override
|
|
240
|
+
public void save(Country country) {
|
|
241
|
+
countryRepository.saveOrUpdate(country); // ❌ 不需要重写
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
// ✅ 正确:继承的 save() 方法已自动处理,无需重写
|
|
245
|
+
// 不编写任何代码,直接使用 save() 方法
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### 错误 3:手动处理子实体
|
|
249
|
+
|
|
250
|
+
```java
|
|
251
|
+
// ❌ 错误:手动保存子实体
|
|
252
|
+
@Override
|
|
253
|
+
public void save(PlatformType platform) {
|
|
254
|
+
platformRepository.save(platform); // ❌ 手动保存
|
|
255
|
+
for (PlatformSite site : platform.getSites()) {
|
|
256
|
+
siteRepository.save(site); // ❌ 手动保存子实体
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// ✅ 正确:继承的 save() 方法会自动级联处理子实体
|
|
261
|
+
// 无需重写 save() 方法,父类已自动级联保存
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### 错误 4:添加事务注解
|
|
265
|
+
|
|
266
|
+
```java
|
|
267
|
+
// ❌ 错误:在 Gateway 层加事务
|
|
268
|
+
@Component
|
|
269
|
+
public class CountryGatewayImpl extends AbstractAggregateRepository<Country, Integer> implements CountryGateway {
|
|
270
|
+
|
|
271
|
+
@Transactional // ❌ 不应该在 Gateway 层加事务
|
|
272
|
+
public void save(Country country) {}
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
// ✅ 正确:事务在 AppService 层
|
|
276
|
+
@Service
|
|
277
|
+
public class CountryAppServiceImpl {
|
|
278
|
+
@Transactional(rollbackFor = Exception.class) // ✅ 事务在这里
|
|
279
|
+
public void create(CreateCountryCmd cmd) {
|
|
280
|
+
countryGateway.save(country);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
### 错误 5:Gateway 中包含业务逻辑
|
|
286
|
+
|
|
287
|
+
```java
|
|
288
|
+
// ❌ 错误:Gateway 中包含业务逻辑
|
|
289
|
+
@Override
|
|
290
|
+
public void save(Country country) {
|
|
291
|
+
if (country.getStatus() == StatusEnum.ENABLE) {
|
|
292
|
+
// ❌ 业务逻辑不应该在 Gateway 中
|
|
293
|
+
country.setActiveTime(LocalDateTime.now());
|
|
294
|
+
}
|
|
295
|
+
super.save(country);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
// ✅ 正确:业务逻辑在聚合根的业务方法中
|
|
299
|
+
// Country.java
|
|
300
|
+
public void enable() {
|
|
301
|
+
this.status = StatusEnum.ENABLE;
|
|
302
|
+
this.setActiveTime(LocalDateTime.now()); // ✅ 业务逻辑在聚合根
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
// CmdExe 中调用
|
|
306
|
+
country.enable(); // ✅ 调用聚合根的业务方法
|
|
307
|
+
countryGateway.save(country); // ✅ Gateway 只做保存
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
---
|
|
311
|
+
|
|
312
|
+
## 相关文档
|
|
313
|
+
|
|
314
|
+
- Gateway 接口规范:[../../domain/gateway/SKILL.md](../../domain/gateway/SKILL.md)
|
|
315
|
+
- Entity 规范:[../../domain/entity/SKILL.md](../../domain/entity/SKILL.md)
|
|
316
|
+
- GatewayImpl 规范:[../SKILL.md](../SKILL.md)
|