66 lines
1.6 KiB
Go
66 lines
1.6 KiB
Go
package sensorItemMapping
|
|
|
|
import (
|
|
"encoding/json"
|
|
"git.loafle.net/overflow/commons_go/model/timestamp"
|
|
"git.loafle.net/overflow/overflow_proxy_service/proxy/sensor"
|
|
"git.loafle.net/overflow/overflow_proxy_service/proxy/sensorItem"
|
|
"git.loafle.net/overflow/overflow_proxy_service/proxy/utils"
|
|
)
|
|
|
|
type SensorItemMapping struct {
|
|
Id json.Number `json:"id,Number,omitempty"`
|
|
Sensor sensor.Sensor `json:"sensor,omitempty"`
|
|
SensorItem sensorItem.SensorItem `json:"sensorItem,omitempty"`
|
|
CreateDate timestamp.Timestamp `json:"createDate,omitempty"`
|
|
}
|
|
|
|
type SensorItemMappingService struct {
|
|
}
|
|
|
|
func NewSensorItemMappingService() *SensorItemMappingService {
|
|
return &SensorItemMappingService{}
|
|
}
|
|
|
|
func (sims *SensorItemMappingService) Create(sim *SensorItemMapping) (string, error) {
|
|
out, err := utils.InvokeDBByModel("sensorItemMapping", "create", sim, "com.loafle.overflow.sensor.model.SensorItemMapping")
|
|
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
return out, nil
|
|
}
|
|
|
|
func (sims *SensorItemMappingService) CreateAll(siml *[]*SensorItemMapping) (string, error) {
|
|
|
|
outlist := make([]string, 0)
|
|
for _, sim := range *siml {
|
|
out,err := sims.Create(sim)
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
outlist = append(outlist, out)
|
|
}
|
|
|
|
bytes,err := json.Marshal(outlist)
|
|
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return string(bytes), nil
|
|
|
|
}
|
|
|
|
func (ss *SensorItemMappingService) List(s *sensor.Sensor) (string, error) {
|
|
|
|
out, err := utils.InvokeDBByModel("sensorItemMapping", "findAllBySensorId", s, "com.loafle.overflow.sensor.model.Sensor")
|
|
|
|
if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return out, nil
|
|
|
|
}
|