ASY-API/API设计文档.md
2025-08-29 21:01:13 +08:00

4.9 KiB

API 设计文档


Product API

POST /api/v1/product/create Creates new product with name,price,stock
Parameters
name type data type description
name required string Product name
price required number Product price
stock required number Number of products in stock
Responses
http code content-type response
201 application/json {"code":"201", "name":"name", "message":"Product created"}
409 application/json {"code":"409","message":"Product with the same name alread exists"}
PUT /api/v1/product/update Update the product name and/or price
Parameters
name type data type description
name required string Product name
price optional number New product price
stock optional number Updated product stock
Responses
http code content-type response
200 application/json {"code":"200", "name":"name", "message":"Product updated"}
404 application/json {"code":"404","message":"Product not found"}
GET /api/v1/product/{name} Get product
Responses
http code content-type response
200 application/json {"code":"200", "product": {"name","price","stock"}, "message":"Product retrieved"}
404 application/json {"code":"404","message":"Product not found"}
GET /api/v1/products Get all the products
Responses
http code content-type response
200 application/json {"code":"200", "products": Array of <product object>, "message":"Products retrieved"}
DELETE /api/v1/product/{name} Delete a product
Responses
http code content-type response
200 application/json {"code":"200", "name":"name", "message":"Product deleted"}
404 application/json {"code":"404","message":"Product not found"}
DELETE /api/v1/products Delete all products
Responses
http code content-type response
200 application/json {"code":"200", "message":"All products deleted"}

Java 实现