Skip to content

MOSU-155 refactor: 엔티티 softDelete 적용 및 cursor 기반 페이지네이션 구현 #164

Merged
chominju02 merged 10 commits intodevelopfrom
refactor/mosu-155
Jul 29, 2025
Merged

MOSU-155 refactor: 엔티티 softDelete 적용 및 cursor 기반 페이지네이션 구현 #164
chominju02 merged 10 commits intodevelopfrom
refactor/mosu-155

Conversation

@chominju02
Copy link
Contributor

@chominju02 chominju02 commented Jul 29, 2025

✨ 구현한 기능

📢 논의하고 싶은 내용

🎸 기타

Summary by CodeRabbit

  • New Features

    • Introduced cursor-based pagination for event listings, allowing users to navigate through events efficiently.
    • Added new endpoints and support for cursor-based pagination in event-related APIs.
  • Improvements

    • Enhanced soft delete support across multiple entities, enabling safer data management without permanent removal.
    • Updated exam management with stricter admin-only access for registration and deletion.
  • Removals

    • Attachment handling for events, notices, and inquiries has been disabled, so related files may no longer be managed or displayed.
    • Removed support for displaying attachments in notice and event responses.
  • Bug Fixes

    • Improved handling of missing file data to prevent errors when file information is absent.
  • Other Changes

    • Various internal optimizations and refactoring to support new pagination and data management logic.

@chominju02 chominju02 self-assigned this Jul 29, 2025
@coderabbitai
Copy link

coderabbitai bot commented Jul 29, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This update introduces cursor-based pagination for event listings, adds soft-delete support to numerous entities, and removes or disables attachment-related logic for events and notices. Several domain classes are refactored to change their inheritance hierarchy, and new classes and annotations are added to support cursor pagination. Attachment entities and services for events are commented out or deleted, and security is tightened for exam-related endpoints.

Changes

Cohort / File(s) Change Summary
Event Attachment Removal
src/main/java/life/mosu/mosuserver/application/event/EventAttachmentService.java, src/main/java/life/mosu/mosuserver/domain/event/EventAttachmentJpaEntity.java, src/main/java/life/mosu/mosuserver/domain/event/EventAttachmentRepository.java, src/main/java/life/mosu/mosuserver/domain/event/projection/EventWithAttachmentProjection.java, src/main/java/life/mosu/mosuserver/presentation/common/FileRequest.java
All event attachment-related classes and methods are commented out or removed, disabling attachment handling for events.
Event Pagination & Refactor
src/main/java/life/mosu/mosuserver/application/event/EventService.java, src/main/java/life/mosu/mosuserver/domain/event/EventJpaEntity.java, src/main/java/life/mosu/mosuserver/domain/event/EventJpaRepository.java, src/main/java/life/mosu/mosuserver/domain/event/EventQueryRepository.java, src/main/java/life/mosu/mosuserver/infra/persistence/jpa/EventQueryRepositoryImpl.java, src/main/java/life/mosu/mosuserver/presentation/event/EventController.java, src/main/java/life/mosu/mosuserver/presentation/event/dto/EventRequest.java, src/main/java/life/mosu/mosuserver/presentation/event/dto/EventResponse.java, src/main/java/life/mosu/mosuserver/global/annotation/CursorParam.java, src/main/java/life/mosu/mosuserver/global/support/Cursor.java, src/main/java/life/mosu/mosuserver/global/support/CursorArgumentResolver.java, src/main/java/life/mosu/mosuserver/global/support/CursorResponse.java
Implements cursor-based pagination for events, introduces supporting classes and annotations, refactors event entity to use file fields, and updates controller/service signatures accordingly.
Attachment Handling Disabled for Notices and Inquiries
src/main/java/life/mosu/mosuserver/application/notice/NoticeAttachmentService.java, src/main/java/life/mosu/mosuserver/application/notice/NoticeService.java, src/main/java/life/mosu/mosuserver/presentation/notice/NoticeController.java, src/main/java/life/mosu/mosuserver/presentation/notice/dto/NoticeResponse.java, src/main/java/life/mosu/mosuserver/application/inquiry/InquiryService.java, src/main/java/life/mosu/mosuserver/application/inquiry/InquiryAnswerService.java
Disables or removes logic for deleting or returning attachments with notices and inquiries. Notice and inquiry responses no longer include attachment data.
Banner Attachment Response Update
src/main/java/life/mosu/mosuserver/application/admin/AdminBannerService.java, src/main/java/life/mosu/mosuserver/presentation/admin/dto/BannerInfoResponse.java
Banner info now uses an AttachmentResponse for image data, with null checks for S3 keys and updated factory methods.
Exam Entity & Controller Updates
src/main/java/life/mosu/mosuserver/application/exam/ExamService.java, src/main/java/life/mosu/mosuserver/presentation/exam/ExamController.java
Adds exam deletion, updates application count logic, and enforces admin-only access for create/delete endpoints.
Domain Entity Inheritance and Soft Delete
src/main/java/life/mosu/mosuserver/domain/application/ApplicationJpaEntity.java, src/main/java/life/mosu/mosuserver/domain/base/BaseDeleteEntity.java, src/main/java/life/mosu/mosuserver/domain/base/BaseTimeEntity.java, src/main/java/life/mosu/mosuserver/domain/exam/ExamJpaEntity.java, src/main/java/life/mosu/mosuserver/domain/examapplication/ExamApplicationJpaEntity.java, src/main/java/life/mosu/mosuserver/domain/examapplication/ExamSubjectJpaEntity.java, src/main/java/life/mosu/mosuserver/domain/faq/FaqJpaEntity.java, src/main/java/life/mosu/mosuserver/domain/file/File.java, src/main/java/life/mosu/mosuserver/domain/file/FileWithTime.java, src/main/java/life/mosu/mosuserver/domain/inquiry/InquiryJpaEntity.java, src/main/java/life/mosu/mosuserver/domain/inquiryAnswer/InquiryAnswerJpaEntity.java, src/main/java/life/mosu/mosuserver/domain/notice/NoticeJpaEntity.java, src/main/java/life/mosu/mosuserver/domain/notify/NotifyJpaEntity.java, src/main/java/life/mosu/mosuserver/domain/payment/PaymentJpaEntity.java, src/main/java/life/mosu/mosuserver/domain/profile/ProfileJpaEntity.java, src/main/java/life/mosu/mosuserver/domain/recommendation/RecommendationJpaEntity.java, src/main/java/life/mosu/mosuserver/domain/refund/RefundJpaEntity.java, src/main/java/life/mosu/mosuserver/domain/user/UserJpaEntity.java
Adds or removes soft delete annotations, changes base classes for several entities, and updates file-related base classes.
Deleted Entity Classes
src/main/java/life/mosu/mosuserver/domain/event/EventImage.java, src/main/java/life/mosu/mosuserver/domain/file/AdmissionTicketFileEntity.java, src/main/java/life/mosu/mosuserver/domain/school/SchoolLunchJpaRepository.java
Removes unused or obsolete entity classes and repositories.
Exam Application Bulk Insert Update
src/main/java/life/mosu/mosuserver/infra/persistence/jpa/ExamApplicationBulkRepository.java
Removes the is_deleted column from bulk insert SQL and disables related parameter binding.
Minor Import Cleanups
src/main/java/life/mosu/mosuserver/domain/inquiry/InquiryAttachmentJpaEntity.java, src/main/java/life/mosu/mosuserver/domain/inquiryAnswer/InquiryAnswerAttachmentEntity.java
Removes unused imports related to soft delete.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant EventController
    participant EventService
    participant EventQueryRepository
    participant CursorResponse

    Client->>EventController: GET /events?id={cursor}
    EventController->>EventService: getEvents(cursor.id)
    EventService->>EventQueryRepository: findAllByCursorId(cursor.id)
    EventQueryRepository-->>EventService: Slice<EventJpaEntity>
    EventService->>CursorResponse: of(slice, nextCursor)
    CursorResponse-->>EventService: CursorResponse<EventResponse>
    EventService-->>EventController: CursorResponse<EventResponse>
    EventController-->>Client: ApiResponseWrapper<CursorResponse<EventResponse>>
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~40 minutes

Suggested labels

우선순위 중

Poem

A cursor hops from event to event,
Soft deletes now leave a gentle dent.
Attachments have hopped away for now,
Security’s stricter—admins take a bow.
Entities reshaped, with code made clean,
The garden’s pruned for a future serene.
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ea50123 and 3e999be.

📒 Files selected for processing (51)
  • src/main/java/life/mosu/mosuserver/application/admin/AdminBannerService.java (2 hunks)
  • src/main/java/life/mosu/mosuserver/application/event/EventAttachmentService.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/application/event/EventService.java (3 hunks)
  • src/main/java/life/mosu/mosuserver/application/exam/ExamService.java (3 hunks)
  • src/main/java/life/mosu/mosuserver/application/inquiry/InquiryAnswerService.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/application/inquiry/InquiryService.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/application/notice/NoticeAttachmentService.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/application/notice/NoticeService.java (4 hunks)
  • src/main/java/life/mosu/mosuserver/domain/application/ApplicationJpaEntity.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/base/BaseDeleteEntity.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/base/BaseTimeEntity.java (0 hunks)
  • src/main/java/life/mosu/mosuserver/domain/event/EventAttachmentJpaEntity.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/event/EventAttachmentRepository.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/event/EventImage.java (0 hunks)
  • src/main/java/life/mosu/mosuserver/domain/event/EventJpaEntity.java (2 hunks)
  • src/main/java/life/mosu/mosuserver/domain/event/EventJpaRepository.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/event/EventQueryRepository.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/event/projection/EventWithAttachmentProjection.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/exam/ExamJpaEntity.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/examapplication/ExamApplicationJpaEntity.java (3 hunks)
  • src/main/java/life/mosu/mosuserver/domain/examapplication/ExamSubjectJpaEntity.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/faq/FaqJpaEntity.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/file/AdmissionTicketFileEntity.java (0 hunks)
  • src/main/java/life/mosu/mosuserver/domain/file/File.java (2 hunks)
  • src/main/java/life/mosu/mosuserver/domain/file/FileWithTime.java (2 hunks)
  • src/main/java/life/mosu/mosuserver/domain/inquiry/InquiryAttachmentJpaEntity.java (0 hunks)
  • src/main/java/life/mosu/mosuserver/domain/inquiry/InquiryJpaEntity.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/inquiryAnswer/InquiryAnswerAttachmentEntity.java (0 hunks)
  • src/main/java/life/mosu/mosuserver/domain/inquiryAnswer/InquiryAnswerJpaEntity.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/notice/NoticeJpaEntity.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/notify/NotifyJpaEntity.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/payment/PaymentJpaEntity.java (2 hunks)
  • src/main/java/life/mosu/mosuserver/domain/profile/ProfileJpaEntity.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/recommendation/RecommendationJpaEntity.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/domain/refund/RefundJpaEntity.java (2 hunks)
  • src/main/java/life/mosu/mosuserver/domain/school/SchoolLunchJpaRepository.java (0 hunks)
  • src/main/java/life/mosu/mosuserver/domain/user/UserJpaEntity.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/global/annotation/CursorParam.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/global/support/Cursor.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/global/support/CursorArgumentResolver.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/global/support/CursorResponse.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/infra/persistence/jpa/EventQueryRepositoryImpl.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/infra/persistence/jpa/ExamApplicationBulkRepository.java (2 hunks)
  • src/main/java/life/mosu/mosuserver/presentation/admin/dto/BannerInfoResponse.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/presentation/common/FileRequest.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/presentation/event/EventController.java (3 hunks)
  • src/main/java/life/mosu/mosuserver/presentation/event/dto/EventRequest.java (2 hunks)
  • src/main/java/life/mosu/mosuserver/presentation/event/dto/EventResponse.java (2 hunks)
  • src/main/java/life/mosu/mosuserver/presentation/exam/ExamController.java (3 hunks)
  • src/main/java/life/mosu/mosuserver/presentation/notice/NoticeController.java (1 hunks)
  • src/main/java/life/mosu/mosuserver/presentation/notice/dto/NoticeResponse.java (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch refactor/mosu-155

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @chominju02, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

I've refactored the application to introduce a comprehensive soft delete mechanism across various entities, centralizing the logic for better maintainability. Concurrently, I've implemented cursor-based pagination for event listings, which significantly improves performance for large datasets. Additionally, I've streamlined the handling of event attachments by embedding file information directly into the event entity, simplifying the data model and related service interactions. These changes contribute to a more robust and efficient backend system.

Highlights

  • Centralized Soft Delete Implementation: I've implemented soft deletion across many core entities by centralizing the logic in a new BaseDeleteEntity. This entity now handles both the deleted flag and auditing timestamps (createdAt, updatedAt), allowing BaseTimeEntity to focus solely on general timestamps. This change impacts entities like Application, Event, Exam, Inquiry, Notice, Payment, Profile, Refund, and User.
  • Migration to Cursor-Based Pagination for Events: I've refactored the event listing functionality to use cursor-based pagination instead of traditional offset-based pagination. This involved introducing new Cursor, CursorResponse, and CursorParam components, along with a dedicated EventQueryRepositoryImpl using QueryDSL for efficient data retrieval. This approach is generally more performant for large datasets as it avoids the performance issues associated with OFFSET clauses.
  • Streamlined Event Attachment Management: I've streamlined how event attachments are handled. Instead of using separate EventAttachmentJpaEntity and EventAttachmentService, the file name and S3 key for event images are now directly embedded within the EventJpaEntity. This simplifies the data model and reduces the overhead of managing separate attachment entities for events.
  • Enhanced Admin Functionality for Exams: I've added a new DELETE endpoint for exams, allowing administrators to remove exam entries. This endpoint is secured with @PreAuthorize to ensure only authenticated users with the 'ADMIN' role can perform this operation.
  • Code Cleanup and Refinement: I've performed a general cleanup of various attachment-related services and DTOs across the application, commenting out or removing deprecated code paths that are no longer needed due to the new attachment handling strategy and soft delete implementation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments or fill out our survey to provide feedback.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@chominju02 chominju02 merged commit 4ec950c into develop Jul 29, 2025
1 of 2 checks passed
@chominju02 chominju02 deleted the refactor/mosu-155 branch July 29, 2025 11:51
Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request is a significant refactoring that introduces soft-deletes across many entities and implements cursor-based pagination for the events list, which are great improvements. The overall implementation is solid, but there are a few critical areas that need attention. Several entities that were updated to support soft-deletes are missing the required @SoftDelete annotation, which will cause them to be hard-deleted. There is also a critical bug in the new CursorArgumentResolver that will prevent the cursor-based pagination from working correctly. Additionally, a number of files and code blocks have been commented out instead of being removed, which affects code clarity. I've provided specific comments and suggestions to address these points.

Comment on lines +29 to +35
String cursorJson = webRequest.getParameter("id");

if (cursorJson == null || cursorJson.isBlank()) {
return Cursor.empty();
}

return objectMapper.readValue(cursorJson, Cursor.class);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

critical

The implementation of resolveArgument is incorrect and will cause a runtime exception. webRequest.getParameter("id") returns a raw string value (e.g., "123"), not a JSON string. objectMapper.readValue will fail when trying to parse this plain string into a Cursor object. The implementation should parse the string to a Long and then create the Cursor object.

        String cursorIdStr = webRequest.getParameter("id");

        if (cursorIdStr == null || cursorIdStr.isBlank()) {
            return Cursor.empty();
        }

        try {
            return Cursor.of(Long.parseLong(cursorIdStr));
        } catch (NumberFormatException e) {
            throw new IllegalArgumentException("Invalid cursor 'id' format. Must be a number.", e);
        }

Comment on lines +75 to 76
// answerAttachmentService.deleteAttachment(answerEntity);
answerAttachmentService.createAttachment(request.attachments(), answerEntity);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The logic for updating attachments is incorrect after the changes. By commenting out answerAttachmentService.deleteAttachment(answerEntity), old attachments will no longer be removed when new ones are provided during an update. This will lead to an accumulation of attachments for the same answer over multiple updates, creating data inconsistencies. The line to delete old attachments should be restored to ensure that only the latest attachments are associated with the answer.

Suggested change
// answerAttachmentService.deleteAttachment(answerEntity);
answerAttachmentService.createAttachment(request.attachments(), answerEntity);
answerAttachmentService.deleteAttachment(answerEntity);
answerAttachmentService.createAttachment(request.attachments(), answerEntity);

Comment on lines 15 to +19
@Entity
@Table(name = "application")
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@SoftDelete
public class ApplicationJpaEntity extends BaseTimeEntity {
public class ApplicationJpaEntity extends BaseDeleteEntity {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The @SoftDelete annotation is missing from this entity. While it now extends BaseDeleteEntity, which provides the deleted flag, Hibernate's soft delete mechanism is only activated by the @SoftDelete annotation on the entity class itself. Without it, any delete operation on this entity will result in a hard delete from the database, which goes against the main goal of this pull request.

Suggested change
@Entity
@Table(name = "application")
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@SoftDelete
public class ApplicationJpaEntity extends BaseTimeEntity {
public class ApplicationJpaEntity extends BaseDeleteEntity {
@Entity
@Table(name = "application")
@Getter
@NoArgsConstructor(access = AccessLevel.PROTECTED)
@SoftDelete
public class ApplicationJpaEntity extends BaseDeleteEntity {

Comment on lines +30 to +37
public static String formatDate(LocalDateTime dateTime) {
return dateTime != null ? dateTime.toLocalDate().toString() : null;
}

public String getCreatedAt() {
return createdAt != null ? createdAt.format(
DateTimeFormatter.ofPattern("yyyy-MM-dd")) : null;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The formatDate and getCreatedAt methods are responsible for date formatting, which is a presentation-layer concern. To maintain a clean architecture and good separation of concerns, this logic should be moved out of the domain entity. Consider placing formatting logic within DTOs or a dedicated utility class.

Comment on lines +1 to +38
//package life.mosu.mosuserver.domain.event;
//
//import jakarta.persistence.Column;
//import jakarta.persistence.Entity;
//import jakarta.persistence.GeneratedValue;
//import jakarta.persistence.GenerationType;
//import jakarta.persistence.Id;
//import jakarta.persistence.Table;
//import life.mosu.mosuserver.domain.file.File;
//import life.mosu.mosuserver.domain.file.Visibility;
//import lombok.Builder;
//import lombok.Getter;
//import lombok.RequiredArgsConstructor;
//
//@Entity
//@RequiredArgsConstructor
//@Getter
//@Table(name = "event_attachment")
//public class EventAttachmentJpaEntity extends File {
//
// @Id
// @GeneratedValue(strategy = GenerationType.IDENTITY)
// @Column(name = "event_attachment_id", nullable = false)
// private Long id;
//
// @Column(name = "event_id", nullable = false)
// private Long eventId;
//
// @Builder
// public EventAttachmentJpaEntity(final String fileName, final String s3Key,
// final Visibility visibility, final Long eventId) {
// super(fileName, s3Key, visibility);
// this.eventId = eventId;
// }
//
// protected void updateFile()
//
//}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This entire file has been commented out. If this class is no longer needed as part of the refactoring, the file should be deleted from the project instead of being left as commented-out code. This improves codebase cleanliness and maintainability.

Comment on lines +1 to +12
//package life.mosu.mosuserver.domain.event;
//
//import java.util.Optional;
//import org.springframework.data.jpa.repository.JpaRepository;
//
//public interface EventAttachmentRepository extends JpaRepository<EventAttachmentJpaEntity, Long> {
//
// void deleteByEventId(Long eventId);
//
// Optional<EventAttachmentJpaEntity> findByEventId(Long eventId);
//}
//

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This repository interface is fully commented out. It should be deleted from the source tree if it's no longer in use to keep the project clean.

Comment on lines +7 to +40
// @Query("""
// select new life.mosu.mosuserver.domain.event.projection.EventWithAttachmentProjection(
// e.id,
// e.title,
// e.duration.endDate,
// e.eventLink,
// new life.mosu.mosuserver.domain.event.projection.AttachmentProjection(
// ea.fileName,
// ea.s3Key
// )
// )
// from EventJpaEntity e
// left join EventAttachmentJpaEntity ea
// on e.id = ea.eventId
// """)
// List<EventWithAttachmentProjection> findAllWithAttachment();

@Query("""
select new life.mosu.mosuserver.domain.event.projection.EventWithAttachmentProjection(
e.id,
e.title,
e.duration.endDate,
e.eventLink,
new life.mosu.mosuserver.domain.event.projection.AttachmentProjection(
ea.fileName,
ea.s3Key
)
)
from EventJpaEntity e
left join EventAttachmentJpaEntity ea
on e.id = ea.eventId
WHERE e.id = :id
""")
Optional<EventWithAttachmentProjection> findWithAttachmentById(Long id);
// @Query("""
// select new life.mosu.mosuserver.domain.event.projection.EventWithAttachmentProjection(
// e.id,
// e.title,
// e.duration.endDate,
// e.eventLink,
// new life.mosu.mosuserver.domain.event.projection.AttachmentProjection(
// ea.fileName,
// ea.s3Key
// )
// )
// from EventJpaEntity e
// left join EventAttachmentJpaEntity ea
// on e.id = ea.eventId
// WHERE e.id = :id
// """)
// Optional<EventWithAttachmentProjection> findWithAttachmentById(Long id);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The commented-out query methods are no longer used. They should be removed completely to improve code readability and maintainability.

Comment on lines +1 to +13
//package life.mosu.mosuserver.domain.event.projection;
//
//import java.time.LocalDate;
//
//public record EventWithAttachmentProjection(
// Long eventId,
// String title,
// LocalDate endDate,
// String eventLink,
// AttachmentProjection attachment
//) {
//
//} No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This record is no longer used and its contents have been commented out. The file should be deleted from the project to avoid clutter.

@RequiredArgsConstructor
@RequestMapping("/event")
public class EventController implements EventControllerDocs {
public class EventController {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The implements EventControllerDocs clause has been removed from the class definition. If this was unintentional, it should be restored. Its absence could lead to incomplete or missing API documentation if you are using a tool like Springdoc or Swagger that relies on such interfaces for documentation generation.

Suggested change
public class EventController {
public class EventController implements EventControllerDocs {

Comment on lines +23 to 48
// @Schema(description = "첨부파일 목록")
// List<AttachmentResponse> attachments
) {

public static NoticeResponse of(NoticeJpaEntity notice, List<AttachmentResponse> attachments) {
public static NoticeResponse of(NoticeJpaEntity notice) {
return new NoticeResponse(
notice.getId(),
notice.getTitle(),
notice.getContent(),
notice.getAuthor(),
notice.getCreatedAt(),
attachments
notice.getCreatedAt()
// attachments
);
}

public record AttachmentResponse(

@Schema(description = "파일 이름", example = "service_guide.pdf")
String fileName,

@Schema(description = "S3 Presigned URL", example = "https://bucket.s3.amazonaws.com/.../service_guide.pdf")
String url
) {

}
// public record AttachmentResponse(
//
// @Schema(description = "파일 이름", example = "service_guide.pdf")
// String fileName,
//
// @Schema(description = "S3 Presigned URL", example = "https://bucket.s3.amazonaws.com/.../service_guide.pdf")
// String url
// ) {
//
// }
} No newline at end of file

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The attachments field and the nested AttachmentResponse record have been commented out. This dead code should be removed to clean up the DTO definition and improve readability.

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