Skip to content

Commit cf7315d

Browse files
committed
CLAP-113 Refactor: 유효성 검증 메서드 분리
<footer> - 관련: #76
1 parent 69dac4d commit cf7315d

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/main/java/clap/server/application/Task/UpdateTaskService.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,16 +58,18 @@ public UpdateTaskResponse updateTask(Long requesterId, Long taskId, UpdateTaskRe
5858
}
5959

6060
private void updateAttachments(List<Long> attachmentIdsToDelete, List<MultipartFile> files, Task task) {
61-
List<Attachment> attachmentsOfTask = loadAttachmentPort.findAllByTaskIdAndAttachmentIdIn(task.getTaskId(), attachmentIdsToDelete);
62-
63-
if(attachmentsOfTask.size() != attachmentIdsToDelete.size()) {
64-
throw new ApplicationException(TaskErrorCode.TASK_ATTACHMENT_NOT_FOUND);
65-
}
66-
61+
validateAttachments(attachmentIdsToDelete, task);
6762
commandAttachmentPort.deleteByIds(attachmentIdsToDelete);
6863

6964
List<String> fileUrls = s3UploadService.uploadFiles(FilePath.TASK_IMAGE, files);
7065
List<Attachment> attachments = AttachmentMapper.toTaskAttachments(task, files, fileUrls);
7166
commandAttachmentPort.saveAll(attachments);
7267
}
68+
69+
private void validateAttachments(List<Long> attachmentIdsToDelete, Task task) {
70+
List<Attachment> attachmentsOfTask = loadAttachmentPort.findAllByTaskIdAndAttachmentIdIn(task.getTaskId(), attachmentIdsToDelete);
71+
if(attachmentsOfTask.size() != attachmentIdsToDelete.size()) {
72+
throw new ApplicationException(TaskErrorCode.TASK_ATTACHMENT_NOT_FOUND);
73+
}
74+
}
7375
}

0 commit comments

Comments
 (0)