Files
tecamino-dbm/dbm/get.go
Adrian Zuercher 48d05eec7e repo name change
2025-08-07 12:18:57 +02:00

41 lines
857 B
Go

package dbm
import (
json_data "gitea.tecamino.com/paadi/tecamino-json_data"
json_dataModels "gitea.tecamino.com/paadi/tecamino-json_data/models"
)
func (d *DBMHandler) Get(req *json_dataModels.Request, id string) {
if req == nil {
return
} else if len(req.Get) == 0 {
return
}
d.RLock()
defer d.RUnlock()
resp := json_data.NewResponse()
resp.Id = req.Id
for _, get := range req.Get {
var depth uint = 1
if get.Query != nil {
depth = get.Query.Depth
}
for _, dp := range d.DBM.QueryDatapoints(depth, get.Uuid, get.Path) {
resp.AddGet(json_dataModels.Get{
Uuid: dp.Uuid,
Path: dp.Path,
Type: dp.Type,
Value: dp.Value,
HasChild: dp.Datapoints != nil,
Rights: dp.ReadWrite,
})
}
}
if err := d.Conns.SendResponse(id, resp); err != nil {
d.Log.Error("get.Get", err.Error())
}
}