You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
service/skycrane/task.go

66 lines
1.4 KiB

6 months ago
package skycrane
import (
"context"
"git.oa00.com/supply-chain/service/client"
"time"
)
const (
TaskStatusIng = 1 // 进行中
TaskStatusFinish = 2 // 结束
)
type task struct {
}
// Pull @Title 拉取商品
func (t *task) Pull(ctx context.Context) error {
a := 0
xClient, err := client.GetClient(t)
if err != nil {
return err
}
return xClient.Call(ctx, "Pull", 0, &a)
}
type TaskStatus struct {
ScrollId string `json:"scrollId"`
Total int64 `json:"total"`
Count int64 `json:"count"`
Status int `json:"status"` // 1=运行中 2=已完成
Msg string `json:"msg"`
StartTime time.Time `json:"startTime"`
LastTime time.Time `json:"lastTime"`
}
// GetPullStatus @Title 获取拉取状态
func (t *task) GetPullStatus(ctx context.Context) (reply TaskStatus, err error) {
xClient, err := client.GetClient(t)
if err != nil {
return
}
err = xClient.Call(ctx, "GetPullStatus", 0, &reply)
return
}
6 months ago
// Prices @Title 商品更新
func (t *task) Prices(ctx context.Context) error {
a := 0
xClient, err := client.GetClient(t)
if err != nil {
return err
}
return xClient.Call(ctx, "Prices", 0, &a)
}
// GetPricesStatus @Title 获取拉取状态
func (t *task) GetPricesStatus(ctx context.Context) (reply TaskStatus, err error) {
xClient, err := client.GetClient(t)
if err != nil {
return
}
err = xClient.Call(ctx, "GetPricesStatus", 0, &reply)
return
}