Files
chis_osi/server.go
T
ilaandClaude Opus 4.8 e67664da45 feat(handler): 体检 HTTP 查询端点(T-302)
- GET /api/health-check/last(最近一次)+ /api/health-check/list(年度已检未检名单)
- 回写平台完整响应 Result.Raw,抽 writeRawOrError 共用
- last 按 idCard/phrid/empiId;list 按 checkYear(必填)+idCard+checkType
- 单测:路径/原样回写/缺参 400(脱敏假 OSI 后端);默认仅绑本机

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 21:17:02 +08:00

33 lines
1001 B
Go

package main
import (
"fmt"
"net/http"
"chis_osi/config"
"chis_osi/handler"
)
// runServer 启动 server 模式 HTTP 服务,暴露健康档案查询端点。
func runServer(cfg config.Config, addr string) error {
client, err := buildOSIClient(cfg)
if err != nil {
return fmt.Errorf("build osi client: %w", err)
}
hr := handler.NewHealthRecordHandler(client)
hc := handler.NewHealthCheckHandler(client)
mux := http.NewServeMux()
mux.HandleFunc("/api/health-record/find", hr.Find)
mux.HandleFunc("/api/health-check/last", hc.Last)
mux.HandleFunc("/api/health-check/list", hc.List)
fmt.Printf("chis_osi server listening on %s\n", addr)
fmt.Printf(" GET http://%s/api/health-record/find?idCard=<身份证>\n", addr)
fmt.Printf(" GET http://%s/api/health-check/last?idCard=<身份证>\n", addr)
fmt.Printf(" GET http://%s/api/health-check/list?checkYear=<年度>&idCard=<身份证>\n", addr)
server := &http.Server{Addr: addr, Handler: mux}
return server.ListenAndServe()
}