overflow_service/proxy/probe/probe_task_service.go
2017-06-27 09:08:47 +09:00

60 lines
1.6 KiB
Go

package probe
import (
"encoding/json"
"git.loafle.net/overflow/commons_go/model/timestamp"
"git.loafle.net/overflow/overflow_service/proxy/meta"
"git.loafle.net/overflow/overflow_service/proxy/utils"
)
type ProbeTask struct {
Id json.Number `json:"id,Number,omitempty"`
MetaProbeTaskType *meta.MetaProbeTaskType `json:"metaProbeTaskType,omitempty"`
Probe *Probe `json:"probe,omitempty"`
Data string `json:"data,omitempty"`
CreateDate timestamp.Timestamp `json:"createDate,omitempty"`
SendDate timestamp.Timestamp `json:"sendDate,omitempty"`
StartDate timestamp.Timestamp `json:"startDate,omitempty"`
EndDate timestamp.Timestamp `json:"startDate,omitempty"`
Succeed bool `json:"succeed,omitempty"`
}
func NewProbeTask(types *meta.MetaProbeTaskType, data string, p *Probe) *ProbeTask {
return &ProbeTask{
MetaProbeTaskType: types,
Data: data,
Probe: p,
}
}
type ProbeTaskService struct {
}
func NewProbeTaskService() *ProbeTaskService {
return &ProbeTaskService{}
}
func (pts *ProbeTaskService) Regist(pt *ProbeTask) (string, error) {
out, err := utils.InvokeDBByModel("probeTask", "save", pt, utils.MODEL_PROBE_TASK)
if err != nil {
return "", err
}
return out, nil
}
func (pts *ProbeTaskService) ReadAllByProbe(p *Probe) (string, error) {
out, err := utils.InvokeDBByModel("probeTask", "findAllByProbe", p, utils.MODEL_PROBE)
if err != nil {
return "", err
}
return out, nil
}