From 578f34ec3d712042dcc532208533d484b997b699 Mon Sep 17 00:00:00 2001 From: meohin Date: Tue, 23 Sep 2025 14:13:12 +0900 Subject: [PATCH 01/11] =?UTF-8?q?refactor:=20=EC=BB=A8=ED=8A=B8=EB=A1=A4?= =?UTF-8?q?=EB=9F=AC=20API=20=EA=B2=BD=EB=A1=9C=EC=97=90=20/api=20?= =?UTF-8?q?=EC=A0=91=EB=91=90=EC=82=AC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/back/domain/mybar/controller/MyBarController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/back/domain/mybar/controller/MyBarController.java b/src/main/java/com/back/domain/mybar/controller/MyBarController.java index 65fe4425..a0cf3632 100644 --- a/src/main/java/com/back/domain/mybar/controller/MyBarController.java +++ b/src/main/java/com/back/domain/mybar/controller/MyBarController.java @@ -13,7 +13,7 @@ import java.time.LocalDateTime; @RestController -@RequestMapping("/me/bar") +@RequestMapping("/api/me/bar") @RequiredArgsConstructor @Validated public class MyBarController { From 1fc4f4d502ec45676f87161ec4bd867a719aa462 Mon Sep 17 00:00:00 2001 From: meohin Date: Tue, 23 Sep 2025 15:23:12 +0900 Subject: [PATCH 02/11] =?UTF-8?q?refactor:=20History=20=ED=8C=A8=ED=82=A4?= =?UTF-8?q?=EC=A7=80=20=EB=B0=8F=20=ED=81=B4=EB=9E=98=EC=8A=A4=20=EB=AA=85?= =?UTF-8?q?=EC=B9=AD=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/MyHistoryPostItemDto.java} | 11 ++++++----- .../dto/MyHistoryPostListDto.java} | 6 +++--- .../repository/MyHistoryPostRepository.java} | 8 ++------ 3 files changed, 11 insertions(+), 14 deletions(-) rename src/main/java/com/back/domain/{history/dto/HistoryPostItemDto.java => myhistory/dto/MyHistoryPostItemDto.java} (77%) rename src/main/java/com/back/domain/{history/dto/HistoryPostListDto.java => myhistory/dto/MyHistoryPostListDto.java} (66%) rename src/main/java/com/back/domain/{history/repository/HistoryRepository.java => myhistory/repository/MyHistoryPostRepository.java} (79%) diff --git a/src/main/java/com/back/domain/history/dto/HistoryPostItemDto.java b/src/main/java/com/back/domain/myhistory/dto/MyHistoryPostItemDto.java similarity index 77% rename from src/main/java/com/back/domain/history/dto/HistoryPostItemDto.java rename to src/main/java/com/back/domain/myhistory/dto/MyHistoryPostItemDto.java index b01cdd23..e12c1247 100644 --- a/src/main/java/com/back/domain/history/dto/HistoryPostItemDto.java +++ b/src/main/java/com/back/domain/myhistory/dto/MyHistoryPostItemDto.java @@ -1,13 +1,14 @@ -package com.back.domain.history.dto; +package com.back.domain.myhistory.dto; import com.back.domain.post.post.entity.Post; -import java.time.LocalDateTime; import lombok.Builder; import lombok.Getter; +import java.time.LocalDateTime; + @Getter @Builder -public class HistoryPostItemDto { +public class MyHistoryPostItemDto { private Long id; private String title; private String imageUrl; @@ -15,8 +16,8 @@ public class HistoryPostItemDto { private Integer likeCount; private Integer commentCount; - public static HistoryPostItemDto from(Post p) { - return HistoryPostItemDto.builder() + public static MyHistoryPostItemDto from(Post p) { + return MyHistoryPostItemDto.builder() .id(p.getId()) .title(p.getTitle()) .imageUrl(p.getImageUrl()) diff --git a/src/main/java/com/back/domain/history/dto/HistoryPostListDto.java b/src/main/java/com/back/domain/myhistory/dto/MyHistoryPostListDto.java similarity index 66% rename from src/main/java/com/back/domain/history/dto/HistoryPostListDto.java rename to src/main/java/com/back/domain/myhistory/dto/MyHistoryPostListDto.java index c459b7d6..9a453713 100644 --- a/src/main/java/com/back/domain/history/dto/HistoryPostListDto.java +++ b/src/main/java/com/back/domain/myhistory/dto/MyHistoryPostListDto.java @@ -1,4 +1,4 @@ -package com.back.domain.history.dto; +package com.back.domain.myhistory.dto; import lombok.AllArgsConstructor; import lombok.Getter; @@ -8,8 +8,8 @@ @Getter @AllArgsConstructor -public class HistoryPostListDto { - private List items; +public class MyHistoryPostListDto { + private List items; private boolean hasNext; private LocalDateTime nextCreatedAt; private Long nextId; diff --git a/src/main/java/com/back/domain/history/repository/HistoryRepository.java b/src/main/java/com/back/domain/myhistory/repository/MyHistoryPostRepository.java similarity index 79% rename from src/main/java/com/back/domain/history/repository/HistoryRepository.java rename to src/main/java/com/back/domain/myhistory/repository/MyHistoryPostRepository.java index b7f948ee..d3ee9d1d 100644 --- a/src/main/java/com/back/domain/history/repository/HistoryRepository.java +++ b/src/main/java/com/back/domain/myhistory/repository/MyHistoryPostRepository.java @@ -1,12 +1,10 @@ -package com.back.domain.history.repository; +package com.back.domain.myhistory.repository; import com.back.domain.post.post.entity.Post; import com.back.domain.post.post.enums.PostStatus; -import jakarta.persistence.QueryHint; import org.springframework.data.domain.Pageable; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; -import org.springframework.data.jpa.repository.QueryHints; import org.springframework.data.repository.query.Param; import org.springframework.stereotype.Repository; @@ -14,9 +12,8 @@ import java.util.List; @Repository -public interface HistoryRepository extends JpaRepository { +public interface MyHistoryPostRepository extends JpaRepository { - @QueryHints(@QueryHint(name = "org.hibernate.readOnly", value = "true")) @Query(""" select p from Post p where p.user.id = :userId @@ -27,7 +24,6 @@ List findMyPostsFirstPage(@Param("userId") Long userId, @Param("deleted") PostStatus deleted, Pageable pageable); - @QueryHints(@QueryHint(name = "org.hibernate.readOnly", value = "true")) @Query(""" select p from Post p where p.user.id = :userId From b8554b61ead531a4894d32d5352b3bd1898f09b7 Mon Sep 17 00:00:00 2001 From: meohin Date: Tue, 23 Sep 2025 15:26:04 +0900 Subject: [PATCH 03/11] =?UTF-8?q?feat:=20=EB=A7=88=EC=9D=B4=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=8C=93=EA=B8=80=20=ED=9E=88=EC=8A=A4?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20DTO=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/MyHistoryCommentItemDto.java | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/main/java/com/back/domain/myhistory/dto/MyHistoryCommentItemDto.java diff --git a/src/main/java/com/back/domain/myhistory/dto/MyHistoryCommentItemDto.java b/src/main/java/com/back/domain/myhistory/dto/MyHistoryCommentItemDto.java new file mode 100644 index 00000000..4ce8b503 --- /dev/null +++ b/src/main/java/com/back/domain/myhistory/dto/MyHistoryCommentItemDto.java @@ -0,0 +1,28 @@ +package com.back.domain.myhistory.dto; + +import com.back.domain.post.comment.entity.Comment; +import lombok.Builder; +import lombok.Getter; + +import java.time.LocalDateTime; + +@Getter +@Builder +public class MyHistoryCommentItemDto { + private Long id; + private Long postId; + private String postTitle; + private String content; + private LocalDateTime createdAt; + + public static MyHistoryCommentItemDto from(Comment c) { + return MyHistoryCommentItemDto.builder() + .id(c.getId()) + .postId(c.getPost().getId()) + .postTitle(c.getPost().getTitle()) + .content(c.getContent()) + .createdAt(c.getCreatedAt()) + .build(); + } +} + From 8fbeed4655e5d0c69d3751ca20ebe5416d61cb09 Mon Sep 17 00:00:00 2001 From: meohin Date: Tue, 23 Sep 2025 15:26:18 +0900 Subject: [PATCH 04/11] =?UTF-8?q?feat:=20=EB=A7=88=EC=9D=B4=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=8C=93=EA=B8=80=20=EB=AA=A9=EB=A1=9D=20?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=A7=80=EB=84=A4=EC=9D=B4=EC=85=98=20DTO=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myhistory/dto/MyHistoryCommentListDto.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/com/back/domain/myhistory/dto/MyHistoryCommentListDto.java diff --git a/src/main/java/com/back/domain/myhistory/dto/MyHistoryCommentListDto.java b/src/main/java/com/back/domain/myhistory/dto/MyHistoryCommentListDto.java new file mode 100644 index 00000000..21b4d070 --- /dev/null +++ b/src/main/java/com/back/domain/myhistory/dto/MyHistoryCommentListDto.java @@ -0,0 +1,17 @@ +package com.back.domain.myhistory.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.time.LocalDateTime; +import java.util.List; + +@Getter +@AllArgsConstructor +public class MyHistoryCommentListDto { + private List items; + private boolean hasNext; + private LocalDateTime nextCreatedAt; + private Long nextId; +} + From 7f2ff0cf5447ddcaddfe83e4329918f5705493d8 Mon Sep 17 00:00:00 2001 From: meohin Date: Tue, 23 Sep 2025 15:26:35 +0900 Subject: [PATCH 05/11] =?UTF-8?q?feat:=20=EB=A7=88=EC=9D=B4=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=8C=93=EA=B8=80=20=EC=9D=B4=EB=8F=99=20?= =?UTF-8?q?=EC=9D=91=EB=8B=B5=20DTO=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../myhistory/dto/MyHistoryCommentGoResponseDto.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/main/java/com/back/domain/myhistory/dto/MyHistoryCommentGoResponseDto.java diff --git a/src/main/java/com/back/domain/myhistory/dto/MyHistoryCommentGoResponseDto.java b/src/main/java/com/back/domain/myhistory/dto/MyHistoryCommentGoResponseDto.java new file mode 100644 index 00000000..009f41e3 --- /dev/null +++ b/src/main/java/com/back/domain/myhistory/dto/MyHistoryCommentGoResponseDto.java @@ -0,0 +1,12 @@ +package com.back.domain.myhistory.dto; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@AllArgsConstructor +public class MyHistoryCommentGoResponseDto { + private Long postId; + private String postApiUrl; +} + From 1e4b6499207f1bb0a479387a0bbd05f68de7891a Mon Sep 17 00:00:00 2001 From: meohin Date: Tue, 23 Sep 2025 15:27:20 +0900 Subject: [PATCH 06/11] =?UTF-8?q?feat:=20=EB=A7=88=EC=9D=B4=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=8C=93=EA=B8=80=20=ED=9E=88=EC=8A=A4?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20Repository=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - `MyHistoryCommentRepository`에 사용자 댓글 조회 기능 추가 - `findMyCommentsFirstPage()`: 사용자 ID를 기반으로 댓글 목록의 첫 페이지를 조회 - `findMyCommentsAfter()`: 커서(lastCreatedAt, lastId)를 사용하여 다음 페이지의 댓글 목록을 효율적으로 조회 - `findByIdAndUserId()`: 특정 사용자의 특정 댓글을 조회하는 기능 추가 --- .../MyHistoryCommentRepository.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/main/java/com/back/domain/myhistory/repository/MyHistoryCommentRepository.java diff --git a/src/main/java/com/back/domain/myhistory/repository/MyHistoryCommentRepository.java b/src/main/java/com/back/domain/myhistory/repository/MyHistoryCommentRepository.java new file mode 100644 index 00000000..4f32b7d2 --- /dev/null +++ b/src/main/java/com/back/domain/myhistory/repository/MyHistoryCommentRepository.java @@ -0,0 +1,43 @@ +package com.back.domain.myhistory.repository; + +import com.back.domain.post.comment.entity.Comment; +import org.springframework.data.domain.Pageable; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; +import org.springframework.stereotype.Repository; + +import java.time.LocalDateTime; +import java.util.List; + +@Repository +public interface MyHistoryCommentRepository extends JpaRepository { + + @Query(""" + select c from Comment c + join fetch c.post p + where c.user.id = :userId + order by c.createdAt desc, c.id desc + """) + List findMyCommentsFirstPage(@Param("userId") Long userId, + Pageable pageable); + + @Query(""" + select c from Comment c + join fetch c.post p + where c.user.id = :userId + and (c.createdAt < :lastCreatedAt or (c.createdAt = :lastCreatedAt and c.id < :lastId)) + order by c.createdAt desc, c.id desc + """) + List findMyCommentsAfter(@Param("userId") Long userId, + @Param("lastCreatedAt") LocalDateTime lastCreatedAt, + @Param("lastId") Long lastId, + Pageable pageable); + + @Query(""" + select c from Comment c + join fetch c.post p + where c.id = :id and c.user.id = :userId + """) + Comment findByIdAndUserId(@Param("id") Long id, @Param("userId") Long userId); +} From a7d31b8b508249601aa3e3468b30c1d84bba98bf Mon Sep 17 00:00:00 2001 From: meohin Date: Tue, 23 Sep 2025 15:28:22 +0900 Subject: [PATCH 07/11] =?UTF-8?q?refactor:=20MyHistoryService=EB=A1=9C=20?= =?UTF-8?q?=ED=81=B4=EB=9E=98=EC=8A=A4=EB=AA=85=20=EB=B0=8F=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=EB=AA=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../history/service/HistoryService.java | 51 ------------------- 1 file changed, 51 deletions(-) delete mode 100644 src/main/java/com/back/domain/history/service/HistoryService.java diff --git a/src/main/java/com/back/domain/history/service/HistoryService.java b/src/main/java/com/back/domain/history/service/HistoryService.java deleted file mode 100644 index be78136e..00000000 --- a/src/main/java/com/back/domain/history/service/HistoryService.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.back.domain.history.service; - -import com.back.domain.history.dto.HistoryPostItemDto; -import com.back.domain.history.dto.HistoryPostListDto; -import com.back.domain.history.repository.HistoryRepository; -import com.back.domain.post.post.entity.Post; -import com.back.domain.post.post.enums.PostStatus; -import org.springframework.data.domain.PageRequest; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -import java.time.LocalDateTime; -import java.util.ArrayList; -import java.util.List; - -@Service -@RequiredArgsConstructor -public class HistoryService { - - private final HistoryRepository historyRepository; - - @Transactional(readOnly = true) - public HistoryPostListDto getMyPosts(Long userId, LocalDateTime lastCreatedAt, Long lastId, int limit) { - int safeLimit = Math.max(1, Math.min(limit, 100)); - int fetchSize = safeLimit + 1; - - List rows; - if (lastCreatedAt == null || lastId == null) { - rows = historyRepository.findMyPostsFirstPage(userId, PostStatus.DELETED, PageRequest.of(0, fetchSize)); - } else { - rows = historyRepository.findMyPostsAfter(userId, PostStatus.DELETED, lastCreatedAt, lastId, PageRequest.of(0, fetchSize)); - } - - boolean hasNext = rows.size() > safeLimit; - if (hasNext) rows = rows.subList(0, safeLimit); - - List items = new ArrayList<>(); - for (Post p : rows) items.add(HistoryPostItemDto.from(p)); - - LocalDateTime nextCreatedAt = null; - Long nextId = null; - if (hasNext && !rows.isEmpty()) { - Post last = rows.get(rows.size() - 1); - nextCreatedAt = last.getCreatedAt(); - nextId = last.getId(); - } - - return new HistoryPostListDto(items, hasNext, nextCreatedAt, nextId); - } -} From a104ee7d53f12b1c31038ea093fd0f055a45cead Mon Sep 17 00:00:00 2001 From: meohin Date: Tue, 23 Sep 2025 15:29:32 +0900 Subject: [PATCH 08/11] =?UTF-8?q?feat:=20=EB=A7=88=EC=9D=B4=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=8C=93=EA=B8=80=20=ED=9E=88=EC=8A=A4?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20=EA=B8=B0=EB=8A=A5=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - MyHistoryService에 사용자가 작성한 댓글 목록을 조회하는 getMyComments() 메서드를 추가 - 커서 기반 페이지네이션을 적용 - 댓글을 클릭하면 해당 댓글이 속한 게시글로 이동할 수 있도록 getPostLinkFromMyComment() 메서드를 구현 - 삭제된 게시글에 대한 예외 처리를 추가 --- .../myhistory/service/MyHistoryService.java | 98 +++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 src/main/java/com/back/domain/myhistory/service/MyHistoryService.java diff --git a/src/main/java/com/back/domain/myhistory/service/MyHistoryService.java b/src/main/java/com/back/domain/myhistory/service/MyHistoryService.java new file mode 100644 index 00000000..b0a6c691 --- /dev/null +++ b/src/main/java/com/back/domain/myhistory/service/MyHistoryService.java @@ -0,0 +1,98 @@ +package com.back.domain.myhistory.service; + +import com.back.domain.myhistory.dto.*; +import com.back.domain.myhistory.repository.MyHistoryCommentRepository; +import com.back.domain.myhistory.repository.MyHistoryPostRepository; +import com.back.domain.post.comment.entity.Comment; +import com.back.domain.post.post.entity.Post; +import com.back.domain.post.post.enums.PostStatus; +import com.back.global.exception.ServiceException; +import lombok.RequiredArgsConstructor; +import org.springframework.data.domain.PageRequest; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; + +@Service +@RequiredArgsConstructor +public class MyHistoryService { + + private final MyHistoryPostRepository myHistoryPostRepository; + private final MyHistoryCommentRepository myHistoryCommentRepository; + + @Transactional(readOnly = true) + public MyHistoryPostListDto getMyPosts(Long userId, LocalDateTime lastCreatedAt, Long lastId, int limit) { + int safeLimit = Math.max(1, Math.min(limit, 100)); + int fetchSize = safeLimit + 1; + + List rows; + if (lastCreatedAt == null || lastId == null) { + rows = myHistoryPostRepository.findMyPostsFirstPage(userId, PostStatus.DELETED, PageRequest.of(0, fetchSize)); + } else { + rows = myHistoryPostRepository.findMyPostsAfter(userId, PostStatus.DELETED, lastCreatedAt, lastId, PageRequest.of(0, fetchSize)); + } + + boolean hasNext = rows.size() > safeLimit; + if (hasNext) rows = rows.subList(0, safeLimit); + + List items = new ArrayList<>(); + for (Post p : rows) items.add(MyHistoryPostItemDto.from(p)); + + LocalDateTime nextCreatedAt = null; + Long nextId = null; + if (hasNext && !rows.isEmpty()) { + Post last = rows.get(rows.size() - 1); + nextCreatedAt = last.getCreatedAt(); + nextId = last.getId(); + } + + return new MyHistoryPostListDto(items, hasNext, nextCreatedAt, nextId); + } + + @Transactional(readOnly = true) + public MyHistoryCommentListDto getMyComments(Long userId, LocalDateTime lastCreatedAt, Long lastId, int limit) { + int safeLimit = Math.max(1, Math.min(limit, 100)); + int fetchSize = safeLimit + 1; + + List rows; + if (lastCreatedAt == null || lastId == null) { + rows = myHistoryCommentRepository.findMyCommentsFirstPage(userId, PageRequest.of(0, fetchSize)); + } else { + rows = myHistoryCommentRepository.findMyCommentsAfter(userId, lastCreatedAt, lastId, PageRequest.of(0, fetchSize)); + } + + boolean hasNext = rows.size() > safeLimit; + if (hasNext) rows = rows.subList(0, safeLimit); + + List items = new ArrayList<>(); + for (Comment c : rows) items.add(MyHistoryCommentItemDto.from(c)); + + LocalDateTime nextCreatedAt = null; + Long nextId = null; + if (hasNext && !rows.isEmpty()) { + Comment last = rows.get(rows.size() - 1); + nextCreatedAt = last.getCreatedAt(); + nextId = last.getId(); + } + + return new MyHistoryCommentListDto(items, hasNext, nextCreatedAt, nextId); + } + + @Transactional(readOnly = true) + public MyHistoryCommentGoResponseDto getPostLinkFromMyComment(Long userId, Long commentId) { + Comment c = myHistoryCommentRepository.findByIdAndUserId(commentId, userId); + if (c == null) { + throw new ServiceException(404, "댓글을 찾을 수 없습니다."); + } + Post post = c.getPost(); + if (post.getStatus() == PostStatus.DELETED) { + throw new ServiceException(410, "삭제된 게시글입니다."); + } + Long postId = post.getId(); + String apiUrl = "/api/posts/" + postId; + return new MyHistoryCommentGoResponseDto(postId, apiUrl); + } +} From 493ac99b680f1d2befefe5cf178f20a198f54cc6 Mon Sep 17 00:00:00 2001 From: meohin Date: Tue, 23 Sep 2025 15:30:28 +0900 Subject: [PATCH 09/11] =?UTF-8?q?refactor:=20MyHistoryController=EB=A1=9C?= =?UTF-8?q?=20=ED=81=B4=EB=9E=98=EC=8A=A4=EB=AA=85=20=EB=B0=8F=20=ED=8C=A8?= =?UTF-8?q?=ED=82=A4=EC=A7=80=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MyHistoryController.java | 38 ------------------- 1 file changed, 38 deletions(-) delete mode 100644 src/main/java/com/back/domain/history/controller/MyHistoryController.java diff --git a/src/main/java/com/back/domain/history/controller/MyHistoryController.java b/src/main/java/com/back/domain/history/controller/MyHistoryController.java deleted file mode 100644 index 8958874f..00000000 --- a/src/main/java/com/back/domain/history/controller/MyHistoryController.java +++ /dev/null @@ -1,38 +0,0 @@ -package com.back.domain.history.controller; - -import com.back.domain.history.dto.HistoryPostListDto; -import com.back.domain.history.service.HistoryService; -import com.back.global.rsData.RsData; -import jakarta.validation.constraints.Max; -import jakarta.validation.constraints.Min; -import lombok.RequiredArgsConstructor; -import org.springframework.format.annotation.DateTimeFormat; -import org.springframework.security.core.annotation.AuthenticationPrincipal; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; - -import java.time.LocalDateTime; - -@RestController -@RequestMapping("/api/me") -@RequiredArgsConstructor -@Validated -public class MyHistoryController { - - private final HistoryService historyService; - - @GetMapping("/posts") - public RsData getMyPosts( - @AuthenticationPrincipal(expression = "id") Long userId, - @RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime lastCreatedAt, - @RequestParam(required = false) Long lastId, - @RequestParam(defaultValue = "20") @Min(1) @Max(100) int limit - ) { - HistoryPostListDto body = historyService.getMyPosts(userId, lastCreatedAt, lastId, limit); - return RsData.successOf(body); - } -} - From 85e2c419c136d9df1b852016d5e31733b307919e Mon Sep 17 00:00:00 2001 From: meohin Date: Tue, 23 Sep 2025 15:31:34 +0900 Subject: [PATCH 10/11] =?UTF-8?q?feat:=20=EB=A7=88=EC=9D=B4=ED=8E=98?= =?UTF-8?q?=EC=9D=B4=EC=A7=80=20=EB=8C=93=EA=B8=80=20=ED=9E=88=EC=8A=A4?= =?UTF-8?q?=ED=86=A0=EB=A6=AC=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/MyHistoryController.java | 57 +++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 src/main/java/com/back/domain/myhistory/controller/MyHistoryController.java diff --git a/src/main/java/com/back/domain/myhistory/controller/MyHistoryController.java b/src/main/java/com/back/domain/myhistory/controller/MyHistoryController.java new file mode 100644 index 00000000..ca15f934 --- /dev/null +++ b/src/main/java/com/back/domain/myhistory/controller/MyHistoryController.java @@ -0,0 +1,57 @@ +package com.back.domain.myhistory.controller; + +import com.back.domain.myhistory.dto.MyHistoryCommentGoResponseDto; +import com.back.domain.myhistory.dto.MyHistoryCommentListDto; +import com.back.domain.myhistory.dto.MyHistoryPostListDto; +import com.back.domain.myhistory.service.MyHistoryService; +import com.back.global.rsData.RsData; +import jakarta.validation.constraints.Max; +import jakarta.validation.constraints.Min; +import lombok.RequiredArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; +import org.springframework.security.core.annotation.AuthenticationPrincipal; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.time.LocalDateTime; + +@RestController +@RequestMapping("/api/me") +@RequiredArgsConstructor +@Validated +public class MyHistoryController { + + private final MyHistoryService myHistoryService; + + @GetMapping("/posts") + public RsData getMyPosts( + @AuthenticationPrincipal(expression = "id") Long userId, + @RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime lastCreatedAt, + @RequestParam(required = false) Long lastId, + @RequestParam(defaultValue = "20") @Min(1) @Max(100) int limit + ) { + MyHistoryPostListDto body = myHistoryService.getMyPosts(userId, lastCreatedAt, lastId, limit); + return RsData.successOf(body); + } + + @GetMapping("/comments") + public RsData getMyComments( + @AuthenticationPrincipal(expression = "id") Long userId, + @RequestParam(required = false) @DateTimeFormat(iso = DateTimeFormat.ISO.DATE_TIME) LocalDateTime lastCreatedAt, + @RequestParam(required = false) Long lastId, + @RequestParam(defaultValue = "20") @Min(1) @Max(100) int limit + ) { + MyHistoryCommentListDto body = myHistoryService.getMyComments(userId, lastCreatedAt, lastId, limit); + return RsData.successOf(body); + } + + @GetMapping("/comments/{id}") + public RsData goFromComment( + @AuthenticationPrincipal(expression = "id") Long userId, + @PathVariable("id") Long commentId + ) { + var body = myHistoryService.getPostLinkFromMyComment(userId, commentId); + return RsData.successOf(body); + } +} + From 92a09faa644c370f6fa85dc26f2ea5cf2fec0fbf Mon Sep 17 00:00:00 2001 From: meohin Date: Tue, 23 Sep 2025 15:39:32 +0900 Subject: [PATCH 11/11] fix typo --- .../com/back/domain/cocktail/controller/CocktailController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/back/domain/cocktail/controller/CocktailController.java b/src/main/java/com/back/domain/cocktail/controller/CocktailController.java index 8ec833fb..bbe7f126 100644 --- a/src/main/java/com/back/domain/cocktail/controller/CocktailController.java +++ b/src/main/java/com/back/domain/cocktail/controller/CocktailController.java @@ -23,7 +23,7 @@ public class CocktailController { @GetMapping("/{id}") @Transactional @Operation(summary = "칵테일 단건 조회") - public RsData getCocktailDetailById(@PathVariable long id){ + public RsData getCocktailDetailById(@PathVariable long id){ CocktailDetailResponseDto cocktailDetailResponseDto = cocktailService.getCocktailDetailById(id); return RsData.successOf(cocktailDetailResponseDto);