Add migration scripts, activity handler, and registry components for equipment, materials, and people

This commit is contained in:
2026-05-17 10:11:56 -04:00
parent fb67c76f45
commit 17e05cb61d
28 changed files with 3777 additions and 34 deletions
+38 -5
View File
@@ -20,6 +20,9 @@ func NewRouter(cfg *config.Config, db *sqlx.DB) http.Handler {
// Serve frontend static files
r.Handle("/*", http.FileServer(http.Dir("./web")))
// Public routes — uploads served without auth (paths are UUIDs, not guessable)
r.Handle("/uploads/*", http.StripPrefix("/uploads/", http.FileServer(http.Dir(cfg.UploadPath))))
// Public auth routes
auth := handlers.NewAuthHandler(db, cfg)
r.Post("/api/auth/login", auth.Login)
@@ -44,6 +47,7 @@ func NewRouter(cfg *config.Config, db *sqlx.DB) http.Handler {
r.Post("/api/work-orders/{id}/steps", step.Create)
r.Put("/api/work-orders/{id}/steps/{sid}", step.Update)
r.Post("/api/work-orders/{id}/steps/{sid}/complete", step.Complete)
r.Post("/api/work-orders/{id}/steps/{sid}/uncomplete", step.Uncomplete)
r.Delete("/api/work-orders/{id}/steps/{sid}", step.Delete)
res := handlers.NewResourceHandler(db)
@@ -55,17 +59,46 @@ func NewRouter(cfg *config.Config, db *sqlx.DB) http.Handler {
r.Get("/api/work-orders/{id}/attachments", att.List)
r.Post("/api/work-orders/{id}/attachments", att.Upload)
r.Delete("/api/work-orders/{id}/attachments/{aid}", att.Delete)
r.Handle("/uploads/*", http.StripPrefix("/uploads/", http.FileServer(http.Dir(cfg.UploadPath))))
acc := handlers.NewAccountingHandler(db)
r.Get("/api/work-orders/{id}/accounting", acc.Get)
r.Put("/api/work-orders/{id}/accounting", acc.Upsert)
act := handlers.NewActivityHandler(db)
r.Get("/api/work-orders/{id}/activity", act.List)
prof := handlers.NewProfileHandler(db)
r.Get("/api/profiles", prof.List)
r.Post("/api/profiles", prof.Create)
r.Get("/api/profiles/{id}", prof.Get)
r.Put("/api/profiles/{id}", prof.Update)
r.Delete("/api/profiles/{id}", prof.Delete)
r.Get("/api/profiles/{id}/steps", prof.ListSteps)
r.Post("/api/profiles/{id}/steps", prof.CreateStep)
r.Put("/api/profiles/{id}/steps/{sid}", prof.UpdateStep)
r.Delete("/api/profiles/{id}/steps/{sid}", prof.DeleteStep)
r.Post("/api/work-orders/{id}/apply-profile/{profileId}", prof.Apply)
reg := handlers.NewRegistryHandler(db)
r.Get("/api/registry/people", reg.People)
r.Get("/api/registry/vehicles", reg.Vehicles)
r.Get("/api/registry/equipment", reg.Equipment)
r.Get("/api/registry/materials", reg.Materials)
r.Get("/api/registry/people", reg.ListPeople)
r.Post("/api/registry/people", reg.CreatePerson)
r.Put("/api/registry/people/{id}", reg.UpdatePerson)
r.Delete("/api/registry/people/{id}", reg.DeletePerson)
r.Get("/api/registry/vehicles", reg.ListVehicles)
r.Post("/api/registry/vehicles", reg.CreateVehicle)
r.Put("/api/registry/vehicles/{id}", reg.UpdateVehicle)
r.Delete("/api/registry/vehicles/{id}", reg.DeleteVehicle)
r.Get("/api/registry/equipment", reg.ListEquipment)
r.Post("/api/registry/equipment", reg.CreateEquipment)
r.Put("/api/registry/equipment/{id}", reg.UpdateEquipment)
r.Delete("/api/registry/equipment/{id}", reg.DeleteEquipment)
r.Get("/api/registry/materials", reg.ListMaterials)
r.Post("/api/registry/materials", reg.CreateMaterial)
r.Put("/api/registry/materials/{id}", reg.UpdateMaterial)
r.Delete("/api/registry/materials/{id}", reg.DeleteMaterial)
})
return r