• 工作框架各种使用整理---服务状态变更数据


    1 <moqui.basic.StatusFlow statusFlowId="Zc3plDefault_Product" statusTypeId="Product" description="Default status flow for 3pl services across entire system."/>
    2     <moqui.basic.StatusFlowItem statusFlowId="Zc3plDefault_Product" statusId="ProductOpen" isInitial="Y"/>
    3     <moqui.basic.StatusFlowItem statusFlowId="Zc3plDefault_Product" statusId="ProductOnShelf"/>
    4     <moqui.basic.StatusFlowItem statusFlowId="Zc3plDefault_Product" statusId="ProductOffShelf"/>
    5     <moqui.basic.StatusFlowItem statusFlowId="Zc3plDefault_Product" statusId="ProductClosed"/>
    6     <moqui.basic.StatusFlowTransition statusFlowId="Zc3plDefault_Product" statusId="ProductOpen" toStatusId="ProductOnShelf" transitionName="Process"/>
    7     <moqui.basic.StatusFlowTransition statusFlowId="Zc3plDefault_Product" statusId="ProductOnShelf" toStatusId="ProductOffShelf" transitionName="Process"/>
    8     <moqui.basic.StatusFlowTransition statusFlowId="Zc3plDefault_Product" statusId="ProductOffShelf" toStatusId="ProductClosed" transitionName="Process"/>
     1 <service verb="update" noun="ProductStatus">
     2         <in-parameters>
     3             <parameter name="productId" required="true"/>
     4             <parameter name="statusId" required="true"/>
     5             <parameter name="placedDate" type="Timestamp"/>
     6         </in-parameters>
     7         <out-parameters><parameter name="oldStatusId"/><parameter name="statusChanged" type="Boolean"/></out-parameters>
     8         <actions>
     9             <entity-find entity-name="mantle.product.Product" list="productList">
    10                 <econdition field-name="productId" from="productId"/></entity-find>
    11             <set field="updateMap" from="[productId:productId, statusId:statusId]"/>
    12             <if condition="placedDate != null">
    13                 <script>updateMap.put('placedDate', placedDate)</script>
    14             </if>
    15             <service-call name="update#mantle.product.Product" out-map="context" in-map="updateMap"/>
    16         </actions>
    17     </service>
     1 <service verb="get" noun="ProductFieldChangeAuditLog">
     2         <in-parameters>
     3             <parameter name="productId"/>
     4             <parameter name="fieldName" default-value="statusId"/>
     5         </in-parameters>
     6         <out-parameters>
     7             <parameter name="auditLogList" type="List"><parameter name="auditLog" type="Map">
     8                 <parameter name="oldValueText"/><parameter name="newValueText"/><parameter name="changedDate"/><parameter name="changeByUserId"/>
     9             </parameter></parameter>
    10         </out-parameters>
    11         <actions>
    12             <!--TODO: do more authorization checking -->
    13 
    14             <entity-find entity-name="moqui.entity.EntityAuditLog" list="auditLogList">
    15                 <econdition-object field="[changedEntityName:'mantle.product.Product', changedFieldName:fieldName, pkPrimaryValue:productId]"/>
    16                 <select-field field-name="oldValueText"/>
    17                 <select-field field-name="newValueText"/>
    18                 <select-field field-name="changedDate"/>
    19                 <select-field field-name="changedByUserId"/>
    20             </entity-find>
    21         </actions>
    22     </service>

    以上即为服务状态变更以及变更状态记录查询的方法。

    在Moqui中如果要使用AutidLog来记录首先要将enable_audit_log=true

    1 <?xml version="1.0" encoding="UTF-8"?>
    2 <entities xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    3           xsi:noNamespaceSchemaLocation="http://moqui.org/xsd/entity-definition-2.0.xsd">
    4     <extend-entity entity-name="Product" package="mantle.product">
    5         <field name="statusId" type="id" enable-audit-log="true"/>
    6     </extend-entity>
    7 </entities>

    update模式用于传递所有的主键或自己期望的非主键字段。如果实体有一个statusID字段并且传入的statusId和字段值不同,那么服务会自动返回原始值放在oldStatusId出参中,无论何时实体有一个statusId字段,服务都还将返回一个boolean类型的statusChanged参数,如果状态和数据库的原始值不一样那么该字段为true反之为false,实体自动服务会通过检查匹配的moqui.basic.StatusFlowTransition存在记录,去执行有效的状态变化。如果没有有效的状态变化,那么服务将返回一个错误。

  • 相关阅读:
    Getting Started with MongoDB (MongoDB Shell Edition)
    Ioc
    BsonDocument
    Find or Query Data with C# Driver
    Insert Data with C# Driver
    Connect to MongoDB
    What's the difference between returning void and returning a Task?
    Import Example Dataset
    jQuery来源学习笔记:整体结构
    Word文件交换的电脑打开字体、排版变化的原因和解决方法!
  • 原文地址:https://www.cnblogs.com/dream-to-pku/p/5695529.html
Copyright © 2020-2023  润新知