sync: 同步 v1.0.4 开源代码并脱敏
This commit is contained in:
@@ -6,16 +6,16 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/consts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/logic/upstreamimpl/dx"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/model"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/service"
|
||||
"math"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/consts"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/logic/upstreamimpl/dx"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/model"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-upstream-chan/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
@@ -84,7 +84,11 @@ func (s *sSimDXV3) request(ctx context.Context, path string, params url.Values,
|
||||
} else {
|
||||
data, err = json.Marshal(body)
|
||||
if err == nil {
|
||||
data, err = s.client.DoPostJSONRequest(ctx, "/api/v3/"+path, data)
|
||||
if path == "singleCutNet" {
|
||||
data, err = s.client.DoPostJSONWriteRequest(ctx, "/api/v3/"+path, data)
|
||||
} else {
|
||||
data, err = s.client.DoPostJSONRequest(ctx, "/api/v3/"+path, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
if err != nil {
|
||||
@@ -180,6 +184,7 @@ func dxV3QueryOne[T any](ctx context.Context, s *sSimDXV3, key *model.SimKey, pa
|
||||
err = prepare(params)
|
||||
}
|
||||
var result map[string]any
|
||||
apnWriteStarted := err == nil && post && path == "singleCutNet"
|
||||
if err == nil {
|
||||
var body any
|
||||
if post {
|
||||
@@ -204,7 +209,14 @@ func dxV3QueryOne[T any](ctx context.Context, s *sSimDXV3, key *model.SimKey, pa
|
||||
output, err = convert(result)
|
||||
}
|
||||
if err != nil {
|
||||
return dxV3Failure[T](key, err)
|
||||
item := dxV3Failure[T](key, err)
|
||||
var business *dxV3Error
|
||||
if apnWriteStarted && !errors.As(err, &business) {
|
||||
if apn, ok := any(&item.ResData).(*model.SimCardOperateChangeApnItem); ok {
|
||||
apn.Uncertain = true
|
||||
}
|
||||
}
|
||||
return item
|
||||
}
|
||||
return &model.SimBaseRes[T]{SimKey: key, ResData: output}
|
||||
}
|
||||
@@ -540,7 +552,7 @@ func (s *sSimDXV3) ChangeSimStatus(ctx context.Context, input *model.SimCardStat
|
||||
}
|
||||
|
||||
func (s *sSimDXV3) ChangeSimApnFunction(ctx context.Context, input *model.SimCardOperateChangeApnInput) (model.SimCardOperateChangeApnOutput, error) {
|
||||
return dxV3Query(ctx, s, input.SimKeys, "singleCutNet", func(params url.Values) error {
|
||||
prepare := func(params url.Values) error {
|
||||
if !s.enableOperations {
|
||||
return fmt.Errorf("telecom v3 operations are disabled")
|
||||
}
|
||||
@@ -559,10 +571,27 @@ func (s *sSimDXV3) ChangeSimApnFunction(ctx context.Context, input *model.SimCar
|
||||
return fmt.Errorf("unsupported data operType")
|
||||
}
|
||||
return nil
|
||||
}, func(item map[string]any) (model.SimCardOperateChangeApnItem, error) {
|
||||
}
|
||||
convert := func(item map[string]any) (model.SimCardOperateChangeApnItem, error) {
|
||||
order, err := dxV3Order(item)
|
||||
return model.SimCardOperateChangeApnItem{OrderNum: order.OrderNum}, err
|
||||
}, true), nil
|
||||
}
|
||||
items := make(model.SimCardOperateChangeApnOutput, 0, len(input.SimKeys))
|
||||
checkpoint, durable := ctx.Value(model.ApnOperationCheckpointKey{}).(func(model.SimCardOperateChangeApnOutput) error)
|
||||
for _, key := range input.SimKeys {
|
||||
item := dxV3QueryOne(ctx, s, key, "singleCutNet", prepare, convert, true)
|
||||
if item.Code == consts.ApiStatusSuccess && (input.ReqData.SubmitOnly || durable) {
|
||||
item.ResData.Uncertain = true
|
||||
item.Message = "电信单独断网请求已受理,最终办理结果未确认,请核对上游"
|
||||
}
|
||||
items = append(items, item)
|
||||
if durable {
|
||||
if err := checkpoint(items); err != nil {
|
||||
return nil, fmt.Errorf("电信 v3 第%d张卡办理结果持久化失败,停止后续写入:%w", len(items), err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
var _ model.SimCardChannelI = (*sSimDXV3)(nil)
|
||||
|
||||
Reference in New Issue
Block a user