bd705e9616
target service
62 lines
1.3 KiB
Go
62 lines
1.3 KiB
Go
package target
|
|
|
|
import (
|
|
"encoding/json"
|
|
"git.loafle.net/overflow/commons_go/model/timestamp"
|
|
"git.loafle.net/overflow/overflow_proxy_service/proxy/member"
|
|
"git.loafle.net/overflow/overflow_proxy_service/proxy"
|
|
)
|
|
|
|
type Target struct {
|
|
Id json.Number `json:"id,Number,omitempty"`
|
|
Ip int64 `json:"ip,omitempty"`
|
|
Port int `json:"port,omitempty"`
|
|
TargetType string `json:"targetType,omitempty"`
|
|
VendorName string `json:"vendorName,omitempty"`
|
|
Kinds string `json:"kinds,omitempty"`
|
|
Version string `json:"version,omitempty"`
|
|
CreateDate timestamp.Timestamp `json:"createDate,omitempty"`
|
|
Member *member.MemberService `json:"member,omitempty"`
|
|
}
|
|
|
|
type TargetService struct {
|
|
|
|
}
|
|
|
|
func NewTargetService() *TargetService {
|
|
return &TargetService{}
|
|
}
|
|
|
|
func (t *TargetService)List(tm *Target) string {
|
|
|
|
bytes, err := json.Marshal(tm)
|
|
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
|
|
m := make(map[string]string)
|
|
m["com.loafle.overflow.target.model.Target"] = string(bytes)
|
|
|
|
out := proxy.InvokeDB("target", "findAll", m)
|
|
|
|
|
|
return out;
|
|
}
|
|
|
|
func (t *TargetService)Create(tm *Target) string {
|
|
|
|
bytes, err := json.Marshal(tm)
|
|
|
|
if err != nil {
|
|
return ""
|
|
}
|
|
|
|
m := make(map[string]string)
|
|
m["com.loafle.overflow.target.model.Target"] = string(bytes)
|
|
|
|
out := proxy.InvokeDB("target", "create", m)
|
|
|
|
|
|
return out;
|
|
} |