Skip to content

Implement ticket management and refactor exception handling - #4

Merged
shmoonwalker merged 4 commits into
mainfrom
feature/ticket-api
Jun 17, 2026
Merged

Implement ticket management and refactor exception handling#4
shmoonwalker merged 4 commits into
mainfrom
feature/ticket-api

Conversation

@shmoonwalker

Copy link
Copy Markdown
Owner

Summary

Implemented and improved core API functionality for users and tickets in the Ticket Tracking System.

This PR adds full CRUD support for users and tickets, ticket assignment functionality, DTO-based API responses, validation, and centralized error handling.

Changes

Users

  • Added create, read, update, and delete functionality for users.
  • Added request DTOs for user creation and update.
  • Added UserResponse DTO to avoid returning internal model objects directly.
  • Added duplicate email validation.
  • Added proper not-found handling for missing users.

Tickets

  • Added create, read, update, and delete functionality for tickets.
  • Added request DTOs for ticket creation and update.
  • Added TicketResponse DTO including assigned user IDs.
  • Added validation for required fields such as title, project ID, and status.
  • Added project existence validation before creating or updating tickets.
  • Updated ticket responses to include real assigned user IDs from the user_ticket table.
  • Moved response mapping logic into the service layer for cleaner controller responsibilities.

Ticket Assignees

  • Added endpoint to assign a user to a ticket.
  • Added endpoint to remove a user from a ticket.
  • Added validation to check whether ticket and user exist before assignment.
  • Added duplicate assignment prevention.
  • Added database support through the user_ticket junction table.

Error Handling

  • Added centralized GlobalExceptionHandler.

  • Added structured error responses using ErrorResponse.

  • Added handling for:

    • resource not found errors
    • duplicate email errors
    • validation errors
    • invalid request bodies
    • database constraint violations
    • illegal arguments such as duplicate ticket assignments

Testing

Tested with Postman:

  • POST /users
  • GET /users
  • GET /users/{id}
  • PUT /users/{id}
  • DELETE /users/{id}
  • POST /tickets
  • GET /tickets
  • GET /tickets/{id}
  • PUT /tickets/{id}
  • DELETE /tickets/{id}
  • POST /tickets/{ticketId}/assignees/{userId}
  • DELETE /tickets/{ticketId}/assignees/{userId}

Also tested error scenarios:

  • creating a user with a duplicate email
  • requesting non-existing users or tickets
  • creating/updating tickets with invalid project IDs
  • assigning the same user to the same ticket twice
  • sending invalid request bodies
  • sending invalid validation data

@shmoonwalker
shmoonwalker merged commit ab2f5ae into main Jun 17, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant