【发布时间】:2017-08-02 19:37:47
【问题描述】:
我们的客户 API 采用 {customer-name, customer-mobile, customer-email} 并在数据库中创建客户。
我们还有接受 {productId, customer-name, customer-mobile, customer-email} 的订单 API。
订单API代码:
- 首先根据订单 API 中传递的 {name,mobile,email} 创建客户并返回 customerId。
- {productId, customerId} 进一步保存在数据库的订单表中。
一个 API 在内部首先创建一些其他资源是一种平静的做法吗?
请注意,这是一个过于简化的示例,其中 API 要求订单 API 中只有一种类型的产品。
【问题讨论】:
标签: rest api restful-architecture