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/project_items.go Normal file
View File

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