Skip to content

feat: add uploader_role to ticket attachments - #66

Merged
ikennot merged 1 commit into
developmentfrom
feat/admin-assign
Apr 14, 2026
Merged

feat: add uploader_role to ticket attachments#66
ikennot merged 1 commit into
developmentfrom
feat/admin-assign

Conversation

@ikennot

@ikennot ikennot commented Apr 14, 2026

Copy link
Copy Markdown
Owner

Type of Change

  • feat — new feature

Labels

p3-low feat backend

What Changed

  • Added uploader_role field (VARCHAR(20)) to the ticket_attachment table via Flyway migration V14__add_uploader_role_to_attachment.sql
  • Added uploaderRole to the TicketAttachment entity
  • AttachmentService now persists the uploader's role when saving a new attachment
  • AttachmentResponse DTO exposes uploaderRole in API responses

Why

Allows consumers (admin UI, analytics) to distinguish whether an attachment was uploaded by a student, staff, or admin without joining the users table on every query.

How to Test

  1. Submit a ticket attachment as a student — verify uploaderRole is "STUDENT" in the response
  2. Upload an attachment as an admin — verify uploaderRole reflects the admin role
  3. Run ./mvnw test — all existing tests should pass

Related Issues

Screenshots

Checklist

  • Code follows the Google Java Style Guide
  • No business logic in controllers
  • Ownership + role checks are in the service layer
  • All responses use ApiResponse<T> wrapper
  • No secrets or credentials committed
  • application.yaml is NOT staged
  • CI passes

Summary by CodeRabbit

  • New Features
    • Added uploader role tracking for attachments. Attachment metadata now includes the role of the user who uploaded it.

@coderabbitai

coderabbitai Bot commented Apr 14, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c489800b-617c-4668-b9c4-1e497b4a4db0

📥 Commits

Reviewing files that changed from the base of the PR and between 100c6ff and f56c0f0.

📒 Files selected for processing (4)
  • src/main/java/com/ucms_backend/dto/AttachmentResponse.java
  • src/main/java/com/ucms_backend/model/entity/TicketAttachment.java
  • src/main/java/com/ucms_backend/service/AttachmentService.java
  • src/main/resources/db/migration/V14__add_uploader_role_to_attachment.sql

📝 Walkthrough

Walkthrough

This pull request adds uploader role tracking to ticket attachments. A new uploaderRole field is introduced in the entity, persisted to the database, captured during upload from the current user's role, and exposed in the API response.

Changes

Cohort / File(s) Summary
Entity & DTO Updates
src/main/java/com/ucms_backend/model/entity/TicketAttachment.java, src/main/java/com/ucms_backend/dto/AttachmentResponse.java
Added uploaderRole field to entity with JPA mapping to uploader_role column (max 20 chars) and corresponding field in response DTO with factory method population.
Service Logic
src/main/java/com/ucms_backend/service/AttachmentService.java
Updated uploadAttachment method to capture and set the current user's role on the attachment builder.
Database Schema
src/main/resources/db/migration/V14__add_uploader_role_to_attachment.sql
Added nullable uploader_role VARCHAR(20) column to ticket_attachment table with existence guard.

Sequence Diagram

sequenceDiagram
    participant User as User/Client
    participant Service as AttachmentService
    participant Entity as TicketAttachment
    participant DB as Database
    participant DTO as AttachmentResponse

    User->>Service: uploadAttachment(file, user.role)
    Service->>Entity: builder().uploaderRole(user.role)
    Service->>DB: save(attachment)
    DB->>DB: INSERT with uploader_role
    Service->>DTO: AttachmentResponse.from(attachment, signedUrl)
    DTO->>DTO: populate uploaderRole field
    DTO-->>User: Response with uploaderRole
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A rabbit's attachment now wears a fine role,
Recording who uploaded, that's quite a goal!
From service to storage, the role takes its place,
Users will see it displayed with such grace! 🎀

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding an uploader_role field to ticket attachments across the entity, DTO, service, and database layers.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/admin-assign

Comment @coderabbitai help to get the list of available commands and usage tips.

@ikennot
ikennot merged commit 136ce8b into development Apr 14, 2026
2 checks 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