This commit is contained in:
crusader 2018-04-18 17:37:18 +09:00
parent 312284ff6d
commit fac45a284d
5 changed files with 79 additions and 9 deletions

View File

@ -0,0 +1,14 @@
package model
import (
"encoding/json"
"git.loafle.net/overflow/commons-go/core/util"
)
type MetaContainer struct {
ID json.Number `json:"id,Number,omitempty"`
Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"`
CreateDate util.Timestamp `json:"createDate,omitempty"`
}

View File

@ -11,4 +11,5 @@ type MetaCrawler struct {
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
Description string `json:"description,omitempty"` Description string `json:"description,omitempty"`
CreateDate util.Timestamp `json:"createDate,omitempty"` CreateDate util.Timestamp `json:"createDate,omitempty"`
Container *MetaContainer `json:"container,omitempty"`
} }

View File

@ -7,8 +7,8 @@ import (
) )
type MetaInfraVendor struct { type MetaInfraVendor struct {
ID json.Number `json:"id,Number,omitempty"` ID json.Number `json:"id,Number,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
CreateDate util.Timestamp `json:"createDate,omitempty"` CreateDate util.Timestamp `json:"createDate,omitempty"`
MetaInfraType *MetaInfraType `json:"metaInfraType,omitempty"` InfraType *MetaInfraType `json:"infraType,omitempty"`
} }

View File

@ -7,9 +7,9 @@ import (
) )
type MetaSensorItem struct { type MetaSensorItem struct {
ID json.Number `json:"id,Number,omitempty"` ID json.Number `json:"id,Number,omitempty"`
MetaSensorItemType *MetaSensorItemType `json:"metaSensorItemType,omitempty"` SensorItemType *MetaSensorItemType `json:"sensorItemType,omitempty"`
Key string `json:"key,omitempty"` Key string `json:"key,omitempty"`
Name string `json:"name,omitempty"` Name string `json:"name,omitempty"`
CreateDate util.Timestamp `json:"createDate,omitempty"` CreateDate util.Timestamp `json:"createDate,omitempty"`
} }

View File

@ -0,0 +1,55 @@
package constants
import (
"encoding/json"
"fmt"
)
type ContainerType int
const (
DISCOVERY ContainerType = iota
NETWORK
GENERNAL
)
var (
containerTypeID = map[ContainerType]string{
DISCOVERY: "DISCOVERY",
NETWORK: "NETWORK",
GENERNAL: "GENERNAL",
}
containerTypeName = map[string]ContainerType{
"DISCOVERY": DISCOVERY,
"NETWORK": NETWORK,
"GENERNAL": GENERNAL,
}
)
func (ct ContainerType) String() string {
return containerTypeID[ct]
}
func (ct ContainerType) MarshalJSON() ([]byte, error) {
value, ok := containerTypeID[ct]
if !ok {
return nil, fmt.Errorf("Invalid EnumType[%s] value", ct)
}
return json.Marshal(value)
}
func (ct ContainerType) UnmarshalJSON(b []byte) error {
var s string
err := json.Unmarshal(b, &s)
if err != nil {
return err
}
value, ok := containerTypeName[s]
if !ok {
return fmt.Errorf("Invalid EnumType[%s] value", s)
}
ct = value
return nil
}