diff --git a/src/main/java/leets/weeth/domain/board/application/usecase/NoticeUsecaseImpl.java b/src/main/java/leets/weeth/domain/board/application/usecase/NoticeUsecaseImpl.java index f2ccccab..a5afa4c6 100644 --- a/src/main/java/leets/weeth/domain/board/application/usecase/NoticeUsecaseImpl.java +++ b/src/main/java/leets/weeth/domain/board/application/usecase/NoticeUsecaseImpl.java @@ -77,8 +77,11 @@ public List findNotices(Long noticeId, Integer count) { public void update(Long noticeId, NoticeDTO.Update dto, List files, Long userId) throws UserNotMatchException { Notice notice = validateOwner(noticeId, userId); - List fileUrls; - fileUrls = fileSaveService.uploadFiles(files); + List fileUrls = notice.getFileUrls(); + List uploadedFileUrls = fileSaveService.uploadFiles(files); + + fileUrls.addAll(uploadedFileUrls); + noticeUpdateService.update(notice, dto, fileUrls); } diff --git a/src/main/java/leets/weeth/domain/board/application/usecase/PostUseCaseImpl.java b/src/main/java/leets/weeth/domain/board/application/usecase/PostUseCaseImpl.java index 8f54063d..60c2cf58 100644 --- a/src/main/java/leets/weeth/domain/board/application/usecase/PostUseCaseImpl.java +++ b/src/main/java/leets/weeth/domain/board/application/usecase/PostUseCaseImpl.java @@ -77,8 +77,10 @@ public List findPosts(Long postId, Integer count) { public void update(Long postId, PostDTO.Update dto, List files, Long userId) throws UserNotMatchException { Post post = validateOwner(postId, userId); - List fileUrls; - fileUrls = fileSaveService.uploadFiles(files); + List fileUrls = post.getFileUrls(); + List uploadedFileUrls = fileSaveService.uploadFiles(files); + + fileUrls.addAll(uploadedFileUrls); postUpdateService.update(post, dto, fileUrls); } diff --git a/src/main/java/leets/weeth/domain/board/domain/entity/Board.java b/src/main/java/leets/weeth/domain/board/domain/entity/Board.java index 77b04c06..8c98ee93 100644 --- a/src/main/java/leets/weeth/domain/board/domain/entity/Board.java +++ b/src/main/java/leets/weeth/domain/board/domain/entity/Board.java @@ -53,7 +53,7 @@ public void increaseCommentCount() { } public void decreaseCommentCount() { - if(commentCount > 0) { + if (commentCount > 0) { commentCount--; } } @@ -67,17 +67,13 @@ public void updateCommentCount(List comments) { public void updateUpperClass(NoticeDTO.Update dto, List fileUrls) { this.title = dto.title(); this.content = dto.content(); - if (!fileUrls.isEmpty()) { - this.fileUrls = fileUrls; - } + this.fileUrls = fileUrls; } public void updateUpperClass(PostDTO.Update dto, List fileUrls) { this.title = dto.title(); this.content = dto.content(); - if (!fileUrls.isEmpty()) { - this.fileUrls = fileUrls; - } + this.fileUrls = fileUrls; } }