70 lines
1.9 KiB
C#
70 lines
1.9 KiB
C#
using StopShopping.Services;
|
|
using StopShopping.Services.Models.Req;
|
|
using StopShopping.Services.Models.Resp;
|
|
|
|
namespace StopShopping.Api.Routes;
|
|
|
|
/// <summary>
|
|
/// 商品相关路由
|
|
/// </summary>
|
|
public static class Product
|
|
{
|
|
public static RouteGroupBuilder MapProduct(this RouteGroupBuilder routes)
|
|
{
|
|
routes.MapGet("/product/list", SearchProductsAsync)
|
|
.WithTags(OpenApiTags.商品.ToString());
|
|
|
|
routes.MapGet("/product/detail", Detail)
|
|
.WithTags(OpenApiTags.商品.ToString());
|
|
|
|
routes.MapPost("/product/edit", EditAsync)
|
|
.WithTags(OpenApiTags.商品.ToString());
|
|
|
|
routes.MapPost("/product/delete", DeleteAsync)
|
|
.WithTags(OpenApiTags.商品.ToString());
|
|
|
|
return routes;
|
|
}
|
|
|
|
public static RouteGroupBuilder MapProductAnonymous(this RouteGroupBuilder routes)
|
|
{
|
|
routes.MapGet("/product/search", SearchProductsAsync)
|
|
.WithTags(OpenApiTags.商品.ToString());
|
|
|
|
return routes;
|
|
}
|
|
|
|
private static async
|
|
Task<ApiResponse<PagedResult<Services.Models.Resp.Product>>>
|
|
SearchProductsAsync(
|
|
[AsParameters] ProductSearchParms model,
|
|
IProductService productService
|
|
)
|
|
{
|
|
return await productService.SearchAsync(model);
|
|
}
|
|
|
|
private static ApiResponse<ProductInfo> Detail(
|
|
[AsParameters] ProductIdParams model,
|
|
IProductService productService)
|
|
{
|
|
return productService.Detail(model);
|
|
}
|
|
|
|
private static async Task<ApiResponse> EditAsync(
|
|
EditProductParams model,
|
|
IProductService productService
|
|
)
|
|
{
|
|
return await productService.EditAsync(model);
|
|
}
|
|
|
|
private static async Task<ApiResponse> DeleteAsync(
|
|
ProductIdParams model,
|
|
IProductService productService
|
|
)
|
|
{
|
|
return await productService.DeleteAsync(model);
|
|
}
|
|
}
|