device client implemented
This commit is contained in:
@ -23,6 +23,11 @@ namespace Yuna.Website.Server.API
|
||||
app.MapGet("/api/device", GetAll)
|
||||
.WithTags("device");
|
||||
|
||||
app.MapGet("/api/device/{deviceId:long}/fetch", FetchData)
|
||||
.WithTags("device")
|
||||
.Produces<string>(404)
|
||||
.Produces(200);
|
||||
|
||||
app.MapPut("/api/device/{deviceId:long}", AddSkillsToDevice)
|
||||
.WithTags("device");
|
||||
}
|
||||
@ -93,5 +98,18 @@ namespace Yuna.Website.Server.API
|
||||
if (result is null) return Results.NotFound("device");
|
||||
return Results.Ok(result);
|
||||
}
|
||||
|
||||
[Authorize]
|
||||
public async Task<IResult> FetchData(long deviceId, IDeviceService deviceService)
|
||||
{
|
||||
var device = await deviceService.GetById(deviceId);
|
||||
if (device is null) return Results.NotFound("device");
|
||||
|
||||
|
||||
var result = await deviceService.FetchPropsData(device);
|
||||
if (result is null) return Results.NotFound("props");
|
||||
|
||||
return Results.Ok(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,8 @@ namespace Yuna.Website.Server.API
|
||||
{
|
||||
JsonValueName = request.JsonValueName,
|
||||
MeasureName = request.MeasureName ?? "",
|
||||
Name = request.Name
|
||||
Name = request.Name,
|
||||
Type = request.type.Equals("float") ? PropType.Float : PropType.Boolean
|
||||
};
|
||||
|
||||
var result = await skillService.Create(prop);
|
||||
|
Reference in New Issue
Block a user