-
Notifications
You must be signed in to change notification settings - Fork 2
MOSU-155 refactor: 엔티티 softDelete 적용 및 cursor 기반 페이지네이션 구현 #164
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5562e7d
0bbd6bd
7fc1747
1c6f98e
9c99c82
7571de7
48855fc
4451174
a4e24df
3e999be
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,40 +1,40 @@ | ||
| package life.mosu.mosuserver.application.event; | ||
|
|
||
| import java.util.List; | ||
| import life.mosu.mosuserver.domain.event.EventAttachmentRepository; | ||
| import life.mosu.mosuserver.domain.event.EventJpaEntity; | ||
| import life.mosu.mosuserver.infra.persistence.s3.AttachmentService; | ||
| import life.mosu.mosuserver.infra.persistence.s3.FileUploadHelper; | ||
| import life.mosu.mosuserver.presentation.common.FileRequest; | ||
| import lombok.RequiredArgsConstructor; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| @Service | ||
| @RequiredArgsConstructor | ||
| public class EventAttachmentService implements AttachmentService<EventJpaEntity, FileRequest> { | ||
|
|
||
| private final EventAttachmentRepository eventAttachmentRepository; | ||
| private final FileUploadHelper fileUploadHelper; | ||
|
|
||
| @Override | ||
| public void createAttachment(List<FileRequest> request, EventJpaEntity eventEntity) { | ||
| if (request == null || request.isEmpty()) { | ||
| return; | ||
| } | ||
| fileUploadHelper.saveAttachments( | ||
| request, | ||
| eventEntity.getId(), | ||
| eventAttachmentRepository, | ||
| (fileRequest, eventId) -> fileRequest.toEventAttachmentEntity(eventEntity.getId()), | ||
| FileRequest::s3Key | ||
| ); | ||
| } | ||
|
|
||
| @Override | ||
| public void deleteAttachment(EventJpaEntity entity) { | ||
| if (eventAttachmentRepository.findByEventId(entity.getId()).isPresent()) { | ||
| eventAttachmentRepository.deleteByEventId(entity.getId()); | ||
| } | ||
| } | ||
|
|
||
| } | ||
| //package life.mosu.mosuserver.application.event; | ||
| // | ||
| //import java.util.List; | ||
| //import life.mosu.mosuserver.domain.event.EventAttachmentRepository; | ||
| //import life.mosu.mosuserver.domain.event.EventJpaEntity; | ||
| //import life.mosu.mosuserver.infra.persistence.s3.AttachmentService; | ||
| //import life.mosu.mosuserver.infra.persistence.s3.FileUploadHelper; | ||
| //import life.mosu.mosuserver.presentation.common.FileRequest; | ||
| //import lombok.RequiredArgsConstructor; | ||
| //import org.springframework.stereotype.Service; | ||
| // | ||
| //@Service | ||
| //@RequiredArgsConstructor | ||
| //public class EventAttachmentService implements AttachmentService<EventJpaEntity, FileRequest> { | ||
| // | ||
| // private final EventAttachmentRepository eventAttachmentRepository; | ||
| // private final FileUploadHelper fileUploadHelper; | ||
| // | ||
| // @Override | ||
| // public void createAttachment(List<FileRequest> request, EventJpaEntity eventEntity) { | ||
| // if (request == null || request.isEmpty()) { | ||
| // return; | ||
| // } | ||
| // fileUploadHelper.saveAttachments( | ||
| // request, | ||
| // eventEntity.getId(), | ||
| // eventAttachmentRepository, | ||
| // (fileRequest, eventId) -> fileRequest.toEventAttachmentEntity(eventEntity.getId()), | ||
| // FileRequest::s3Key | ||
| // ); | ||
| // } | ||
| // | ||
| // @Override | ||
| // public void deleteAttachment(EventJpaEntity entity) { | ||
| // if (eventAttachmentRepository.findByEventId(entity.getId()).isPresent()) { | ||
| // eventAttachmentRepository.deleteByEventId(entity.getId()); | ||
| // } | ||
| // } | ||
| // | ||
| //} |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -6,19 +6,17 @@ | |||||||||||||||||||||||||||
| import jakarta.persistence.GenerationType; | ||||||||||||||||||||||||||||
| import jakarta.persistence.Id; | ||||||||||||||||||||||||||||
| import jakarta.persistence.Table; | ||||||||||||||||||||||||||||
| import life.mosu.mosuserver.domain.base.BaseTimeEntity; | ||||||||||||||||||||||||||||
| import life.mosu.mosuserver.domain.base.BaseDeleteEntity; | ||||||||||||||||||||||||||||
| import lombok.AccessLevel; | ||||||||||||||||||||||||||||
| import lombok.Builder; | ||||||||||||||||||||||||||||
| import lombok.Getter; | ||||||||||||||||||||||||||||
| import lombok.NoArgsConstructor; | ||||||||||||||||||||||||||||
| import org.hibernate.annotations.SoftDelete; | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @Entity | ||||||||||||||||||||||||||||
| @Table(name = "application") | ||||||||||||||||||||||||||||
| @Getter | ||||||||||||||||||||||||||||
| @NoArgsConstructor(access = AccessLevel.PROTECTED) | ||||||||||||||||||||||||||||
| @SoftDelete | ||||||||||||||||||||||||||||
| public class ApplicationJpaEntity extends BaseTimeEntity { | ||||||||||||||||||||||||||||
| public class ApplicationJpaEntity extends BaseDeleteEntity { | ||||||||||||||||||||||||||||
|
Comment on lines
15
to
+19
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| @Id | ||||||||||||||||||||||||||||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.