chore: 并入 iotlcm-upstream-proxy 历史到 upstream-proxy/(原提交 44209ec)

This commit is contained in:
MiFaZhan
2026-11-02 13:28:02 +08:00
117 changed files with 8690 additions and 0 deletions
@@ -0,0 +1,65 @@
package cardquery
import (
"context"
"encoding/json"
"strings"
"github.com/gogf/gf/v2/frame/g"
v1 "git.5iot.com/iotlcm-public/iotlcm-upstream-proxy/api/cardquery/v1"
"git.5iot.com/iotlcm-public/iotlcm-upstream-proxy/internal/service"
)
// func (c *ControllerV1) SimBase(ctx context.Context, req *v1.SimBaseReq) (res *v1.SimBaseRes, err error) {
// g.Log().Debugf(ctx, "SimBase req %+v", req)
// r := g.RequestFromCtx(ctx)
// if r.Method != "POST" {
// return nil, gerror.New("method not allowed")
// }
// path := r.URL.Path
// if path == "" {
// return nil, gerror.New("path is required")
// }
// // 获取渠道KEY
// for _, simKey := range req.SimKeys {
// if simKey.ChanKey == "" {
// simKey.ChanKey = "channel_003"
// }
// }
// // 获取三码信息
// url := "http://iotlcmupstreamproxy-http-svc" + path
// client := g.Client()
// client.SetDiscovery(gsvc.GetRegistry())
// client.SetTimeout(time.Second * 10)
// postData, err := json.Marshal(req)
// if err != nil {
// return nil, err
// }
// resp, err := client.Post(ctx, url, postData)
// if err != nil {
// return nil, err
// }
// body := resp.ReadAllString()
// var simBaseRes model.SimBaseResJson
// err = json.Unmarshal([]byte(body), &simBaseRes)
// if err != nil {
// return nil, err
// }
// return &simBaseRes, nil
// }
func (c *ControllerV1) SimBase(ctx context.Context, req *v1.SimBaseReq) (res *v1.SimBaseRes, err error) {
request := g.RequestFromCtx(ctx)
if request != nil && (request.URL.Path == "/sim/change/sim-apn" || request.URL.Path == "/sim/query/sim-apn-capability") && strings.HasPrefix(strings.ToLower(request.Header.Get("Content-Type")), "application/json") {
// GoFrame通用字段转换不能保留json.RawMessage,APN协议直接按原始JSON绑定。
if err := json.Unmarshal(request.GetBody(), &req.SimBaseReqJson); err != nil {
return nil, err
}
}
out, err := service.SimKeyFill().SimKeyFill(ctx, &req.SimBaseReqJson)
if err != nil {
return nil, err
}
return &out, nil
}