2024-11-14 17:11:43 +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 DetectTaskLogApi
|
|
|
|
|
{
|
|
|
|
|
public DetectTaskLogApi(IEndpointRouteBuilder? webApp)
|
|
|
|
|
{
|
|
|
|
|
// all
|
2024-11-15 17:46:05 +08:00
|
|
|
|
webApp?.MapGet("/v1/data/task-log/all", () => Locator.Current.GetService<DetectTaskLogService>()!.ListAll());
|
2024-11-14 17:11:43 +08:00
|
|
|
|
|
|
|
|
|
// search
|
2024-11-15 17:46:05 +08:00
|
|
|
|
webApp?.MapGet("/v1/data/task-log/search", ([FromQuery] long? taskId, [FromQuery]int pageNum = 1, [FromQuery]int pageSize = 10) =>
|
2024-11-14 17:11:43 +08:00
|
|
|
|
Locator.Current.GetService<DetectTaskLogService>()!.Search(taskId, pageNum, pageSize));
|
|
|
|
|
|
|
|
|
|
// id
|
2024-11-15 17:46:05 +08:00
|
|
|
|
webApp?.MapGet("/v1/data/task-log/{id:long}", ([FromRoute] long id) =>
|
2024-11-14 17:11:43 +08:00
|
|
|
|
Locator.Current.GetService<DetectTaskLogService>()!.ListById(id));
|
|
|
|
|
|
|
|
|
|
// add
|
2024-11-15 17:46:05 +08:00
|
|
|
|
webApp?.MapPost("/v1/data/task-log/", ([FromBody] DetectTaskLogEntity entity) =>
|
2024-11-14 17:11:43 +08:00
|
|
|
|
Locator.Current.GetService<DetectTaskLogService>()!.AddData(entity));
|
|
|
|
|
|
|
|
|
|
// update
|
2024-11-15 17:46:05 +08:00
|
|
|
|
webApp?.MapPut("/v1/data/task-log/", ([FromBody] DetectTaskLogEntity entity) =>
|
2024-11-14 17:11:43 +08:00
|
|
|
|
Locator.Current.GetService<DetectTaskLogService>()!.UpdateData(entity));
|
|
|
|
|
|
|
|
|
|
// delete
|
2024-11-15 17:46:05 +08:00
|
|
|
|
webApp?.MapDelete("/v1/data/task-log/{id:long}", ([FromRoute] long id) =>
|
2024-11-14 17:11:43 +08:00
|
|
|
|
Locator.Current.GetService<DetectTaskLogService>()!.DeleteById(id));
|
|
|
|
|
}
|
|
|
|
|
}
|