Migrate ingest and API paths to string IDs
This commit is contained in:
@@ -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"`
|
||||
|
||||
Reference in New Issue
Block a user