remove logic
This commit is contained in:
parent
91dd79edc3
commit
e27a7af285
@ -9,7 +9,7 @@ import (
|
|||||||
|
|
||||||
type SensorItem struct {
|
type SensorItem struct {
|
||||||
Id json.Number `json:"id,Number,omitempty"`
|
Id json.Number `json:"id,Number,omitempty"`
|
||||||
Sensor *Sensor `json:"sensor,omitempty"`
|
Sensor *Sensor `json:"sensor,omitempty"`
|
||||||
MetaSensorItem *meta.MetaSensorItem `json:"item,omitempty"`
|
MetaSensorItem *meta.MetaSensorItem `json:"item,omitempty"`
|
||||||
CreateDate timestamp.Timestamp `json:"createDate,omitempty"`
|
CreateDate timestamp.Timestamp `json:"createDate,omitempty"`
|
||||||
}
|
}
|
||||||
@ -50,3 +50,13 @@ func (ss *SensorItemService) Read(id string) (string, error) {
|
|||||||
|
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ss *SensorItemService) Remove(s *SensorItem) (string, error) {
|
||||||
|
out, err := utils.InvokeDBByModel("sensorItem", "delete", s, utils.MODEL_SENSOR_ITEM)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return out, nil
|
||||||
|
}
|
@ -54,3 +54,13 @@ func (ss *SensorService) Read(id string) (string, error) {
|
|||||||
|
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (ss *SensorService) Remove(s *Sensor) (string, error) {
|
||||||
|
out, err := utils.InvokeDBByModel("sensor", "delete", s, utils.MODEL_SENSOR)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return out, nil
|
||||||
|
}
|
||||||
|
@ -57,3 +57,14 @@ func (t *TargetService) Read(id string) (string, error) {
|
|||||||
|
|
||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *TargetService) Remove(target *Target) (string, error) {
|
||||||
|
|
||||||
|
out, err := utils.InvokeDBByModel("target", "delete", target, utils.MODEL_TARGET)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
|
||||||
|
return out, nil
|
||||||
|
}
|
@ -49,3 +49,16 @@ func TestTargetRead(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Log(res)
|
t.Log(res)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func TestTargetDelete(t *testing.T) {
|
||||||
|
ts := NewTargetService()
|
||||||
|
target := &Target{
|
||||||
|
Id:"1",
|
||||||
|
}
|
||||||
|
res, err := ts.Remove(target)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
t.Log(res)
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user