From bbb4c46a4cb9f1043887a9edd533bebcd76b872a Mon Sep 17 00:00:00 2001 From: EunHyunsu Date: Wed, 13 Nov 2024 21:38:30 +0900 Subject: [PATCH 1/2] =?UTF-8?q?fix:=20#31=20DTO=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../article/dto/ArticleResponseDto.java | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/main/java/com/leets/xcellentbe/domain/article/dto/ArticleResponseDto.java b/src/main/java/com/leets/xcellentbe/domain/article/dto/ArticleResponseDto.java index 763dd8e..8e2f838 100644 --- a/src/main/java/com/leets/xcellentbe/domain/article/dto/ArticleResponseDto.java +++ b/src/main/java/com/leets/xcellentbe/domain/article/dto/ArticleResponseDto.java @@ -20,7 +20,8 @@ @NoArgsConstructor public class ArticleResponseDto { private UUID articleId; - private Long writerId; + private String customId; + private String userName; private String content; private DeletedStatus deletedStatus; private List hashtags; @@ -34,11 +35,13 @@ public class ArticleResponseDto { private boolean owner; @Builder - private ArticleResponseDto(UUID articleId, Long writerId, String content, DeletedStatus deletedStatus, - List hashtags, UUID rePostId, List mediaUrls, List comments, - int viewCnt, long rePostCnt, long likeCnt, long commentCnt, boolean owner) { + private ArticleResponseDto(UUID articleId, String userName, String customId, String content, + DeletedStatus deletedStatus, + List hashtags, UUID rePostId, List mediaUrls, List comments, + int viewCnt, long rePostCnt, long likeCnt, long commentCnt, boolean owner) { this.articleId = articleId; - this.writerId = writerId; + this.userName = userName; + this.customId = customId; this.content = content; this.deletedStatus = deletedStatus; this.hashtags = hashtags; @@ -52,12 +55,14 @@ private ArticleResponseDto(UUID articleId, Long writerId, String content, Delete this.comments = comments; } - public static ArticleResponseDto from(Article article, boolean isOwner, ArticleStatsDto stats, Map replyStatsMap) { + public static ArticleResponseDto from(Article article, boolean isOwner, ArticleStatsDto stats, + Map replyStatsMap) { return ArticleResponseDto.builder() .articleId(article.getArticleId()) .content(article.getContent()) .deletedStatus(article.getDeletedStatus()) - .writerId(article.getWriter().getUserId()) + .userName(article.getWriter().getUserName()) + .customId(article.getWriter().getCustomId()) .hashtags(article.getHashtags() != null ? article.getHashtags() .stream() .map(Hashtag::getContent) @@ -69,9 +74,11 @@ public static ArticleResponseDto from(Article article, boolean isOwner, ArticleS .collect(Collectors.toList()) : null) .comments(article.getComments() != null ? article.getComments() .stream() - .filter(comment -> comment != null && comment.getDeletedStatus() == DeletedStatus.NOT_DELETED) // null 및 삭제된 댓글 필터링 + .filter(comment -> comment != null + && comment.getDeletedStatus() == DeletedStatus.NOT_DELETED) // null 및 삭제된 댓글 필터링 .map(comment -> { - CommentStatsDto commentStats = replyStatsMap.getOrDefault(comment.getCommentId(), CommentStatsDto.from(0, 0)); + CommentStatsDto commentStats = replyStatsMap.getOrDefault(comment.getCommentId(), + CommentStatsDto.from(0, 0)); boolean isCommentOwner = comment.getWriter().getUserId().equals(article.getWriter().getUserId()); return CommentResponseDto.from(comment, isCommentOwner, commentStats, replyStatsMap, 1); // 깊이 1로 제한 }) @@ -89,7 +96,8 @@ public static ArticleResponseDto fromWithoutComments(Article article, boolean is .articleId(article.getArticleId()) .content(article.getContent()) .deletedStatus(article.getDeletedStatus()) - .writerId(article.getWriter().getUserId()) + .userName(article.getWriter().getUserName()) + .customId(article.getWriter().getCustomId()) .hashtags(article.getHashtags() != null ? article.getHashtags() .stream() .map(Hashtag::getContent) From 61fe28aec099e262faf4669dea562a93e5988ca4 Mon Sep 17 00:00:00 2001 From: EunHyunsu Date: Wed, 13 Nov 2024 21:38:59 +0900 Subject: [PATCH 2/2] =?UTF-8?q?fix:=20#31=20=ED=8C=8C=EC=9D=BC=20=EC=A0=9C?= =?UTF-8?q?=EC=95=BD=20=ED=99=95=EC=9E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/article/service/S3UploadMediaService.java | 5 +++-- .../xcellentbe/domain/user/service/S3UploadService.java | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/leets/xcellentbe/domain/article/service/S3UploadMediaService.java b/src/main/java/com/leets/xcellentbe/domain/article/service/S3UploadMediaService.java index 55d8c86..91519bd 100644 --- a/src/main/java/com/leets/xcellentbe/domain/article/service/S3UploadMediaService.java +++ b/src/main/java/com/leets/xcellentbe/domain/article/service/S3UploadMediaService.java @@ -30,12 +30,13 @@ public class S3UploadMediaService { public String upload(MultipartFile multipartFile, String dirName) { String fileName = multipartFile.getOriginalFilename(); - if (!(fileName.endsWith(".png") || fileName.endsWith(".jpg"))) { + if (!(fileName.endsWith(".png") || fileName.endsWith(".jpg") || fileName.endsWith(".jpeg") || fileName.endsWith( + ".gif") || fileName.endsWith(".bmp"))) { throw new InvalidFileFormat(); } try { File uploadFile = convert(multipartFile) - .orElseThrow(()->new RuntimeException()); + .orElseThrow(() -> new RuntimeException()); return upload(uploadFile, dirName); } catch (IOException e) { throw new InternalServerErrorException(); diff --git a/src/main/java/com/leets/xcellentbe/domain/user/service/S3UploadService.java b/src/main/java/com/leets/xcellentbe/domain/user/service/S3UploadService.java index 91af467..bbd6875 100644 --- a/src/main/java/com/leets/xcellentbe/domain/user/service/S3UploadService.java +++ b/src/main/java/com/leets/xcellentbe/domain/user/service/S3UploadService.java @@ -30,7 +30,8 @@ public class S3UploadService { // MultipartFile을 전달받아 File로 전환한 후 S3에 업로드 public String upload(MultipartFile multipartFile, String dirName) { // dirName의 디렉토리가 S3 Bucket 내부에 생성됨 String fileName = multipartFile.getOriginalFilename(); - if ((fileName.endsWith(".png") || fileName.endsWith(".jpg"))) { + if (!(fileName.endsWith(".png") || fileName.endsWith(".jpg") || fileName.endsWith(".jpeg") || fileName.endsWith( + ".gif") || fileName.endsWith(".bmp"))) { throw new InvalidFileFormat(); }