40 lines
801 B
Go
40 lines
801 B
Go
package dbm
|
|
|
|
import (
|
|
json_data "github.com/tecamino/tecamino-json_data"
|
|
json_dataModels "github.com/tecamino/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,
|
|
Rights: dp.ReadWrite,
|
|
})
|
|
}
|
|
}
|
|
|
|
if err := d.Conns.SendResponse(id, resp); err != nil {
|
|
d.Log.Error("get.Get", err.Error())
|
|
}
|
|
}
|