detect/detect.gui/Api/System/DetectTaskApi.cs

37 lines
1.4 KiB
C#
Raw Normal View History

2024-11-13 17:09:15 +08:00
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)
{
2024-11-14 17:11:43 +08:00
// all
webApp?.MapGet("/v1/system/task/all", () => Locator.Current.GetService<DetectTaskService>()!.ListAll());
// search
webApp?.MapGet("/v1/system/task/search", ([FromQuery] string? name, [FromQuery]int pageNum = 1, [FromQuery]int pageSize = 10) =>
Locator.Current.GetService<DetectTaskService>()!.Search(name, pageNum, pageSize));
// id
webApp?.MapGet("/v1/system/task/{id:long}", ([FromRoute] long id) =>
Locator.Current.GetService<DetectTaskService>()!.ListById(id));
// add
webApp?.MapPost("/v1/system/task/", ([FromBody] DetectTaskEntity entity) =>
Locator.Current.GetService<DetectTaskService>()!.AddData(entity));
// update
webApp?.MapPut("/v1/system/task/", ([FromBody] DetectTaskEntity entity) =>
Locator.Current.GetService<DetectTaskService>()!.UpdateData(entity));
// delete
webApp?.MapDelete("/v1/system/task/{id:long}", ([FromRoute] long id) =>
Locator.Current.GetService<DetectTaskService>()!.DeleteById(id));
2024-11-13 17:09:15 +08:00
}
}