using detect.gui.Models.Entities; using detect.gui.Services.Detect; using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Routing; using Splat; namespace detect.gui.Api.System; public class DetectTaskApi { public DetectTaskApi(IEndpointRouteBuilder? webApp) { // all webApp?.MapGet("/v1/data/task/all", () => Locator.Current.GetService()!.ListAll()); // search webApp?.MapGet("/v1/data/task/search", ([FromQuery] string? name, [FromQuery]int pageNum = 1, [FromQuery]int pageSize = 10) => Locator.Current.GetService()!.Search(name, pageNum, pageSize)); // id webApp?.MapGet("/v1/data/task/{id:long}", ([FromRoute] long id) => Locator.Current.GetService()!.ListById(id)); // add webApp?.MapPost("/v1/data/task/", ([FromBody] DetectTaskEntity entity) => Locator.Current.GetService()!.AddData(entity)); // update webApp?.MapPut("/v1/data/task/", ([FromBody] DetectTaskEntity entity) => Locator.Current.GetService()!.UpdateData(entity)); // delete webApp?.MapDelete("/v1/data/task/{id:long}", ([FromRoute] long id) => Locator.Current.GetService()!.DeleteById(id)); } }