feat(tickets): management CRUD for ticket status/priority/type/queue/category lookups #239
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/PMS-321-ticket-lookup-crud"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds management (create/update/delete) endpoints for the four ticket lookup tables (statuses, priorities, types, queues) and full list/create/update/delete for the previously route-less
ticket_categoriestable, mounted under/api/v1/tickets/*. Read GET handlers are unchanged. This is the server half that unblocks the MAPPS Settings-hub ticket-lookup editors (MAPPS-172).What changed
POST /tickets/{statuses,priorities,types,queues}+PUT/DELETEon/{id};GET/POST /tickets/categories+PUT/DELETE /tickets/categories/{id}.mokosh-types:Upsert{Status,Priority,Type,Queue,Category}Request, plusTicketCategoryandTicketCategoryResponse.TicketServicegains create/update/delete for each lookup and list/CRUD for categories, mirroring the asset-type CRUD shape.Behavior / guarantees
RequireAdmin), consistent with the asset-type write routes; reads stay onRequireAuth.migrations/005_tickets.sql, so an over-long value is a 400 here rather than a 500 from Postgres.sla_multiplieris range-checked to fitDECIMAL(3, 2).is_defaultlookups (statuses, priorities, queues), setting a new default clears the prior default in the same transaction, so a tenant never carries two defaults.parent_idmust reference a category in the same tenant, and a category may not be its own parent.Tests
Integration coverage added in
tests/tickets.rs(all green against a throwaway Postgres, mirroring CIintegration.yml): status CRUD lifecycle + re-delete 404, new-default-clears-prior, delete-referenced-returns-409, category create/child/parent-validation (cross-tenant + self-parent rejection), and non-admin-forbidden.cargo fmt --checkandclippy --all-targets -D warningsclean.Notes
Cargo.lockcarries a one-line correction bumping the stalemokosh-serverentry0.2.0 -> 0.3.0to matchCargo.tomlafter the v0.3.0 release; the build regenerated it.#PMS-321
Add create/update/delete endpoints for the four ticket lookup tables (statuses, priorities, types, queues) plus full list/create/update/delete for the previously route-less ticket_categories table, mounted under /api/v1/tickets/*. The read GET handlers are unchanged. Each mutation validates field lengths against the column widths in migrations/005_tickets.sql, is tenant-scoped, and is admin-gated via RequireAdmin (matching the asset-type write routes). For the is_default lookups (statuses, priorities, queues) setting a new default clears the prior default in the same transaction so a tenant never carries two defaults. Deleting a lookup still referenced by a ticket or child record is mapped from the FK violation (SQLSTATE 23503) to a 409 instead of a 500, and a category parent_id must reference a category in the same tenant (a category may not be its own parent). New shared DTOs live in mokosh-types: Upsert{Status,Priority,Type,Queue,Category}Request plus TicketCategory and TicketCategoryResponse. Integration coverage in tests/tickets.rs: status CRUD lifecycle + re-delete 404, new-default-clears-prior, delete-referenced-returns-409, category create/child/parent-validation, and non-admin-forbidden. #PMS-321 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>