38 lines
736 B
Go
38 lines
736 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(gets []json_dataModels.Get, id, id2 string) {
|
|
if gets == nil {
|
|
return
|
|
}
|
|
d.RLock()
|
|
defer d.RUnlock()
|
|
|
|
r := json_data.NewResponse()
|
|
r.Id = id2
|
|
for _, get := range gets {
|
|
var depth uint = 1
|
|
if get.Query != nil {
|
|
depth = get.Query.Depth
|
|
}
|
|
|
|
for _, dp := range d.DB.QueryDatapoints(depth, get.Path) {
|
|
r.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, r); err != nil {
|
|
d.Log.Error("get.Get", err.Error())
|
|
}
|
|
}
|