sensor etc added
This commit is contained in:
46
proxy/sensor/sensor.go
Normal file
46
proxy/sensor/sensor.go
Normal file
@@ -0,0 +1,46 @@
|
||||
package sensor
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.loafle.net/overflow/commons_go/model/timestamp"
|
||||
"git.loafle.net/overflow/overflow_proxy_service/proxy/target"
|
||||
"git.loafle.net/overflow/overflow_proxy_service/proxy/utils"
|
||||
)
|
||||
|
||||
type Sensor struct {
|
||||
Id json.Number `json:"id,Number,omitempty"`
|
||||
Target target.Target `json:"target,omitempty"`
|
||||
Notification string `json:"notification,omitempty"`
|
||||
CreateDate timestamp.Timestamp `json:"createDate,omitempty"`
|
||||
}
|
||||
|
||||
type SensorService struct {
|
||||
}
|
||||
|
||||
func NewSensorService() *SensorService {
|
||||
return &SensorService{}
|
||||
}
|
||||
|
||||
func (ss *SensorService) Create(s *Sensor) (string, error) {
|
||||
out, err := utils.InvokeDB("sensor", "create", s)
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
|
||||
func (ss *SensorService)List(t *target.Target) (string, error) {
|
||||
|
||||
|
||||
out, err := utils.InvokeDBByModel("sensor", "findAllByTargetId", t, "com.loafle.overflow.target.model.Target")
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
||||
return out, nil;
|
||||
|
||||
}
|
||||
1
proxy/sensor/sensor_test.go
Normal file
1
proxy/sensor/sensor_test.go
Normal file
@@ -0,0 +1 @@
|
||||
package sensor
|
||||
Reference in New Issue
Block a user