Initialize work order management system with database schema, API handlers, web client, and Docker configuration.

This commit is contained in:
2026-05-16 16:15:53 -04:00
parent c135722339
commit f904431ec3
28 changed files with 2171 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
package handlers
import (
"net/http"
"github.com/jmoiron/sqlx"
"workorders/internal/model"
)
type RegistryHandler struct{ db *sqlx.DB }
func NewRegistryHandler(db *sqlx.DB) *RegistryHandler { return &RegistryHandler{db: db} }
func (h *RegistryHandler) People(w http.ResponseWriter, r *http.Request) {
var rows []model.RegistryPerson
h.db.Select(&rows, `SELECT id,name,role,email,phone FROM resource_people WHERE active=1 ORDER BY name`)
respond(w, http.StatusOK, rows)
}
func (h *RegistryHandler) Vehicles(w http.ResponseWriter, r *http.Request) {
var rows []model.RegistryVehicle
h.db.Select(&rows, `SELECT id,unit_number,description,vehicle_type FROM resource_vehicles WHERE active=1 ORDER BY unit_number`)
respond(w, http.StatusOK, rows)
}
func (h *RegistryHandler) Equipment(w http.ResponseWriter, r *http.Request) {
var rows []model.RegistryEquipment
h.db.Select(&rows, `SELECT id,name,asset_tag,category FROM resource_equipment WHERE active=1 ORDER BY name`)
respond(w, http.StatusOK, rows)
}
func (h *RegistryHandler) Materials(w http.ResponseWriter, r *http.Request) {
var rows []model.RegistryMaterial
h.db.Select(&rows, `SELECT id,name,unit,part_number FROM resource_materials WHERE active=1 ORDER BY name`)
respond(w, http.StatusOK, rows)
}