58 lines
1.7 KiB
C#
58 lines
1.7 KiB
C#
using StopShopping.Services;
|
|
using StopShopping.Services.Models.Req;
|
|
using StopShopping.Services.Models.Resp;
|
|
|
|
namespace StopShopping.Api.Routes;
|
|
|
|
public static class Request
|
|
{
|
|
public static RouteGroupBuilder MapRequest(this RouteGroupBuilder routes)
|
|
{
|
|
routes.MapPost("/request/publish", PublishRequestAsync)
|
|
.WithTags(OpenApiTags.需求.ToString());
|
|
|
|
routes.MapGet("/request/search", SearchAsync)
|
|
.WithTags(OpenApiTags.需求.ToString())
|
|
.AllowAnonymous();
|
|
|
|
routes.MapGet("/request/orders", OrderSearchAsync)
|
|
.WithTags(OpenApiTags.需求.ToString());
|
|
|
|
routes.MapPost("/request/delete", DeleteRequestAsync)
|
|
.WithTags(OpenApiTags.需求.ToString());
|
|
|
|
return routes;
|
|
}
|
|
|
|
private static async Task<ApiResponse> PublishRequestAsync(
|
|
CreateRequestParams model,
|
|
IRequestService requestService)
|
|
{
|
|
return await requestService.PublishRequestAsync(model);
|
|
}
|
|
|
|
private static async Task<ApiResponse<PagedResult<Services.Models.Resp.Request>>> SearchAsync(
|
|
[AsParameters] RequestSearchParams model,
|
|
IRequestService requestService
|
|
)
|
|
{
|
|
return await requestService.SearchAsync(model);
|
|
}
|
|
|
|
private static async Task<ApiResponse<PagedResult<Services.Models.Resp.Request>>> OrderSearchAsync(
|
|
[AsParameters] RequestSearchWithStatusParams model,
|
|
IRequestService requestService
|
|
)
|
|
{
|
|
return await requestService.RequestOrderSearchAsync(model);
|
|
}
|
|
|
|
private static async Task<ApiResponse> DeleteRequestAsync(
|
|
RequestIdParams model,
|
|
IRequestService requestService
|
|
)
|
|
{
|
|
return await requestService.DeleteRequestAsync(model);
|
|
}
|
|
}
|