
1、根据下面模型文件，完整代码实现案例（含前端React端到端测试页Demo)，特别是M4的flowSteps,M2的bizSteps，MetaRule，架构引擎负责解释与执行，各层釆用什么具体技术，M 8前端模板定义及如何与具体业务绑定，并用案例方式推演解释整体架构的运行原理

2、以上方案实现使用 Claude Code 全流程开发，包含工程目录结构、Claude专用配置、全套建模YAML、后端Java引擎源码、React前端Demo、场景推演文档、代码生成模板、部署脚本、测试用例等等。

模型文件如下：
本体驱动 DDD+EDA 全量11份YAML架构文档 v2.0
架构总述
版本：v2.0 | 状态：生产级完备，支持代码生成
架构分层全集：M0-meta-schema、M1-domain、M2-command、ME-event、M3-deploy、M4-scene、M5-security、M6-monitor、M7-sla、MetaRule-business、M8-front-schema
核心扩展：新增M8-front-schema React可视化拖拽建模层，M0补充前端模板完整JSON Schema校验；全量兼容原有DDD+EDA本体模型，无破坏性变更、仅增量扩展；实现业务专家无代码拖拽生成React页面，页面数据源强制绑定M1领域模型，页面自动关联M4场景、M2命令API、M5脱敏权限、MetaRule动态规则，实现后期仅维护模板、不修改前端业务源码。

一、M0-meta-schema.yaml（全域元数据校验根规范，新增M8前端Schema定义）
meta_model:
  version: "2.0"
  $schema: https://json-schema.org/draft/2020-12/schema
  definitions:
    # 基础通用标识类型
    Identifier:
      type: string
      pattern: "^[a-z][a-zA-Z0-9]*$"
      description: 小写驼峰字段/组件标识
    UpperIdentifier:
      type: string
      pattern: "^[A-Z][a-zA-Z0-9]*$"
      description: 大写驼峰聚合/命令/事件ID
    NonEmptyString:
      type: string
      minLength: 1
    SceneId:
      type: string
      pattern: "^SCENE_[A-Z0-9_]+$"
    RuleId:
      type: string
      pattern: "^R_[A-Z0-9_]+$"
    TopicName:
      type: string
      pattern: "^topic_[a-z0-9_]+$"
    ConsistencyTypeEnum:
      type: string
      enum: [strong, eventual]
    DbEngineEnum:
      type: string
      enum: [mysql8]
    AuthModeEnum:
      type: string
      enum: [oauth2_jwt]

    # ========== M8前端专用枚举（新增） ==========
    FrontTemplateTypeEnum:
      type: string
      enum: [single_table_form, master_detail_form, custom_drag_form]
      description: single_table_form单实体表单；master_detail_form主从表单；custom_drag_form自定义空白拖拽模板
    FrontComponentEnum:
      type: string
      enum: [input, number_input, date_picker, switch, table, card, text_area, select]
      description: React底层原子拖拽组件
    BindSourceTypeEnum:
      type: string
      enum: [aggregate_root, aggregate_entity]
      description: 组件绑定数据源类型：聚合根/聚合内部子实体
    ReactRenderModeEnum:
      type: string
      enum: [form_modal, page_container, drawer]
      description: 页面渲染载体：弹窗/整页/侧边抽屉

    # M1 领域模型单元定义
    M1_Attribute:
      type: object
      required: [name, type]
      properties:
        name: { $ref: "#/definitions/Identifier" }
        type:
          type: string
          enum: [string, int, decimal, datetime, boolean]
        refAggregate: { type: string }
        refRoot: { type: string }
        refIdentifier: { type: string }
        description: { type: string }
    M1_Relation:
      type: object
      required: [ref, relationType]
      properties:
        ref: { $ref: "#/definitions/NonEmptyString" }
        relationType:
          type: string
          enum: [composition]
    M1_Entity:
      type: object
      required: [name, localIdentifier, attributes]
      properties:
        name: { $ref: "#/definitions/NonEmptyString" }
        localIdentifier: { $ref: "#/definitions/Identifier" }
        attributes:
          type: array
          items: { $ref: "#/definitions/M1_Attribute" }
    M1_AggregateRoot:
      type: object
      required: [name, identifier, attributes]
      properties:
        name: { $ref: "#/definitions/NonEmptyString" }
        identifier: { $ref: "#/definitions/Identifier" }
        attributes:
          type: array
          items: { $ref: "#/definitions/M1_Attribute" }
        relations:
          type: array
          items: { $ref: "#/definitions/M1_Relation" }
    M1_Aggregate:
      type: object
      required: [aggregateId, description, aggregateRoot]
      properties:
        aggregateId:
          type: string
          pattern: "^[A-Z][a-zA-Z]+Aggregate$"
        description: { $ref: "#/definitions/NonEmptyString" }
        aggregateRoot: { $ref: "#/definitions/M1_AggregateRoot" }
        entities:
          type: array
          items: { $ref: "#/definitions/M1_Entity" }
        valueObjects:
          type: array
          maxItems: 0

    # M2 命令行为单元定义
    M2_InputParam:
      type: object
      required: [name, type]
      properties:
        name: { $ref: "#/definitions/Identifier" }
        type: { type: string }
        optional: { type: boolean }
    M2_Command:
      type: object
      required: [cmdId, desc, inputParams, validations, emitEvents]
      properties:
        cmdId: { $ref: "#/definitions/UpperIdentifier" }
        desc: { $ref: "#/definitions/NonEmptyString" }
        inputParams:
          type: array
          items: { $ref: "#/definitions/M2_InputParam" }
        validations:
          type: array
          items: { type: string }
        bizSteps: { type: string }
        emitEvents:
          type: array
          items: { $ref: "#/definitions/UpperIdentifier" }
        sideEffect: { type: string }
    M2_AggregateBehavior:
      type: object
      required: [aggregateId, aggregateRoot, commands]
      properties:
        aggregateId:
          type: string
          pattern: "^[A-Z][a-zA-Z]+Aggregate$"
        aggregateRoot: { $ref: "#/definitions/NonEmptyString" }
        commands:
          type: array
          items: { $ref: "#/definitions/M2_Command" }

    # ME 事件模型单元定义
    ME_Event:
      type: object
      required: [topic, payload]
      properties:
        topic: { $ref: "#/definitions/TopicName" }
        payload:
          type: array
          items: { $ref: "#/definitions/Identifier" }
        consumers:
          type: array
          items: { type: string }
    ME_OutboxConfig:
      type: object
      required: [enabled, table]
      properties:
        enabled: { type: boolean }
        table: { $ref: "#/definitions/NonEmptyString" }
        pollInterval: { type: string }
        batchSize: { type: integer, minimum:1 }
        cleanupDays: { type: integer, minimum:1 }
    ME_CrossConsistencyRule:
      type: object
      required: [triggerEvent, targetAggregate, targetCommand, consistencyType]
      properties:
        triggerEvent: { $ref: "#/definitions/UpperIdentifier" }
        targetAggregate:
          type: string
          pattern: "^[A-Z][a-zA-Z]+Aggregate$"
        targetCommand: { $ref: "#/definitions/UpperIdentifier" }
        consistencyType: { $ref: "#/definitions/ConsistencyTypeEnum" }

    # M3 存储部署映射单元定义
    M3_TableMapping:
      type: object
      required: [domainEntity, table, pk, fieldMap]
      properties:
        domainEntity: { $ref: "#/definitions/NonEmptyString" }
        table: { $ref: "#/definitions/NonEmptyString" }
        pk: { $ref: "#/definitions/Identifier" }
        shardRule: { type: string }
        fieldMap:
          type: object
          additionalProperties: { type: string }
    M3_AggregateDeploy:
      type: object
      required: [aggregateId, serviceName, commandApi, tableMappings]
      properties:
        aggregateId:
          type: string
          pattern: "^[A-Z][a-zA-Z]+Aggregate$"
        serviceName:
          type: string
          pattern: "^[a-z-]+-service$"
        commandApi:
          type: object
          additionalProperties:
            type: string
            pattern: "^/api/v1/.+"
        tableMappings:
          type: array
          items: { $ref: "#/definitions/M3_TableMapping" }

    # M4 业务场景编排单元定义
    M4_SceneStep:
      type: object
      required: [stepType]
      properties:
        stepType:
          type: string
          enum: [bindCommand, readOnlyCheck, loopItems, return]
        bindAggregate: { type: string }
        bindCommand: { $ref: "#/definitions/UpperIdentifier" }
    M4_Scene:
      type: object
      required: [sceneId, sceneName, aggregateScope, permissionBind, flowSteps]
      properties:
        sceneId: { $ref: "#/definitions/SceneId" }
        sceneName: { $ref: "#/definitions/NonEmptyString" }
        aggregateScope:
          type: array
          items:
            type: string
            pattern: "^[A-Z][a-zA-Z]+Aggregate$"
        permissionBind:
          type: array
          items: { $ref: "#/definitions/Identifier" }
        flowSteps:
          type: array
          items: { $ref: "#/definitions/M4_SceneStep" }

    # M5 安全权限单元定义
    M5_SecurityRoot:
      type: object
      required: [globalConfig, principals, functionPermissions, maskRules, encryptRules]
    # M6 监控告警单元定义
    M6_Alert:
      type: object
      required: [desc, level, trigger]
      properties:
        desc: { type: string }
        level:
          type: string
          enum: [严重告警, 警告告警]
        trigger: { type: string }
    M6_MonitorRoot:
      type: object
      required: [globalConfig, serviceMetricBind, alertRules]
    # M7 流量SLA单元定义
    M7_QualityRoot:
      type: object
      required: [aggregateSla, commandSla, sceneSla, flowControl]
    # MetaRule 动态业务规则单元定义
    MetaRule_Param:
      type: object
      required: [paramId, name, dataType, defaultValue]
    MetaRule_Item:
      type: object
      required: [ruleId, ruleVersion, ruleName, matchCondition, effect, message]
      properties:
        ruleId: { $ref: "#/definitions/RuleId" }
        effect:
          type: string
          enum: [REJECT, ALERT, SKIP_CHECK, CALC_FILL, COMPENSATE]
    MetaRule_Group:
      type: object
      required: [groupId, groupType, bindScene, rules]

    # ===================== M8 前端拖拽模板完整定义（新增核心） =====================
    M8_FrontFieldBind:
      type: object
      required: [bindAggregateId, bindSourceType, domainFieldName]
      properties:
        bindAggregateId:
          type: string
          pattern: "^[A-Z][a-zA-Z]+Aggregate$"
        bindSourceType: { $ref: "#/definitions/BindSourceTypeEnum" }
        domainEntityName: { type: string }
        domainFieldName: { $ref: "#/definitions/Identifier" }
        formLabel: { type: string }
        placeholder: { type: string }
        required: { type: boolean }
        maskField: { type: boolean }
    M8_FrontDragComponent:
      type: object
      required: [compId, compType, fieldBind]
      properties:
        compId: { $ref: "#/definitions/Identifier" }
        compType: { $ref: "#/definitions/FrontComponentEnum" }
        width: { type: string }
        span: { type: integer }
        fieldBind: { $ref: "#/definitions/M8_FrontFieldBind" }
        childComponents:
          type: array
          items: { $ref: "#/definitions/M8_FrontDragComponent" }
    M8_FrontPageTemplate:
      type: object
      required: [templateId, templateName, templateType, renderMode, bindSceneId, rootComponents]
      properties:
        templateId: { $ref: "#/definitions/Identifier" }
        templateName: { $ref: "#/definitions/NonEmptyString" }
        templateType: { $ref: "#/definitions/FrontTemplateTypeEnum" }
        renderMode: { $ref: "#/definitions/ReactRenderModeEnum" }
        bindSceneId: { $ref: "#/definitions/SceneId" }
        masterAggregate: { type: string }
        detailAggregates:
          type: array
          items: { type: string }
        rootComponents:
          type: array
          items: { $ref: "#/definitions/M8_FrontDragComponent" }
    M8_FrontSchema:
      type: object
      required: [reactGlobalConfig, pageTemplates]
      properties:
        reactGlobalConfig:
          type: object
          required: [uiLib, dragEngineStorage]
          properties:
            uiLib:
              type: string
              const: antd
            dragEngineStorage:
              type: string
              const: mysql8
        pageTemplates:
          type: array
          items: { $ref: "#/definitions/M8_FrontPageTemplate" }

    # 各分层根Schema定义（新增M8根校验）
    M1_Schema:
      type: object
      required: [aggregates, globalConstraints]
    M2_Schema:
      type: object
      required: [behaviors, globalBehaviorConstraints]
    ME_Schema:
      type: object
      required: [eventModel]
    M3_Schema:
      type: object
      required: [deploymentMappings]
    M4_Schema:
      type: object
      required: [sceneModel]
    M5_Schema:
      type: object
      required: [securityModel]
    M6_Schema:
      type: object
      required: [monitorModel]
    M7_Schema:
      type: object
      required: [qualityModel]
    MetaRule_Schema:
      type: object
      required: [metaRuleModel]
    M8_Schema:
      type: object
      required: [frontModel]

  rootAllOntologySchema:
    type: object
    oneOf:
      - {$ref: "#/definitions/M1_Schema"}
      - {$ref: "#/definitions/M2_Schema"}
      - {$ref: "#/definitions/ME_Schema"}
      - {$ref: "#/definitions/M3_Schema"}
      - {$ref: "#/definitions/M4_Schema"}
      - {$ref: "#/definitions/M5_Schema"}
      - {$ref: "#/definitions/M6_Schema"}
      - {$ref: "#/definitions/M7_Schema"}
      - {$ref: "#/definitions/MetaRule_Schema"}
      - {$ref: "#/definitions/M8_Schema"}
二、M1-domain.yaml（DDD领域聚合静态模型，无修改）
# M1 DDD聚合领域静态模型
aggregates:
  # 聚合1：客户聚合 CustomerAggregate
  - aggregateId: CustomerAggregate
    description: 客户主数据聚合，独立事务边界
    aggregateRoot:
      name: Customer
      identifier: customerId
      attributes:
        - name: customerName
          type: string
        - name: contactPhone
          type: string
        - name: registerTime
          type: datetime
        - name: customerLevel
          type: string
    entities: []
    valueObjects: []

  # 聚合2：产品聚合 ProductAggregate
  - aggregateId: ProductAggregate
    description: 商品主数据聚合，独立事务边界
    aggregateRoot:
      name: Product
      identifier: productId
      attributes:
        - name: productName
          type: string
        - name: skuCode
          type: string
        - name: category
          type: string
        - name: saleCurrency
          type: string
        - name: salePrice
          type: decimal
        - name: stockNum
          type: int
        - name: isOnSale
          type: boolean
    entities: []
    valueObjects: []

  # 聚合3：订单聚合 OrderAggregate
  - aggregateId: OrderAggregate
    description: 订单业务聚合，独立事务边界
    aggregateRoot:
      name: Order
      identifier: orderId
      attributes:
        - name: createTime
          type: datetime
        - name: totalCurrency
          type: string
        - name: totalAmount
          type: decimal
        - name: customerId
          type: string
          refAggregate: CustomerAggregate
          refRoot: Customer
          refIdentifier: customerId
          description: 客户ID，引用客户聚合根主键
      relations:
        - ref: OrderItem
          relationType: composition
        - ref: PaymentTerm
          relationType: composition
        - ref: DeliveryAddressEntity
          relationType: composition
    entities:
      - name: OrderItem
        localIdentifier: itemId
        attributes:
          - name: productId
            type: string
            refAggregate: ProductAggregate
            refRoot: Product
            refIdentifier: productId
            description: 商品ID，引用产品聚合根主键
          - name: quantity
            type: int
          - name: itemCurrency
            type: string
          - name: itemPrice
            type: decimal
      - name: PaymentTerm
        localIdentifier: termId
        attributes:
          - name: paymentType
            type: string
          - name: dueDays
            type: int
          - name: depositRatio
            type: decimal
          - name: settleCurrency
            type: string
          - name: settleAmount
            type: decimal
      - name: DeliveryAddressEntity
        localIdentifier: addrId
        attributes:
          - name: province
            type: string
          - name: city
            type: string
          - name: district
            type: string
          - name: streetDetail
            type: string
          - name: receiverName
            type: string
          - name: receiverPhone
            type: string
    valueObjects: []

globalConstraints:
  - crossAggRefRule: 跨聚合仅允许引用对方【聚合根唯一标识】，禁止引用对方内部实体、值对象
  - transactionBoundary: 一次事务只能修改同一个聚合内对象，跨聚合拆分为多个事务
  - cascadeDelete: 聚合根删除时，级联删除自身内部所有组合子实体
  - foreignKeyStrategy: 业务层做引用校验，默认不创建数据库物理外键；如需物理外键增加 dbForeignKey: true
三、M2-command.yaml（聚合命令行为模型，无修改）
# M2 聚合行为命令模型
behaviors:
  # 1.客户聚合行为
  - aggregateId: CustomerAggregate
    aggregateRoot: Customer
    commands:
      - cmdId: CreateCustomer
        desc: 新增客户主数据
        inputParams:
          - name: customerName
            type: string
          - name: contactPhone
            type: string
          - name: customerLevel
            type: string
        validations:
          - contactPhone非空、手机号格式校验
          - customerLevel取值范围[普通,VIP,高级VIP]
        emitEvents:
          - CustomerCreated
        sideEffect: 仅写入本聚合，不可修改其他聚合

      - cmdId: ModifyCustomerInfo
        desc: 修改客户名称、联系方式、等级
        inputParams:
          - name: customerId
            type: string
          - name: customerName
            type: string
            optional: true
          - name: contactPhone
            type: string
            optional: true
          - name: customerLevel
            type: string
            optional: true
        validations:
          - customerId必须存在
        emitEvents:
          - CustomerInfoModified

  # 2.产品聚合行为
  - aggregateId: ProductAggregate
    aggregateRoot: Product
    commands:
      - cmdId: CreateProduct
        desc: 新增商品档案
        inputParams:
          - name: productName
            type: string
          - name: skuCode
            type: string
          - name: category
            type: string
          - name: saleCurrency
            type: string
          - name: salePrice
            type: decimal
          - name: stockNum
            type: int
          - name: isOnSale
            type: boolean
        validations:
          - skuCode全局唯一
          - salePrice > 0
          - stockNum >= 0
        emitEvents:
          - ProductCreated

      - cmdId: ModifyProductPrice
        desc: 修改售价与币种
        inputParams:
          - name: productId
            type: string
          - name: saleCurrency
            type: string
            optional: true
          - name: salePrice
            type: decimal
            optional: true
        validations:
          - productId存在
          - 修改后售价>0
        emitEvents:
          - ProductPriceChanged

      - cmdId: StockDeduct
        desc: 下单扣减库存（订单聚合远程调用）
        inputParams:
          - name: productId
            type: string
          - name: deductQty
            type: int
        validations:
          - 可用库存 >= deductQty
        emitEvents:
          - ProductStockDeducted

  # 3.订单聚合行为
  - aggregateId: OrderAggregate
    aggregateRoot: Order
    commands:
      - cmdId: CreateOrder
        desc: 创建订单主单+明细+付款条件+送货地址
        inputParams:
          - name: customerId
            type: string
          - name: totalCurrency
            type: string
          - name: totalAmount
            type: decimal
          - name: items
            type: array
          - name: paymentTerm
            type: object
          - name: deliveryAddress
            type: object
        validations:
          - customerId 存在于CustomerAggregate
          - 所有productId存在于ProductAggregate
          - 订单明细金额累加 ≈ 订单总金额
          - dueDays >= 0, depositRatio ∈ [0,1]
          - 收货手机号格式合法
        bizSteps: "1.构建Order聚合根主记录 2.批量构建OrderItem子实体 3.构建PaymentTerm、DeliveryAddressEntity子实体 4.远程调用Product聚合StockDeduct扣减各商品库存"
        emitEvents:
          - OrderCreated
          - OrderItemAdded
          - OrderPaymentTermSet
          - OrderDeliveryAddressSet

      - cmdId: ModifyOrderDeliveryAddress
        desc: 修改订单送货地址子实体
        inputParams:
          - name: orderId
            type: string
          - name: province
            type: string
            optional: true
          - name: city
            type: string
            optional: true
          - name: district
            type: string
            optional: true
          - name: streetDetail
            type: string
            optional: true
          - name: receiverName
            type: string
            optional: true
          - name: receiverPhone
            type: string
            optional: true
        validations:
          - orderId存在
        emitEvents:
          - OrderDeliveryAddressModified

      - cmdId: CancelOrder
        desc: 取消订单，归还库存
        inputParams:
          - name: orderId
            type: string
        validations:
          - 订单状态允许取消
        bizSteps: "1.校验订单可取消状态 2.查询订单全部明细商品与数量 3.远程调用Product聚合增加对应库存 4.标记订单作废"
        emitEvents:
          - OrderCancelled

globalBehaviorConstraints:
  - 命令只能操作所属聚合内部对象，跨聚合仅允许调用对方聚合根暴露Command，禁止直接操作对方内部实体
  - 单个命令事务边界仅限当前聚合；跨聚合操作拆为分布式事件最终一致性
  - 子实体只能被所属聚合根命令修改，外部无法直接操作
  - 所有跨聚合依赖仅基于对方聚合根ID做校验，不依赖内部字段
四、ME-event.yaml（EDA事件驱动模型，无修改）
eventModel:
  globalConfig:
    idGenerator: snowflake
    bus: rocketmq
    retry: 3
    dlq: topic_msg_dlq
    outbox:
      enabled: true
      table: t_domain_outbox
      pollInterval: 1000ms
      batchSize: 50
      cleanupDays: 7

  aggregateEventDefinitions:
    - aggregateId: CustomerAggregate
      events:
        CustomerCreated:
          topic: topic_customer_create
          payload: [customerId,customerName,customerLevel]
          consumers: [customer-service]
        CustomerInfoModified:
          topic: topic_customer_modify
          payload: [customerId,contactPhone,customerLevel]
          consumers: [customer-service]

    - aggregateId: ProductAggregate
      events:
        ProductCreated:
          topic: topic_product_create
          payload: [productId,skuCode,salePrice,stockNum]
          consumers: [product-service]
        ProductPriceChanged:
          topic: topic_product_price
          payload: [productId,salePrice,saleCurrency]
          consumers: [order-service]
        ProductStockDeducted:
          topic: topic_stock_deduct
          payload: [productId,stockNum]
          consumers: [order-service]

    - aggregateId: OrderAggregate
      events:
        OrderCreated:
          topic: topic_order_create
          payload: [orderId,customerId,totalAmount]
          consumers: [product-service,customer-service]
        OrderDeliveryAddressModified:
          topic: topic_order_addr_modify
          payload: [orderId,receiverPhone]
          consumers: [order-service]
        OrderCancelled:
          topic: topic_order_cancel
          payload: [orderId,productIdList]
          consumers: [product-service]

  crossAggConsistencyRules:
    - triggerEvent: OrderCreated
      targetAggregate: ProductAggregate
      targetCommand: StockDeduct
      consistencyType: eventual
    - triggerEvent: OrderCancelled
      targetAggregate: ProductAggregate
      targetCommand: StockDeduct
      consistencyType: eventual
五、M3-deploy.yaml（服务存储部署映射，无修改）
deploymentMappings:
  globalConfig:
    dbEngine: mysql8
    defaultSchema: trade_db
    idGen: snowflake

  aggregateMappingList:
    - aggregateId: CustomerAggregate
      serviceName: customer-service
      commandApi:
        CreateCustomer: /api/v1/customer/create
        ModifyCustomerInfo: /api/v1/customer/modify
      tableMappings:
        - domainEntity: Customer
          table: t_customer_main
          pk: customer_id
          fieldMap:
            customerId: customer_id
            customerName: cust_name
            contactPhone: phone
            registerTime: register_time
            customerLevel: cust_level

    - aggregateId: ProductAggregate
      serviceName: product-service
      commandApi:
        CreateProduct: /api/v1/product/create
        ModifyProductPrice: /api/v1/product/price
        StockDeduct: /api/v1/product/stock/deduct
      tableMappings:
        - domainEntity: Product
          table: t_product_main
          pk: product_id
          fieldMap:
            productId: product_id
            productName: prod_name
            skuCode: sku_code
            category: category
            saleCurrency: currency
            salePrice: sale_price
            stockNum: stock_num
            isOnSale: is_on_sale

    - aggregateId: OrderAggregate
      serviceName: order-service
      commandApi:
        CreateOrder: /api/v1/order/create
        ModifyOrderDeliveryAddress: /api/v1/order/addr
        CancelOrder: /api/v1/order/cancel
      tableMappings:
        - domainEntity: Order
          table: t_order_main
          pk: order_id
          fieldMap:
            orderId: order_id
            createTime: create_time
            totalCurrency: total_currency
            totalAmount: total_amt
            customerId: cust_id
        - domainEntity: OrderItem
          table: t_order_item
          pk: item_id
          fieldMap:
            itemId: item_id
            productId: product_id
            quantity: buy_qty
            itemCurrency: item_currency
            itemPrice: item_price
        - domainEntity: PaymentTerm
          table: t_order_payment_term
          pk: term_id
          fieldMap:
            termId: term_id
            paymentType: pay_type
            dueDays: due_days
            depositRatio: deposit_ratio
            settleCurrency: settle_currency
            settleAmount: settle_amt
        - domainEntity: DeliveryAddressEntity
          table: t_order_address
          pk: addr_id
          fieldMap:
            addrId: addr_id
            province: province
            city: city
            district: district
            streetDetail: street
            receiverName: receiver_name
            receiverPhone: receiver_phone
六、M4-scene.yaml（业务Saga场景编排，无修改）
sceneModel:
  globalConfig:
    engine: saga
    consistency: eventual
    maxRetry: 2

  sceneDefinitions:
    - sceneId: SCENE_CREATE_ORDER
      sceneName: 用户创建订单完整流程
      aggregateScope: [CustomerAggregate,ProductAggregate,OrderAggregate]
      permissionBind: [order_create]
      flowSteps:
        - stepType: readOnlyCheck
          bindAggregate: CustomerAggregate
        - stepType: bindCommand
          bindAggregate: OrderAggregate
          bindCommand: CreateOrder
        - stepType: return

    - sceneId: SCENE_MODIFY_ORDER_ADDR
      sceneName: 修改订单收货地址
      aggregateScope: [OrderAggregate]
      permissionBind: [order_modify_addr]
      flowSteps:
        - stepType: bindCommand
          bindAggregate: OrderAggregate
          bindCommand: ModifyOrderDeliveryAddress
        - stepType: return

    - sceneId: SCENE_CANCEL_ORDER
      sceneName: 取消订单、归还库存
      aggregateScope: [OrderAggregate,ProductAggregate]
      permissionBind: [order_cancel]
      flowSteps:
        - stepType: bindCommand
          bindAggregate: OrderAggregate
          bindCommand: CancelOrder
        - stepType: return
七、M5-security.yaml（权限脱敏安全模型，无修改）
securityModel:
  globalConfig:
    authMode: oauth2_jwt
    auditEnable: true

  principals:
    - principalId: normal_user
      desc: C端普通消费者
    - principalId: backend_admin
      desc: 后台运营管理员

  functionPermissions:
    - permId: order_create
      bindScene: SCENE_CREATE_ORDER
      allowPrincipals: [normal_user,backend_admin]
    - permId: order_modify_addr
      bindScene: SCENE_MODIFY_ORDER_ADDR
      allowPrincipals: [normal_user,backend_admin]
    - permId: order_cancel
      bindScene: SCENE_CANCEL_ORDER
      allowPrincipals: [normal_user,backend_admin]

  maskRules:
    contactPhone: "{first3}****{last4}"
    receiverPhone: "{first3}****{last4}"

  encryptRules:
    storageEncrypt: [contactPhone,receiverPhone]
八、M6-monitor.yaml（全链路监控告警，无修改）
monitorModel:
  globalConfig:
    traceEngine: skywalking
    metricExport: prometheus

  serviceMetricBind:
    - serviceName: customer-service
      metricItems: [qps,rt,error_count]
    - serviceName: product-service
      metricItems: [qps,rt,stock_deduct_fail]
    - serviceName: order-service
      metricItems: [qps,rt,create_fail,cancel_fail]

  alertRules:
    - desc: 订单创建失败率大于5%
      level: 严重告警
      trigger: order-service.create_fail / order-service.qps > 0.05
    - desc: 库存扣减失败突增
      level: 警告告警
      trigger: product-service.stock_deduct_fail > 10
九、M7-sla.yaml（流量管控SLA规范，无修改）
qualityModel:
  aggregateSla:
    CustomerAggregate:
      availability: 99.95
    ProductAggregate:
      availability: 99.95
    OrderAggregate:
      availability: 99.99
  commandSla:
    CreateOrder:
      RT: 300ms
    StockDeduct:
      RT: 100ms
  sceneSla:
    SCENE_CREATE_ORDER:
      endToEndRT: 600ms
      successRate: 99.9
  flowControl:
    globalLimitQps: 20000
    circuitBreaker:
      enable: true
      failureThreshold: 20
      waitDuration: 3000ms
十、MetaRule-business.yaml（前端后端统一动态规则引擎，无修改）
metaRuleModel:
  globalConfig:
    ruleEngine: aviator
    hotUpdate: true

  ruleGlobalParams:
    - paramId: single_order_max_amount
      name: 单笔订单最大限额
      dataType: decimal
      defaultValue: 50000
    - paramId: stock_warn_min
      name: 库存预警最低值
      dataType: int
      defaultValue: 20
    - paramId: vip_discount_limit
      name: VIP免风控金额阈值
      dataType: decimal
      defaultValue: 10000

  ruleGroups:
    - groupId: ORDER_RISK_RULE
      groupType: 下单风控校验
      bindScene: SCENE_CREATE_ORDER
      rules:
        - ruleId: R_ORDER_AMOUNT_LIMIT
          ruleVersion: 1.0
          ruleName: 大额订单拦截
          matchCondition: totalAmount > #{single_order_max_amount} && customerLevel != "VIP"
          effect: REJECT
          message: 普通用户单笔订单不可超过50000元，请拆分下单
        - ruleId: R_STOCK_LOW_WARN
          ruleVersion: 1.0
          ruleName: 低库存预警
          matchCondition: stockNum < #{stock_warn_min}
          effect: ALERT
          message: 商品库存低于预警值，请及时补货

    - groupId: ORDER_COMPENSATE_RULE
      groupType: 订单取消补偿逻辑
      bindScene: SCENE_CANCEL_ORDER
      rules:
        - ruleId: R_CANCEL_STOCK_RETURN
          ruleVersion: 1.0
          ruleName: 取消订单归还库存
          matchCondition: true
          effect: COMPENSATE
          message: 订单取消自动返还锁定商品库存
十一、M8-front-schema.yaml（新增核心：React可视化拖拽前端模板建模层）
# M8 React前端可视化拖拽页面模板建模层 v2.0
# 约束：所有组件字段强制绑定M1领域模型，不允许自定义字段；自动关联M4场景、M2命令、M5脱敏、MetaRule规则
frontModel:
  reactGlobalConfig:
    uiLib: antd
    dragEngineStorage: mysql8
    renderFramework: react18
    autoGenFormSubmit: true
    autoBindApiFromScene: true
    dragRolePermission: [backend_admin]
    desc: 拖拽编辑器仅管理员可见；普通用户仅渲染页面，不可编辑模板

  pageTemplates:
    # 模板1：单实体表单模板 - 客户录入
    - templateId: template_customer_single
      templateName: 客户单表单录入模板
      templateType: single_table_form
      renderMode: page_container
      bindSceneId: SCENE_CREATE_CUSTOMER
      masterAggregate: CustomerAggregate
      detailAggregates: []
      rootComponents:
        - compId: card_customer_base
          compType: card
          width: 100%
          span: 24
          fieldBind:
            bindAggregateId: CustomerAggregate
            bindSourceType: aggregate_root
            domainFieldName: customerId
            formLabel: 客户基础信息卡片
          childComponents:
            - compId: input_cust_name
              compType: input
              span: 12
              fieldBind:
                bindAggregateId: CustomerAggregate
                bindSourceType: aggregate_root
                domainFieldName: customerName
                formLabel: 客户名称
                required: true
            - compId: input_cust_phone
              compType: input
              span: 12
              fieldBind:
                bindAggregateId: CustomerAggregate
                bindSourceType: aggregate_root
                domainFieldName: contactPhone
                formLabel: 联系手机号
                required: true
                maskField: true
            - compId: select_cust_level
              compType: select
              span: 12
              fieldBind:
                bindAggregateId: CustomerAggregate
                bindSourceType: aggregate_root
                domainFieldName: customerLevel
                formLabel: 客户等级
                required: true
            - compId: date_register
              compType: date_picker
              span: 12
              fieldBind:
                bindAggregateId: CustomerAggregate
                bindSourceType: aggregate_root
                domainFieldName: registerTime
                formLabel: 注册时间

    # 模板2：主从表单模板 - 订单录入（聚合根+多子实体）
    - templateId: template_order_master_detail
      templateName: 订单主从录入模板
      templateType: master_detail_form
      renderMode: page_container
      bindSceneId: SCENE_CREATE_ORDER
      masterAggregate: OrderAggregate
      detailAggregates: [OrderItem,PaymentTerm,DeliveryAddressEntity]
      rootComponents:
        # 订单主信息卡片
        - compId: card_order_master
          compType: card
          width: 100%
          span: 24
          fieldBind:
            bindAggregateId: OrderAggregate
            bindSourceType: aggregate_root
            domainFieldName: orderId
            formLabel: 订单主信息
          childComponents:
            - compId: select_customer
              compType: select
              span: 12
              fieldBind:
                bindAggregateId: CustomerAggregate
                bindSourceType: aggregate_root
                domainFieldName: customerId
                formLabel: 客户
                required: true
            - compId: input_currency
              compType: input
              span: 12
              fieldBind:
                bindAggregateId: OrderAggregate
                bindSourceType: aggregate_root
                domainFieldName: totalCurrency
                formLabel: 结算币种
                required: true
            - compId: number_total_amt
              compType: number_input
              span: 12
              fieldBind:
                bindAggregateId: OrderAggregate
                bindSourceType: aggregate_root
                domainFieldName: totalAmount
                formLabel: 订单总金额
                required: true
            - compId: date_create
              compType: date_picker
              span: 12
              fieldBind:
                bindAggregateId: OrderAggregate
                bindSourceType: aggregate_root
                domainFieldName: createTime
                formLabel: 下单时间
        # 订单明细表格子实体
        - compId: table_order_item
          compType: table
          width: 100%
          span: 24
          fieldBind:
            bindAggregateId: OrderAggregate
            bindSourceType: aggregate_entity
            domainEntityName: OrderItem
            domainFieldName: itemId
            formLabel: 订单商品明细
          childComponents:
            - compId: select_product
              compType: select
              span: 6
              fieldBind:
                bindAggregateId: ProductAggregate
                bindSourceType: aggregate_root
                domainFieldName: productId
                formLabel: 商品
                required: true
            - compId: number_qty
              compType: number_input
              span: 6
              fieldBind:
                bindAggregateId: OrderAggregate
                bindSourceType: aggregate_entity
                domainEntityName: OrderItem
                domainFieldName: quantity
                formLabel: 购买数量
                required: true
            - compId: number_price
              compType: number_input
              span: 6
              fieldBind:
                bindAggregateId: OrderAggregate
                bindSourceType: aggregate_entity
                domainEntityName: OrderItem
                domainFieldName: itemPrice
                formLabel: 单品单价
            - compId: input_item_currency
              compType: input
              span: 6
              fieldBind:
                bindAggregateId: OrderAggregate
                bindSourceType: aggregate_entity
                domainEntityName: OrderItem
                domainFieldName: itemCurrency
                formLabel: 单品币种
        # 付款条件子实体卡片
        - compId: card_payment_term
          compType: card
          width: 100%
          span: 24
          fieldBind:
            bindAggregateId: OrderAggregate
            bindSourceType: aggregate_entity
            domainEntityName: PaymentTerm
            domainFieldName: termId
            formLabel: 付款条款
          childComponents:
            - compId: select_pay_type
              compType: select
              span: 12
              fieldBind:
                bindAggregateId: OrderAggregate
                bindSourceType: aggregate_entity
                domainEntityName: PaymentTerm
                domainFieldName: paymentType
                formLabel: 付款方式
            - compId: number_duedays
              compType: number_input
              span: 12
              fieldBind:
                bindAggregateId: OrderAggregate
                bindSourceType: aggregate_entity
                domainEntityName: PaymentTerm
                domainFieldName: dueDays
                formLabel: 账期天数
        # 收货地址子实体卡片
        - compId: card_delivery_addr
          compType: card
          width: 100%
          span: 24
          fieldBind:
            bindAggregateId: OrderAggregate
            bindSourceType: aggregate_entity
            domainEntityName: DeliveryAddressEntity
            domainFieldName: addrId
            formLabel: 收货地址
          childComponents:
            - compId: input_province
              compType: input
              span: 6
              fieldBind:
                bindAggregateId: OrderAggregate
                bindSourceType: aggregate_entity
                domainEntityName: DeliveryAddressEntity
                domainFieldName: province
                formLabel: 省份
            - compId: input_city
              compType: input
              span: 6
              fieldBind:
                bindAggregateId: OrderAggregate
                bindSourceType: aggregate_entity
                domainEntityName: DeliveryAddressEntity
                domainFieldName: city
                formLabel: 城市
            - compId: input_district
              compType: input
              span: 6
              fieldBind:
                bindAggregateId: OrderAggregate
                bindSourceType: aggregate_entity
                domainEntityName: DeliveryAddressEntity
                domainFieldName: district
                formLabel: 区县
            - compId: input_street
              compType: input
              span: 6
              fieldBind:
                bindAggregateId: OrderAggregate
                bindSourceType: aggregate_entity
                domainEntityName: DeliveryAddressEntity
                domainFieldName: streetDetail
                formLabel: 详细街道
            - compId: input_receiver
              compType: input
              span: 12
              fieldBind:
                bindAggregateId: OrderAggregate
                bindSourceType: aggregate_entity
                domainEntityName: DeliveryAddressEntity
                domainFieldName: receiverName
                formLabel: 收货人
            - compId: input_receiver_phone
              compType: input
              span: 12
              fieldBind:
                bindAggregateId: OrderAggregate
                bindSourceType: aggregate_entity
                domainEntityName: DeliveryAddressEntity
                domainFieldName: receiverPhone
                formLabel: 收货电话
                maskField: true

    # 模板3：空白自定义拖拽模板（全新业务场景使用）
    - templateId: template_custom_blank
      templateName: 空白自定义拖拽模板
      templateType: custom_drag_form
      renderMode: drawer
      bindSceneId: ""
      masterAggregate: null
      detailAggregates: []
      rootComponents: []
完整架构分层定位总总结

全套11层分层职责

1. M0-meta-schema：全域本体校验根规范，新增React前端模板JSON Schema约束，CI流水线校验所有YAML语法合法；统一前后端数据、组件、页面描述标准。

2. M1-domain：DDD领域聚合唯一数据源，前端所有拖拽组件强制绑定本层字段，禁止自定义字段，保证前后端数据口径完全统一。

3. M2-command：聚合操作命令入参定义，React页面提交时自动映射表单组件值至命令参数，无硬编码接口参数。

4. ME-event：EDA事件总线定义，页面提交完成后监听领域事件，自动刷新页面、弹窗反馈、触发异步补偿逻辑。

5. M3-deploy：服务与数据库映射，自动关联页面场景对应的后端HTTP接口地址，前端无硬编码URL。

6. M4-scene：Saga业务流程编排，M8页面模板绑定SceneId，一套模板对应完整端到端业务流程。

7. M5-security：权限、脱敏、数据加密规范；区分模板编辑管理员权限、页面访问权限、敏感字段掩码渲染规则，前端渲染引擎自动读取执行。

8. M6-monitor：全链路监控指标，前端页面加载、表单提交、接口异常自动埋点，匹配后端告警规则。

9. M7-sla：接口流量、熔断、超时规范，前端请求层统一复用SLA限流配置。

10. MetaRule-business：Aviator统一动态规则，前端渲染引擎实时执行，控制组件显隐、禁用、输入拦截、预警弹窗；后端执行持久化校验，规则仅维护一份。

11. M8-front-schema（新增）：React18+Ant Design可视化拖拽建模层，业务专家无代码操作；内置单表单/主从表单/空白模板三类模板；模板持久化MySQL；自动联动上游全部M层元数据；业务迭代仅修改模板yaml，无需修改React底层业务代码，满足后期专业人员独立维护模板的核心需求。

业务落地闭环流程

1. 架构工程师维护M0-M7、MetaRule底层元模型（一次性开发，极少变更）；

2. 业务建模/专业维护人员仅操作M8-front-schema模板：可视化拖拽绑定M1字段生成页面；

3. 模板绑定M4场景后，系统自动关联M2命令API、M5脱敏权限、MetaRule动态规则；

4. 前端React通用渲染引擎读取M8模板动态生成页面，无业务硬编码；

5. 业务需求变更：仅调整M8模板组件配置，无需发布前端JS/TS源码，支持配置中心热更新。
