Started with items

This commit is contained in:
2026-06-03 14:24:14 +02:00
parent 78731c1728
commit 0a44df319d
9 changed files with 279 additions and 24 deletions

34
handlers/stock.go Normal file
View File

@@ -0,0 +1,34 @@
package handlers
import (
"MiauInv/storage"
"encoding/json"
"net/http"
)
type StockRequest struct {
ItemID int `json:"item_id"`
LocationID int `json:"location_id"`
Quantity int `json:"quantity"`
}
func AddStock(w http.ResponseWriter, r *http.Request) {
var req StockRequest
json.NewDecoder(r.Body).Decode(&req)
_, err := storage.DB.Exec(`
INSERT INTO stock(item_id,location_id,quantity)
VALUES(?,?,?)
`,
req.ItemID,
req.LocationID,
req.Quantity,
)
if err != nil {
http.Error(w, err.Error(), 500)
return
}
}