This is too simple. Where is the process?
In the above example, we see the order CRUD operation, but this is not the real situation in real life, the entire order lifecycle is shown in:
To achieve this process, we can take two steps: Step 1: model the order resources, and Step 2: Manage the lifecycle of the order process through the workflow.
A workflow is responsible for managing the lifecycle of an order. At different stages of its lifecycle, we have different participants who have different operation permissions on the order. Our system architecture has evolved into the following:
Let's look at the example. This time, we will move our perspective to the box network to see how the box handles the orders we have submitted. We use GET: http://api.kuangkuang.com/orders? Status = waiting-review:
Xml Code
<Orders>
<Link rel = "list" media-type = "application/xml" url = "http://api.kuangkuang.com/orders"/>
<Order>
<Id> 1000 </id>
<State> waiting review </state>
<Link rel = "detail" media-type = "application/xml" url = "http://api.kuangkuang.com/order/1000"/>
</Order>
</Orders>
<Orders>
<Link rel = "list" media-type = "application/xml" url = "http://api.kuangkuang.com/orders"/>
<Order>
<Id> 1000 </id>
<State> waiting review </state>
<Link rel = "detail" media-type = "application/xml" url = "http://api.kuangkuang.com/order/1000"/>
</Order>
</Orders>
Let's check the specific order information. Let's GET: http://api.kuangkuang.com/order/1000. the server returns the following data:
Xml Code
<Order>
<Link rel = "detail" media-type = "application/xml" url = "http://api.kuangkuang.com/order/1000"/>
<Content>
<Id> 1000 </id>
<Cost> 88.0 </cost>
<State> waiting review </state>
<Squence>
<Activity rel = "review" media-type = "application/xml" url = "http://api.kuangkuang.com/review/order/1000"/>
</Squence>
</Content>
</Order>
<Order>
<Link rel = "detail" media-type = "application/xml" url = "http://api.kuangkuang.com/order/1000"/>
<Content>
<Id> 1000 </id>
<Cost> 88.0 </cost>
<State> waiting review </state>
<Squence>
<Activity rel = "review" media-type = "application/xml" url = "http://api.kuangkuang.com/review/order/1000"/>
</Squence>
</Content>
</Order>
Note these two rows:
Java code
<State> waiting review </state>
<Squence>
<Activity rel = "review" media-type = "application/xml" url = "http://api.kuangkuang.com/review/order/1000"/>
</Squence>
<State> waiting review </state>
<Squence>
<Activity rel = "review" media-type = "application/xml" url = "http://api.kuangkuang.com/review/order/1000"/>
</Squence>
This information is added by the workflow, which tells us that the status of the current order is pending for review and that we need to review the next step. Then, let's PUT http://api.kuangkuang.com/review/order/100020.the server has passed the review and the server returns the data:
Xml Code
<Order>
<Link rel = "detail" media-type = "application/xml" url = "http://api.kuangkuang.com/order/1000"/>
<Content>
<Id> 1000 </id>
<Cost> 88.0 </cost>
<State> waiting send </state>
<Squence>
<Activity rel = "send" media-type = "application/xml" url = "http://api.kuangkuang.com/sent/order/1000"/>
</Squence>
</Content>
</Order>
<Order>
<Link rel = "detail" media-type = "application/xml" url = "http://api.kuangkuang.com/order/1000"/>
<Content>
<Id> 1000 </id>
<Cost> 88.0 </cost>
<State> waiting send </state>
<Squence>
<Activity rel = "send" media-type = "application/xml" url = "http://api.kuangkuang.com/sent/order/1000"/>
</Squence>
</Content>
</Order>
Similarly, the workflow adds the following two rows of data:
Xml Code
<State> waiting send </state>
<Squence>
<Activity rel = "send" media-type = "application/xml" url = "http://api.kuangkuang.com/sent/order/1000"/>
</Squence>
<State> waiting send </state>
<Squence>
<Activity rel = "send" media-type = "application/xml" url = "http://api.kuangkuang.com/sent/order/1000"/>
</Squence>
The status of the current order is waiting for delivery, and the next step is to complete this step. In this case, if the customer checks the number of his/her orders