Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
6f375272a0
@ -17,9 +17,6 @@ func TestSensorRegist(t *testing.T) {
|
|||||||
p.Id = json.Number("1")
|
p.Id = json.Number("1")
|
||||||
i := &infra.Infra{}
|
i := &infra.Infra{}
|
||||||
i.Id = json.Number("1")
|
i.Id = json.Number("1")
|
||||||
status := &meta.MetaSensorStatus{
|
|
||||||
Id: "2",
|
|
||||||
}
|
|
||||||
target := &target.Target{
|
target := &target.Target{
|
||||||
Id: "1",
|
Id: "1",
|
||||||
}
|
}
|
||||||
@ -29,7 +26,7 @@ func TestSensorRegist(t *testing.T) {
|
|||||||
sensor := &Sensor{
|
sensor := &Sensor{
|
||||||
CreateDate: timestamp.Now(),
|
CreateDate: timestamp.Now(),
|
||||||
Description: "This is a Sensor",
|
Description: "This is a Sensor",
|
||||||
MetaSensorStatus: status,
|
MetaSensorStatus: meta.NewMetaSensorStatus(meta.SENSOR_STATUS_RUNNING),
|
||||||
Target: target,
|
Target: target,
|
||||||
Crawler: crawler,
|
Crawler: crawler,
|
||||||
}
|
}
|
||||||
|
@ -1,47 +0,0 @@
|
|||||||
package sensorItem
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/commons_go/model/timestamp"
|
|
||||||
"git.loafle.net/overflow/overflow_service/proxy/crawler"
|
|
||||||
"git.loafle.net/overflow/overflow_service/proxy/sensorItemCategory"
|
|
||||||
"git.loafle.net/overflow/overflow_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
|
|
||||||
|
|
||||||
}
|
|
@ -1,18 +0,0 @@
|
|||||||
package sensorItem
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/overflow_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)
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
package sensorItemCategory
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/commons_go/model/timestamp"
|
|
||||||
"git.loafle.net/overflow/overflow_service/proxy/utils"
|
|
||||||
)
|
|
||||||
|
|
||||||
type SensorItemCategory struct {
|
|
||||||
Id json.Number `json:"id,Number,omitempty"`
|
|
||||||
Name string `json:"name,omitempty"`
|
|
||||||
Description string `json:"description,omitempty"`
|
|
||||||
CreateDate timestamp.Timestamp `json:"createDate,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type SensorItemCategoryService struct {
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewSensorItemCategoryService() *SensorItemCategoryService {
|
|
||||||
return &SensorItemCategoryService{}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (sics *SensorItemCategoryService) Create(sic *SensorItemCategory) (string, error) {
|
|
||||||
out, err := utils.InvokeDBByModel("sensorItemCategory", "create", sic, "com.loafle.overflow.sensor.model.SensorItemCategory")
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
return "", err
|
|
||||||
}
|
|
||||||
return out, nil
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
package sensorItemCategory
|
|
@ -1,65 +0,0 @@
|
|||||||
package sensorItemMapping
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"git.loafle.net/overflow/commons_go/model/timestamp"
|
|
||||||
"git.loafle.net/overflow/overflow_service/proxy/sensor"
|
|
||||||
"git.loafle.net/overflow/overflow_service/proxy/sensorItem"
|
|
||||||
"git.loafle.net/overflow/overflow_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
|
|
||||||
|
|
||||||
}
|
|
@ -1,56 +0,0 @@
|
|||||||
package sensorItemMapping
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"git.loafle.net/overflow/overflow_service/proxy/sensor"
|
|
||||||
"strconv"
|
|
||||||
"sync"
|
|
||||||
"testing"
|
|
||||||
)
|
|
||||||
|
|
||||||
func TestSensorItemMappingService_List(t *testing.T) {
|
|
||||||
s := &sensor.Sensor{}
|
|
||||||
s.Id = json.Number("1")
|
|
||||||
|
|
||||||
sims := NewSensorItemMappingService()
|
|
||||||
res, _ := sims.List(s)
|
|
||||||
|
|
||||||
t.Log(res)
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestSensorItemMappingService_List_GoRutine(t *testing.T) {
|
|
||||||
//s := &sensor.Sensor{}
|
|
||||||
//s.Id = json.Number("14")
|
|
||||||
|
|
||||||
sims := NewSensorItemMappingService()
|
|
||||||
|
|
||||||
il := make([]int, 0)
|
|
||||||
|
|
||||||
il = append(il, 1)
|
|
||||||
il = append(il, 2)
|
|
||||||
il = append(il, 3)
|
|
||||||
il = append(il, 13)
|
|
||||||
il = append(il, 14)
|
|
||||||
|
|
||||||
for _, ii := range il {
|
|
||||||
|
|
||||||
go func(i int) {
|
|
||||||
s := &sensor.Sensor{}
|
|
||||||
s.Id = json.Number(strconv.Itoa(ii))
|
|
||||||
res, _ := sims.List(s)
|
|
||||||
fmt.Print(res)
|
|
||||||
}(ii)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
wg := sync.WaitGroup{}
|
|
||||||
|
|
||||||
wg.Add(1)
|
|
||||||
|
|
||||||
wg.Wait()
|
|
||||||
|
|
||||||
//res, _ := sims.List(s)
|
|
||||||
//
|
|
||||||
//t.Log(res)
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user