feat(osi): 体检已检/未检名单查询打通(T-305)
- osi.ListHealthCheckPeople(JKTJLIST00002 /auto/jktjlist/query) - ListHealthCheckQuery:checkYear 必填、page/rows 默认、idCard/checkType 可选 - contract.HealthCheckPerson 名单行 20 字段,字段名按实测校正(birthday/phrId/manaDoctorId/manaDocterName/empiId) - 单测:名单解码/路径/baseInfo 分页/checkYear 校验(脱敏假数据) - 实测端点已部署,code=01 返回分页人员名单 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ package osi
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
@@ -43,6 +44,56 @@ func TestLastHealthCheckDecodesSummaryAndHitsPath(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestListHealthCheckPeopleDecodesRosterAndHitsPath(t *testing.T) {
|
||||
var seenPath string
|
||||
var seenBody map[string]any
|
||||
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
seenPath = r.URL.Path
|
||||
_ = json.NewDecoder(r.Body).Decode(&seenBody)
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
// data 为人员名单数组;字段名取自实测,值均为脱敏假数据
|
||||
_, _ = w.Write([]byte(`{"code":"01","message":"操作成功","data":[` +
|
||||
`{"idCard":"TEST-1","personName":"甲","phrId":"PHR-1","checkType":"0","rqbj":"PU"},` +
|
||||
`{"idCard":"TEST-2","personName":"乙","phrId":"PHR-2","checkType":"1","rqbj":"LAO"}]}`))
|
||||
}))
|
||||
defer server.Close()
|
||||
|
||||
transport, err := NewTransport(TransportConfig{Timeout: time.Second})
|
||||
if err != nil {
|
||||
t.Fatalf("NewTransport: %v", err)
|
||||
}
|
||||
client := NewClient(ClientConfig{BaseURL: server.URL, UserName: "u", Ask: "k", Transport: transport})
|
||||
|
||||
people, result, err := client.ListHealthCheckPeople(context.Background(), ListHealthCheckQuery{CheckYear: "2025", IDCard: "TEST-1", CheckType: "2"})
|
||||
if err != nil {
|
||||
t.Fatalf("ListHealthCheckPeople: %v", err)
|
||||
}
|
||||
if seenPath != "/osi/api/auto/jktjlist/query" {
|
||||
t.Fatalf("path = %q", seenPath)
|
||||
}
|
||||
if !result.Success || len(people) != 2 {
|
||||
t.Fatalf("people = %d result = %#v", len(people), result)
|
||||
}
|
||||
if people[0].CheckType != "0" || people[0].PhrID != "PHR-1" {
|
||||
t.Fatalf("row0 = %#v", people[0])
|
||||
}
|
||||
// checkYear/page/rows 应落在 uploadinfo.baseInfo
|
||||
base := seenBody["uploadinfo"].(map[string]any)["baseInfo"].(map[string]any)
|
||||
if base["checkYear"] != "2025" || base["page"] != "1" || base["rows"] != "10" {
|
||||
t.Fatalf("baseInfo = %#v", base)
|
||||
}
|
||||
}
|
||||
|
||||
func TestListHealthCheckQueryRequiresCheckYear(t *testing.T) {
|
||||
if _, err := (ListHealthCheckQuery{IDCard: "x"}).baseInfo(); err == nil {
|
||||
t.Fatal("missing checkYear should error")
|
||||
}
|
||||
base, err := (ListHealthCheckQuery{CheckYear: "2025"}).baseInfo()
|
||||
if err != nil || base["page"] != "1" || base["rows"] != "10" {
|
||||
t.Fatalf("default page/rows wrong: %v err=%v", base, err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFindHealthCheckQueryRequiresExactlyOneKey(t *testing.T) {
|
||||
if _, err := (FindHealthCheckQuery{}).baseInfo(); err == nil {
|
||||
t.Fatal("empty query should error")
|
||||
|
||||
Reference in New Issue
Block a user