Skip to content

implement ResultComplaint aggregate with CQRS pattern and paginated API

Давид Анастасов requested to merge merge-branch-for-aggregates into dev

Core Domain Model:

  • Create ResultComplaint aggregate root with command and event handling
  • Implement value objects: ComplaintId, ExamResultId, StudentIndex, ComplaintDescription, ComplaintStatus
  • Add CreateResultComplaintCommand for aggregate creation
  • Add ResultComplaintCreatedEvent for event sourcing

Infrastructure & Persistence:

  • Create ResultComplaintRepository for aggregate persistence
  • Implement ResultComplaintView as immutable read-only entity using @Subselect
  • Enable JPA auditing with @EnableJpaAuditing on application class
  • Update BasicAudit to use Instant with @CreatedDate/@LastModifiedDate
  • Fix H2 reserved keyword issue by mapping description to description_text column

REST API:

  • Create ResultComplaintController with POST and GET endpoints
  • Implement CreateResultComplaintDto for request payload validation
  • Implement ResultComplaintResponseDto for response serialization
  • Implement PaginatedResponseDto generic wrapper for paginated responses

Service Layer (CQRS):

  • Split services into ResultComplaintService (commands) and ResultComplaintViewService (queries)
  • Implement pagination with configurable page, size, sort, and direction
  • Service handles PageRequest creation for cleaner controller code

API Endpoints:

  • POST /api/result-complaints - Create new complaint
  • GET /api/result-complaints?page=0&size=10&sort=dateCreated&direction=DESC
    • Fetch paginated complaints with flexible sorting

Merge request reports

Loading