b08495b6f6
- collected.txt 跨文件/跨次记录已查询条码,避免重复采集 - Web UI 显示历史已采集条码计数 - Goods API 新增 POST /api/import/bypos 批量导入端点(含upsert) - 采集器 Web UI 新增一键导入按钮(登录+上传JSONL) - Windows exe 重新编译 Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
31 lines
792 B
Go
31 lines
792 B
Go
package adminhandler
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/baicai2026-baicai/goods/api/internal/adminstore"
|
|
)
|
|
|
|
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 len(records) == 0 {
|
|
writeError(w, http.StatusBadRequest, "empty", "\u6ca1\u6709\u53ef\u5bfc\u5165\u7684\u8bb0\u5f55")
|
|
return
|
|
}
|
|
result, err := h.store.ImportByposRecords(r.Context(), records)
|
|
if err != nil {
|
|
writeError(w, http.StatusInternalServerError, "import_error", err.Error())
|
|
return
|
|
}
|
|
writeJSON(w, http.StatusOK, result)
|
|
}
|