50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
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
|
|
}
|