mirror of
http://git.xinwangdao.com/cnnc-embedded-parts-detect/detect.git
synced 2025-06-24 13:34:13 +08:00
41 lines
1.7 KiB
C#
41 lines
1.7 KiB
C#
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 AuthorityApi
|
|
{
|
|
public AuthorityApi(IEndpointRouteBuilder? webApp)
|
|
{
|
|
// all
|
|
webApp?.MapGet("/v1/system/authority/all", () => Locator.Current.GetService<DetectAuthorityService>()!.ListAll());
|
|
|
|
// search
|
|
webApp?.MapGet("/v1/system/authority/search", ([FromQuery] int? id, [FromQuery] string? name = "", [FromQuery]int pageNum = 1, [FromQuery]int pageSize = 10) =>
|
|
Locator.Current.GetService<DetectAuthorityService>()!.Search(id, name, pageNum, pageSize));
|
|
|
|
// one
|
|
webApp?.MapGet("/v1/system/authority/one", ([FromQuery] int? id, [FromQuery] string? name = "") =>
|
|
Locator.Current.GetService<DetectAuthorityService>()!.ListOne(id, name));
|
|
|
|
// id
|
|
webApp?.MapGet("/v1/system/authority/{id:long}", ([FromRoute] long id) =>
|
|
Locator.Current.GetService<DetectAuthorityService>()!.ListById(id));
|
|
|
|
// add
|
|
webApp?.MapPost("/v1/system/authority/", ([FromBody] AuthorityEntity entity) =>
|
|
Locator.Current.GetService<DetectAuthorityService>()!.AddData(entity));
|
|
|
|
// update
|
|
webApp?.MapPut("/v1/system/authority/", ([FromBody] AuthorityEntity entity) =>
|
|
Locator.Current.GetService<DetectAuthorityService>()!.UpdateData(entity));
|
|
|
|
// delete
|
|
webApp?.MapDelete("/v1/system/authority/{id:long}", ([FromRoute] long id) =>
|
|
Locator.Current.GetService<DetectAuthorityService>()!.DeleteById(id));
|
|
}
|
|
} |