Skip to content

Commit

Permalink
HOTIFX: 게시글 업데이트 로직 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hyxklee committed Aug 27, 2024
1 parent f9babec commit 80c9f10
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,11 @@ public List<NoticeDTO.ResponseAll> findNotices(Long noticeId, Integer count) {
public void update(Long noticeId, NoticeDTO.Update dto, List<MultipartFile> files, Long userId) throws UserNotMatchException {
Notice notice = validateOwner(noticeId, userId);

List<String> fileUrls;
fileUrls = fileSaveService.uploadFiles(files);
List<String> fileUrls = notice.getFileUrls();
List<String> uploadedFileUrls = fileSaveService.uploadFiles(files);

fileUrls.addAll(uploadedFileUrls);

noticeUpdateService.update(notice, dto, fileUrls);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,10 @@ public List<PostDTO.ResponseAll> findPosts(Long postId, Integer count) {
public void update(Long postId, PostDTO.Update dto, List<MultipartFile> files, Long userId) throws UserNotMatchException {
Post post = validateOwner(postId, userId);

List<String> fileUrls;
fileUrls = fileSaveService.uploadFiles(files);
List<String> fileUrls = post.getFileUrls();
List<String> uploadedFileUrls = fileSaveService.uploadFiles(files);

fileUrls.addAll(uploadedFileUrls);

postUpdateService.update(post, dto, fileUrls);
}
Expand Down
10 changes: 3 additions & 7 deletions src/main/java/leets/weeth/domain/board/domain/entity/Board.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void increaseCommentCount() {
}

public void decreaseCommentCount() {
if(commentCount > 0) {
if (commentCount > 0) {
commentCount--;
}
}
Expand All @@ -67,17 +67,13 @@ public void updateCommentCount(List<Comment> comments) {
public void updateUpperClass(NoticeDTO.Update dto, List<String> 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<String> fileUrls) {
this.title = dto.title();
this.content = dto.content();
if (!fileUrls.isEmpty()) {
this.fileUrls = fileUrls;
}
this.fileUrls = fileUrls;
}

}

0 comments on commit 80c9f10

Please sign in to comment.