add new parameter hasChild and set with connection id

This commit is contained in:
Adrian Zürcher
2025-05-28 22:04:40 +02:00
parent 60b3f77e29
commit c57c22f93a
5 changed files with 62 additions and 27 deletions

View File

@@ -20,29 +20,29 @@ func (d *DBMHandler) Json_Data(c *gin.Context) {
return
}
respond := json_dataModels.NewResponse()
resp := json_dataModels.NewResponse()
if payload.Get != nil {
if len(payload.Get) > 0 {
var depth uint = 1
for _, get := range payload.Get {
if get.Query != nil {
depth = get.Query.Depth
}
for _, res := range d.DBM.QueryDatapoints(depth, get.Uuid, get.Path) {
respond.AddGet(json_dataModels.Get{
Uuid: res.Uuid,
Path: res.Path,
Type: res.Type,
Value: res.Value,
Rights: res.ReadWrite,
Drivers: &res.Drivers,
resp.AddGet(json_dataModels.Get{
Uuid: res.Uuid,
Path: res.Path,
Type: res.Type,
Value: res.Value,
HasChild: res.Datapoints != nil,
Rights: res.ReadWrite,
})
}
}
}
if payload.Set != nil {
respond.Set, err = d.DBM.CreateDatapoints(payload.Set...)
if len(payload.Set) > 0 {
resp.Set, err = d.DBM.CreateDatapoints(payload.Set...)
if err != nil {
r := json_data.NewResponse()
r.SetError()
@@ -52,7 +52,7 @@ func (d *DBMHandler) Json_Data(c *gin.Context) {
}
}
c.JSON(200, respond)
c.JSON(200, resp)
}
func (d *DBMHandler) Delete(c *gin.Context) {