delivery api
1.0.0
欢迎来到送货API!此API是用于管理应用程序中产品和销售的解决方案。它以.NET为基础,为创建和管理产品和处理销售交易提供了一个宁静的接口。本文档概述了交付API端点,包括详细的描述,请求参数和响应格式。 API包括用于健康检查,管理产品和处理销售的端点。
克隆存储库:
git clone https://github.com/anthonyvii27/delivery-api更改为存储库目录:
cd delivery-api运行命令以启动容器化环境:
make compose-up-v2 API将在计算机上的端口:8080上运行。
可选地,在此存储库的根部,有一个名为delivery-api.http的文件,该文件提供了一个易于使用的接口,用于执行已实现的端点。
GET /health摘要:检查API的健康状况。
回答:
200好
" Database connection is healthy. "503服务不可用
" Database connection isn't available. "500内部服务器错误
" An error occurred while checking the database connection. "GET /products摘要:检索所有产品。
回答:
[
{
"id" : 1 ,
"name" : " Product Name " ,
"unitOfMeasurement" : " UN " ,
"price" : 9.99
}
]GET /products/{id}摘要:通过其ID检索产品。
参数:
id (整数):要检索的产品ID。回答:
200好
{
"id" : 1 ,
"name" : " Product Name " ,
"unitOfMeasurement" : " UN " ,
"price" : 9.99
}404找不到
{
"message" : " Product with ID {id} not found. "
}POST /products摘要:创建一个新产品。
请求主体:
{
"name" : " Product Name " ,
"unitOfMeasurement" : " Unit " ,
"price" : 9.99
}回答:
201创建
{
"id" : 1 ,
"name" : " Product Name " ,
"unitOfMeasurement" : " Unit " ,
"price" : 9.99
}400不良要求
{
"message" : " Validation error messages "
}PUT /products/{id}摘要:更新现有产品。
参数:
id (整数):要更新产品的ID。请求主体:
{
"name" : " Updated Product Name " ,
"unitOfMeasurement" : " Updated Unit " ,
"price" : 9.99
}回答:
200好
{
"id" : 1 ,
"name" : " Updated Product Name " ,
"unitOfMeasurement" : " Updated Unit " ,
"price" : 9.99
}400不良要求
{
"message" : " Validation error messages "
}404找不到
{
"message" : " Product with ID {id} not found. "
}DELETE /products/{id}摘要:通过其ID删除产品。
参数:
id (整数):要删除产品的ID。回答:
204没有内容
400不良要求
{
"message" : " Error message "
}404找不到
{
"message" : " Product with ID {id} not found. "
}409冲突
{
"message" : " Cannot delete the product as it has associated sale items. "
}GET /sales摘要:检索所有销售(历史)。
回答:
[
{
"id" : 1 ,
"saleDate" : " 2024-08-14T00:00:00Z " ,
"totalAmount" : 100.00 ,
"saleItems" : [
{
"id" : 1 ,
"productId" : 1 ,
"quantity" : 2 ,
"unitPrice" : 50.00
}
]
}
]GET /sales/{id}摘要:通过ID检索销售。
参数:
id (整数):检索出售的ID。回答:
200好
{
"id" : 1 ,
"saleDate" : " 2024-08-14T00:00:00Z " ,
"totalAmount" : 100.00 ,
"saleItems" : [
{
"id" : 1 ,
"productId" : 1 ,
"quantity" : 2 ,
"unitPrice" : 50.00
}
]
}404找不到
{
"message" : " Sale with ID {id} not found. "
}POST /sales摘要:创建新的销售。
请求主体:
{
"saleDate" : " 2024-08-14T00:00:00Z " ,
"zipCode" : " 12345678 " ,
"saleItems" : [
{
"productId" : 1 ,
"quantity" : 2
}
]
}回答:
201创建
{
"id" : 1 ,
"saleDate" : " 2024-08-14T00:00:00Z " ,
"totalAmount" : 100.00 ,
"saleItems" : [
{
"id" : 1 ,
"productId" : 1 ,
"quantity" : 2 ,
"unitPrice" : 50.00 ,
"product" : {
"id" : 1 ,
"name" : " Product Name " ,
"unitOfMeasurement" : " Unit " ,
"price" : 50.00
}
}
]
}400不良要求
{
"message" : " Validation error messages "
}DELETE /sales/{id}摘要:删除(取消)通过其ID销售。
参数:
id (整数):删除销售的ID。回答:
204没有内容
400不良要求
{
"message" : " Error message "
}404找不到
{
"message" : " Sale with ID {id} not found. "
}