first overflow service commit
This commit is contained in:
47
proxy/sensorItem/sensorItem.go
Normal file
47
proxy/sensorItem/sensorItem.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package sensorItem
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.loafle.net/overflow/commons_go/model/timestamp"
|
||||
"git.loafle.net/overflow/overflow_proxy_service/proxy/crawler"
|
||||
"git.loafle.net/overflow/overflow_proxy_service/proxy/sensorItemCategory"
|
||||
"git.loafle.net/overflow/overflow_proxy_service/proxy/utils"
|
||||
)
|
||||
|
||||
type SensorItem struct {
|
||||
Id json.Number `json:"id,Number,omitempty"`
|
||||
Crawler crawler.Crawler `json:"crawler,omitempty"`
|
||||
SensorItemCategory sensorItemCategory.SensorItemCategory `json:"sensorItemCategory,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
DataType string `json:"dataType,omitempty"`
|
||||
CreateDate timestamp.Timestamp `json:"createDate,omitempty"`
|
||||
}
|
||||
|
||||
type SensorItemService struct {
|
||||
}
|
||||
|
||||
func NewSensorItemService() *SensorItemService {
|
||||
return &SensorItemService{}
|
||||
}
|
||||
|
||||
func (sis *SensorItemService) Create(si *SensorItem) (string, error) {
|
||||
out, err := utils.InvokeDBByModel("sensorItem", "create", si, "com.loafle.overflow.sensor.model.SensorItem")
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (ss *SensorItemService) List(cr *crawler.Crawler) (string, error) {
|
||||
|
||||
out, err := utils.InvokeDBByModel("sensorItem", "findAllByCrawlerId", cr, "com.loafle.overflow.crawler.model.Crawler")
|
||||
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return out, nil
|
||||
|
||||
}
|
||||
18
proxy/sensorItem/sensorItem_test.go
Normal file
18
proxy/sensorItem/sensorItem_test.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package sensorItem
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"git.loafle.net/overflow/overflow_proxy_service/proxy/crawler"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestSensorItemService_List(t *testing.T) {
|
||||
|
||||
cr := &crawler.Crawler{}
|
||||
cr.Id = json.Number("1")
|
||||
sis := NewSensorItemService()
|
||||
|
||||
res, _ := sis.List(cr)
|
||||
|
||||
t.Log(res)
|
||||
}
|
||||
Reference in New Issue
Block a user