Migrate ingest and API paths to string IDs

This commit is contained in:
2026-02-14 20:10:23 +03:00
parent 6df92b7a69
commit 3ffdf9b0e1
42 changed files with 1958 additions and 437 deletions

View File

@@ -107,14 +107,14 @@ func (h registryHandlers) handleProjects(w http.ResponseWriter, r *http.Request)
writeJSON(w, http.StatusOK, items)
case http.MethodPost:
var req struct {
CustomerID int64 `json:"customer_id"`
CustomerID string `json:"customer_id"`
Name string `json:"name"`
}
if err := decodeJSON(r, &req); err != nil {
writeError(w, http.StatusBadRequest, err.Error())
return
}
if req.CustomerID <= 0 {
if req.CustomerID == "" {
writeError(w, http.StatusBadRequest, "customer_id is required")
return
}
@@ -175,8 +175,8 @@ func (h registryHandlers) handleAssets(w http.ResponseWriter, r *http.Request) {
writeJSON(w, http.StatusOK, items)
case http.MethodPost:
var req struct {
ProjectID int64 `json:"project_id"`
LocationID *int64 `json:"location_id"`
ProjectID string `json:"project_id"`
LocationID *string `json:"location_id"`
Name string `json:"name"`
Vendor *string `json:"vendor"`
Model *string `json:"model"`
@@ -187,7 +187,7 @@ func (h registryHandlers) handleAssets(w http.ResponseWriter, r *http.Request) {
writeError(w, http.StatusBadRequest, err.Error())
return
}
if req.ProjectID <= 0 {
if req.ProjectID == "" {
writeError(w, http.StatusBadRequest, "project_id is required")
return
}
@@ -207,7 +207,7 @@ func (h registryHandlers) handleAssets(w http.ResponseWriter, r *http.Request) {
Vendor: req.Vendor,
Model: req.Model,
VendorSerial: strings.TrimSpace(req.VendorSerial),
AssetTag: req.AssetTag,
MachineTag: req.AssetTag,
}
item, err := h.deps.Assets.Create(r.Context(), asset)
@@ -237,7 +237,7 @@ func (h registryHandlers) handleComponents(w http.ResponseWriter, r *http.Reques
writeJSON(w, http.StatusOK, items)
case http.MethodPost:
var req struct {
LotID *int64 `json:"lot_id"`
LotID *string `json:"lot_id"`
Vendor *string `json:"vendor"`
Model *string `json:"model"`
VendorSerial string `json:"vendor_serial"`