简体   繁体   English

批量创建/更新 API 客户端不知道创建或更新

[英]Bulk Create/Update API where client is unaware of create or update

Use Case: User receives CSV file from Supplier about the inventory which needs to be fed into the user's e-commerce website/backend.用例:用户从供应商处收到关于库存的 CSV 文件,需要将其输入用户的电子商务网站/后端。 The CSV could contain inventory items that were previously uploaded. CSV 可能包含之前上传的库存项目。 CSV contains the item attributes sent by the Supplier and does not contain the item-id which is specific to the e-commerce backend system. CSV包含Supplier发送的item属性,不包含电商后台系统特有的item-id。

This is a case where the backend system goes through each item in the CSV, decides if it is a Create case or Update case (based on 5 attributes of the item), and makes the changes accordingly.这是后端系统遍历 CSV 中的每个项目的案例,决定它是创建案例还是更新案例(基于项目的 5 个属性),并进行相应的更改。

How do we design a RESTful API for each use case?我们如何为每个用例设计一个 RESTful API?

This sounds like an "import".这听起来像是“进口”。

I'd make a single API method called "Import Inventory" (eg, POST /inventory:import ) where the CSV is provided as input and the result is a summary of what items were created/updated.我会制作一个名为“导入库存”(例如POST /inventory:import )的单个 API 方法,其中 CSV 作为输入提供,结果是创建/更新的项目的摘要。

Some references worth looking at:一些值得一看的参考资料:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM