sync: 同步 v1.0.4 开源代码并脱敏
This commit is contained in:
@@ -2,12 +2,58 @@ package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strings"
|
||||
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/os/gcmd"
|
||||
|
||||
"git.5iot.com/iotlcm-public/iotlcm-worker-svr/internal/client/upstream"
|
||||
datarepository "git.5iot.com/iotlcm-public/iotlcm-worker-svr/internal/repository/data"
|
||||
dataservice "git.5iot.com/iotlcm-public/iotlcm-worker-svr/internal/service/data"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-worker-svr/internal/worker"
|
||||
)
|
||||
|
||||
var QueryAPNReview = gcmd.Command{
|
||||
Name: "query-apn-review",
|
||||
Usage: "query-apn-review --operation-id=<operationId> | --batch-no=<batchNo>",
|
||||
Brief: "只读查询待核查APN子批并同步已确认结果(传 batch-no 时同步该父批下全部待核查子批)",
|
||||
Arguments: []gcmd.Argument{
|
||||
{Name: "operation-id", Brief: "待核查子批operationId"},
|
||||
{Name: "batch-no", Brief: "待核查父批批次号,按父批同步全部待核查子批"},
|
||||
},
|
||||
Func: func(ctx context.Context, parser *gcmd.Parser) error {
|
||||
operationID := strings.TrimSpace(parser.GetOpt("operation-id").String())
|
||||
batchNo := strings.TrimSpace(parser.GetOpt("batch-no").String())
|
||||
if operationID == "" && batchNo == "" {
|
||||
return gerror.New("必须提供 operation-id 或 batch-no")
|
||||
}
|
||||
if operationID != "" && batchNo != "" {
|
||||
return gerror.New("operation-id 与 batch-no 不能同时提供")
|
||||
}
|
||||
executor := dataservice.NewExecutor(datarepository.New(), upstream.New())
|
||||
if batchNo != "" {
|
||||
queried, err := executor.QueryReviewBatch(ctx, batchNo)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
g.Log().Infof(ctx, "APN待核查批量同步完成 batchNo=%s 已同步=%d", batchNo, queried)
|
||||
return nil
|
||||
}
|
||||
if err := executor.QueryReview(ctx, operationID); err != nil {
|
||||
return err
|
||||
}
|
||||
g.Log().Infof(ctx, "APN待核查查询完成 operationId=%s", operationID)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
if err := Main.AddCommand(&QueryAPNReview); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
var Main = gcmd.Command{
|
||||
Name: "main",
|
||||
Usage: "main",
|
||||
|
||||
Reference in New Issue
Block a user