55 lines
1.6 KiB
C#
55 lines
1.6 KiB
C#
using StopShopping.Services;
|
|
using StopShopping.Services.Models.Req;
|
|
using StopShopping.Services.Models.Resp;
|
|
|
|
namespace StopShopping.AdminApi.Routes;
|
|
|
|
public static class Category
|
|
{
|
|
public static RouteGroupBuilder MapCategory(this RouteGroupBuilder routes)
|
|
{
|
|
routes.MapGet("/category/list", GetTree)
|
|
.WithTags(OpenApiTags.分类.ToString());
|
|
|
|
routes.MapPost("/category/edit", EditCategoryAsync)
|
|
.WithTags(OpenApiTags.分类.ToString());
|
|
|
|
routes.MapPost("/category/resort", ResortCategoryAsync)
|
|
.WithTags(OpenApiTags.分类.ToString());
|
|
|
|
routes.MapPost("/category/delete", DeleteCategoryAsync)
|
|
.WithTags(OpenApiTags.分类.ToString());
|
|
|
|
return routes;
|
|
}
|
|
|
|
private static ApiResponse<List<Services.Models.Resp.Category>> GetTree(
|
|
ICategoryService categoryService
|
|
)
|
|
{
|
|
return categoryService.GetCategoriesTree();
|
|
}
|
|
|
|
private static async Task<ApiResponse<Services.Models.Resp.Category>> EditCategoryAsync(
|
|
EditCategoryParams model,
|
|
ICategoryService categoryService)
|
|
{
|
|
return await categoryService.EditCategoryAsync(model);
|
|
}
|
|
|
|
private static async Task<ApiResponse> ResortCategoryAsync(
|
|
ResortCategoryParams model,
|
|
ICategoryService categoryService)
|
|
{
|
|
return await categoryService.ResortCategoryAsync(model);
|
|
}
|
|
|
|
private static async Task<ApiResponse> DeleteCategoryAsync(
|
|
CategoryIdParams model,
|
|
ICategoryService categoryService
|
|
)
|
|
{
|
|
return await categoryService.DeleteCategoryAsync(model);
|
|
}
|
|
}
|