feat(osi): 优化人群分类查询接口(T-209)
This commit is contained in:
@@ -51,6 +51,37 @@ func (h *HealthRecordHandler) Find(w http.ResponseWriter, r *http.Request) {
|
||||
writeJSONError(w, http.StatusBadGateway, "empty response from OSI")
|
||||
}
|
||||
|
||||
// Crowd 处理 GET /api/health-record/crowd?idCard=..|phrid=..
|
||||
// 原样回写 JKDA00005 人群分类与子档案标记响应。
|
||||
func (h *HealthRecordHandler) Crowd(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet {
|
||||
writeJSONError(w, http.StatusMethodNotAllowed, "only GET is supported")
|
||||
return
|
||||
}
|
||||
|
||||
q := r.URL.Query()
|
||||
query := osi.FindRqbjQuery{
|
||||
IDCard: q.Get("idCard"),
|
||||
PHRID: q.Get("phrid"),
|
||||
}
|
||||
if query.IDCard == "" && query.PHRID == "" {
|
||||
writeJSONError(w, http.StatusBadRequest, "provide one of: idCard, phrid")
|
||||
return
|
||||
}
|
||||
|
||||
_, result, err := h.client.FindRqbj(r.Context(), query)
|
||||
if len(result.Raw) > 0 {
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
_, _ = w.Write(result.Raw)
|
||||
return
|
||||
}
|
||||
if err != nil {
|
||||
writeJSONError(w, http.StatusBadGateway, err.Error())
|
||||
return
|
||||
}
|
||||
writeJSONError(w, http.StatusBadGateway, "empty response from OSI")
|
||||
}
|
||||
|
||||
func writeJSONError(w http.ResponseWriter, status int, msg string) {
|
||||
w.Header().Set("Content-Type", "application/json; charset=utf-8")
|
||||
w.WriteHeader(status)
|
||||
|
||||
Reference in New Issue
Block a user