test(admin): 补充后台接口数据库测试 (#47)

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
fu500f
2026-10-31 00:59:06 +00:00
co-authored by Devin AI
parent 36f9c95fa7
commit 003543d6e2
2 changed files with 354 additions and 6 deletions
+3 -6
View File
@@ -10,12 +10,9 @@ import (
func (h *Handler) ImportBypos(w http.ResponseWriter, r *http.Request) {
var records []adminstore.ByposRecord
dec := json.NewDecoder(http.MaxBytesReader(w, r.Body, 50<<20))
for dec.More() {
var rec adminstore.ByposRecord
if err := dec.Decode(&rec); err != nil {
continue
}
records = append(records, rec)
if err := dec.Decode(&records); err != nil {
writeError(w, http.StatusBadRequest, "bad_request", "请求体应为 JSON 数组")
return
}
if len(records) == 0 {
writeError(w, http.StatusBadRequest, "empty", "\u6ca1\u6709\u53ef\u5bfc\u5165\u7684\u8bb0\u5f55")