feat(osi): 打通 Go 侧真实请求验收(T-005)

This commit is contained in:
ila
2026-07-06 23:03:14 +08:00
parent 2a77a4dbc1
commit def95efb1c
12 changed files with 411 additions and 54 deletions
+49
View File
@@ -0,0 +1,49 @@
package main
import (
"context"
"encoding/json"
"fmt"
"time"
"chis_osi/config"
"chis_osi/osi"
)
type jkdaFindCheckResult struct {
Code string
Message string
DataCount int
}
func runJKDAFindCheck(ctx context.Context, cfg config.Config, idCard string) (jkdaFindCheckResult, error) {
if idCard == "" {
return jkdaFindCheckResult{}, fmt.Errorf("id card is required")
}
transport, err := osi.NewTransport(osi.TransportConfig{
Timeout: time.Duration(cfg.OSI.TimeoutSec) * time.Second,
Socks5Proxy: cfg.OSI.Socks5Proxy,
})
if err != nil {
return jkdaFindCheckResult{}, err
}
client := osi.NewClient(osi.ClientConfig{
BaseURL: cfg.OSI.BaseURL,
OrgCode: cfg.OSI.OrgCode,
DeviceSN: cfg.OSI.DeviceSN,
UserName: cfg.OSI.UserName,
Ask: cfg.OSI.Ask,
OperateUser: cfg.OSI.OperateUser,
OperateUnit: cfg.OSI.OrgCode,
Transport: transport,
})
var data []json.RawMessage
result, err := client.Call(ctx, osi.ServiceIDJKDAFind, map[string]string{"idCard": idCard}, &data)
check := jkdaFindCheckResult{Code: result.Code, Message: result.Message, DataCount: len(data)}
if err != nil {
return check, err
}
return check, nil
}