This commit is contained in:
2024-07-11 19:52:47 +07:00
parent e3c69229ad
commit 56484b54c8
4 changed files with 62 additions and 19 deletions

View File

@ -17,7 +17,7 @@ namespace Yuna.Website.Server.API
app.MapDelete("/api/device/{id:long}", () => { })
.WithTags("device");
app.MapGet("/api/device/{id:long}", () => { })
app.MapGet("/api/device/{deviceId:long}", GetById)
.WithTags("device");
app.MapGet("/api/device", GetAll)
@ -58,6 +58,16 @@ namespace Yuna.Website.Server.API
return Results.Ok(result);
}
[Authorize]
public async Task<IResult> GetById(long deviceId,IDeviceService deviceService)
{
var result = await deviceService.GetById(deviceId);
if (result is null) return Results.NotFound(deviceId);
return Results.Ok(result);
}
[Authorize]
public async Task<IResult> GetAll(IDeviceService deviceService)
{