48 lines
966 B
Go
48 lines
966 B
Go
package meta
|
|
|
|
import (
|
|
"encoding/json"
|
|
|
|
"git.loafle.net/overflow/model/util"
|
|
)
|
|
|
|
type MetaPortType struct {
|
|
ID json.Number `json:"id,Number,omitempty"`
|
|
Name string `json:"name,omitempty"`
|
|
Key string `json:"key,omitempty"`
|
|
CreateDate *util.Timestamp `json:"createDate,omitempty"`
|
|
}
|
|
|
|
type MetaPortTypeEnum int
|
|
|
|
const (
|
|
MetaPortTypeEnumTCP MetaPortTypeEnum = iota + 1
|
|
MetaPortTypeEnumUDP
|
|
)
|
|
|
|
var (
|
|
metaPortTypeEnumID = map[MetaPortTypeEnum]string{
|
|
MetaPortTypeEnumTCP: "TCP",
|
|
MetaPortTypeEnumUDP: "UDP",
|
|
}
|
|
|
|
metaPortTypeEnumKey = map[string]MetaPortTypeEnum{
|
|
"TCP": MetaPortTypeEnumTCP,
|
|
"UDP": MetaPortTypeEnumUDP,
|
|
}
|
|
)
|
|
|
|
func (e MetaPortTypeEnum) String() string {
|
|
return metaPortTypeEnumID[e]
|
|
}
|
|
|
|
func ToMetaPortTypeEnum(v *MetaPortType) MetaPortTypeEnum {
|
|
return metaPortTypeEnumKey[v.Key]
|
|
}
|
|
|
|
func ToMetaPortType(v MetaPortTypeEnum) *MetaPortType {
|
|
return &MetaPortType{
|
|
Key: metaPortTypeEnumID[v],
|
|
}
|
|
}
|