feat: add case + party CRUD with case events (Phase 1B)
- CaseService: list (paginated, filterable), get detail (with parties, events, deadline count), create, update, soft-delete (archive) - PartyService: list by case, create, update, delete - Auto-create case_events on case creation, status change, party add, and case archive - Auth middleware now resolves tenant_id from user_tenants table - All operations scoped to tenant_id from auth context
This commit is contained in:
@@ -5,6 +5,8 @@ import (
|
||||
"net/http"
|
||||
|
||||
"mgit.msbls.de/m/KanzlAI-mGMT/internal/auth"
|
||||
"mgit.msbls.de/m/KanzlAI-mGMT/internal/handlers"
|
||||
"mgit.msbls.de/m/KanzlAI-mGMT/internal/services"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
)
|
||||
@@ -12,12 +14,34 @@ import (
|
||||
func New(db *sqlx.DB, authMW *auth.Middleware) http.Handler {
|
||||
mux := http.NewServeMux()
|
||||
|
||||
// Services
|
||||
caseSvc := services.NewCaseService(db)
|
||||
partySvc := services.NewPartyService(db)
|
||||
|
||||
// Handlers
|
||||
caseH := handlers.NewCaseHandler(caseSvc)
|
||||
partyH := handlers.NewPartyHandler(partySvc)
|
||||
|
||||
// Public routes
|
||||
mux.HandleFunc("GET /health", handleHealth(db))
|
||||
|
||||
// Authenticated API routes
|
||||
api := http.NewServeMux()
|
||||
api.HandleFunc("GET /api/cases", placeholder("cases"))
|
||||
|
||||
// Cases
|
||||
api.HandleFunc("GET /api/cases", caseH.List)
|
||||
api.HandleFunc("POST /api/cases", caseH.Create)
|
||||
api.HandleFunc("GET /api/cases/{id}", caseH.Get)
|
||||
api.HandleFunc("PUT /api/cases/{id}", caseH.Update)
|
||||
api.HandleFunc("DELETE /api/cases/{id}", caseH.Delete)
|
||||
|
||||
// Parties (nested under cases for creation/listing, top-level for update/delete)
|
||||
api.HandleFunc("GET /api/cases/{id}/parties", partyH.List)
|
||||
api.HandleFunc("POST /api/cases/{id}/parties", partyH.Create)
|
||||
api.HandleFunc("PUT /api/parties/{partyId}", partyH.Update)
|
||||
api.HandleFunc("DELETE /api/parties/{partyId}", partyH.Delete)
|
||||
|
||||
// Placeholder routes for future phases
|
||||
api.HandleFunc("GET /api/deadlines", placeholder("deadlines"))
|
||||
api.HandleFunc("GET /api/appointments", placeholder("appointments"))
|
||||
api.HandleFunc("GET /api/documents", placeholder("documents"))
|
||||
|
||||
Reference in New Issue
Block a user