2727
2828import java .util .Objects ;
2929
30+ import static clap .server .domain .model .task .Attachment .formatFileSize ;
31+
3032@ ApplicationService
3133@ RequiredArgsConstructor
3234public class PostCommentService implements SaveCommentUsecase , SaveCommentAttachmentUsecase {
@@ -48,7 +50,7 @@ public void save(Long memberId, Long taskId, CreateCommentRequest request) {
4850
4951 // 일반 회원일 경우 => 요청자인지 확인
5052 taskCommentPolicy .validateCommentPermission (task , member );
51- Comment comment = Comment .createComment (member , task , request .content ());
53+ Comment comment = Comment .createComment (member , task , request .content (), null , null , null );
5254 Comment savedComment = commandCommentPort .saveComment (comment );
5355
5456 TaskHistory taskHistory = TaskHistory .createTaskHistory (TaskHistoryType .COMMENT , task , null , member , savedComment );
@@ -71,11 +73,14 @@ public void saveCommentAttachment(Long memberId, Long taskId, MultipartFile file
7173 Member member = memberService .findActiveMember (memberId );
7274
7375 taskCommentPolicy .validateCommentPermission (task , member );
74- Comment comment = Comment .createComment (member , task , null );
76+
77+ String fileUrl = s3UploadPort .uploadSingleFile (FilePathConstants .TASK_COMMENT , file );
78+ String fileName = file .getOriginalFilename ();
79+
80+ Comment comment = Comment .createComment (member , task , null , fileName , fileUrl , formatFileSize (file .getSize ()));
7581 Comment savedComment = commandCommentPort .saveComment (comment );
76- String fileName = saveAttachment (file , task );
7782
78- TaskHistory taskHistory = TaskHistory .createTaskHistory (TaskHistoryType .COMMENT_FILE , task , null , member , savedComment );
83+ TaskHistory taskHistory = TaskHistory .createTaskHistory (TaskHistoryType .COMMENT_FILE , null , null , null , savedComment );
7984 commandTaskHistoryPort .save (taskHistory );
8085
8186 Member processor = task .getProcessor ();
@@ -88,12 +93,13 @@ public void saveCommentAttachment(Long memberId, Long taskId, MultipartFile file
8893
8994 }
9095
91- private String saveAttachment (MultipartFile file , Task task ) {
92- String fileUrl = s3UploadPort .uploadSingleFile (FilePathConstants .TASK_COMMENT , file );
93- Attachment attachment = Attachment .createCommentAttachment (task , file .getOriginalFilename (), fileUrl , file .getSize ());
94- commandAttachmentPort .save (attachment );
95- return file .getOriginalFilename ();
96- }
96+ @ Deprecated
97+ // private String saveAttachment(MultipartFile file, Task task) {
98+ // String fileUrl = s3UploadPort.uploadSingleFile(FilePathConstants.TASK_COMMENT, file);
99+ // Attachment attachment = Attachment.createCommentAttachment(task, null, file.getOriginalFilename(), fileUrl, file.getSize());
100+ // commandAttachmentPort.save(attachment);
101+ // return file.getOriginalFilename();
102+ // }
97103
98104 private void publishNotification (Member receiver , Task task , String message , String commenterName ) {
99105 boolean isManager = receiver .getMemberInfo ().getRole () == MemberRole .ROLE_MANAGER ;
0 commit comments