From 0c23e2e08bdbb324f881b3ab0e39531ad28ae04a Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sat, 22 Jun 2024 23:16:34 +0900 Subject: [PATCH 01/19] =?UTF-8?q?refactor:=20ReadNews=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/news/api/NewsApi.java | 14 ---------- .../domain/news/api/NewsController.java | 10 +------ .../news/repository/ReadNewsRepository.java | 2 +- .../domain/news/service/NewsService.java | 4 +-- .../domain/readNews/api/ReadNewsApi.java | 22 +++++++++++++++ .../readNews/api/ReadNewsController.java | 27 +++++++++++++++++++ .../{news => readNews}/entity/ReadNews.java | 3 ++- .../service/ReadNewsService.java | 5 ++-- .../domain/news/api/NewsControllerTest.java | 4 +-- .../repository/ReadNewsRepositoryTest.java | 2 +- 10 files changed, 61 insertions(+), 32 deletions(-) create mode 100644 backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.java create mode 100644 backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsController.java rename backend/core/src/main/java/com/rollthedice/backend/domain/{news => readNews}/entity/ReadNews.java (87%) rename backend/core/src/main/java/com/rollthedice/backend/domain/{news => readNews}/service/ReadNewsService.java (83%) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java index b6d19e4f..a152eebc 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java @@ -46,18 +46,4 @@ NewsDetailResponse getDetailNews( @Parameter(in = ParameterIn.PATH, description = "뉴스 ID", required = true) Long newsId ); - - @Operation( - summary = "최근 읽은 뉴스 조회", - description = "가장 최근에 읽은 3개의 뉴스를 조회합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"news"} - ) - @ApiResponse( - responseCode = "200", - description = "요청에 성공하였습니다." - ) - List getReadNews(); - - } diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsController.java b/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsController.java index 0f50123a..84407564 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsController.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsController.java @@ -2,9 +2,7 @@ import com.rollthedice.backend.domain.news.dto.response.NewsDetailResponse; import com.rollthedice.backend.domain.news.dto.response.NewsResponse; -import com.rollthedice.backend.domain.news.dto.response.ReadNewsResponse; import com.rollthedice.backend.domain.news.service.NewsService; -import com.rollthedice.backend.domain.news.service.ReadNewsService; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; @@ -17,7 +15,6 @@ @RequestMapping("news") public class NewsController implements NewsApi { private final NewsService newsService; - private final ReadNewsService readNewsService; @ResponseStatus(HttpStatus.OK) @GetMapping("") @@ -28,13 +25,8 @@ public List getNews(final Pageable pageable) { @ResponseStatus(HttpStatus.OK) @GetMapping("/{newsId}") + @Override public NewsDetailResponse getDetailNews(final @PathVariable Long newsId) { return newsService.getDetailNews(newsId); } - - @ResponseStatus(HttpStatus.OK) - @GetMapping("/viewed-history") - public List getReadNews() { - return readNewsService.getReadNews(); - } } diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/news/repository/ReadNewsRepository.java b/backend/core/src/main/java/com/rollthedice/backend/domain/news/repository/ReadNewsRepository.java index 0dec52dc..c1c49b32 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/news/repository/ReadNewsRepository.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/news/repository/ReadNewsRepository.java @@ -1,7 +1,7 @@ package com.rollthedice.backend.domain.news.repository; import com.rollthedice.backend.domain.member.entity.Member; -import com.rollthedice.backend.domain.news.entity.ReadNews; +import com.rollthedice.backend.domain.readNews.entity.ReadNews; import com.rollthedice.backend.domain.statistics.repository.ReadNewsCustomRepository; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.stereotype.Repository; diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/news/service/NewsService.java b/backend/core/src/main/java/com/rollthedice/backend/domain/news/service/NewsService.java index bb3136c1..8dac390a 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/news/service/NewsService.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/news/service/NewsService.java @@ -4,7 +4,7 @@ import com.rollthedice.backend.domain.member.entity.Member; import com.rollthedice.backend.domain.news.dto.response.NewsDetailResponse; import com.rollthedice.backend.domain.news.dto.response.ReadNewsResponse; -import com.rollthedice.backend.domain.news.entity.ReadNews; +import com.rollthedice.backend.domain.readNews.entity.ReadNews; import com.rollthedice.backend.domain.news.exception.NewsNotFoundException; import com.rollthedice.backend.domain.news.repository.ReadNewsRepository; import com.rollthedice.backend.global.oauth2.service.AuthService; @@ -30,11 +30,11 @@ @RequiredArgsConstructor public class NewsService { private final AuthService authService; + private final BookmarkService bookmarkService; private final ContentProducer contentProducer; private final NewsRepository newsRepository; private final ReadNewsRepository readNewsRepository; private final NewsMapper newsMapper; - private final BookmarkService bookmarkService; @Transactional diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.java new file mode 100644 index 00000000..59aff96e --- /dev/null +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.java @@ -0,0 +1,22 @@ +package com.rollthedice.backend.domain.readNews.api; + +import com.rollthedice.backend.domain.news.dto.response.ReadNewsResponse; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; + +import java.util.List; + +public interface ReadNewsApi { + @Operation( + summary = "최근 읽은 뉴스 조회", + description = "가장 최근에 읽은 3개의 뉴스를 조회합니다.", + security = {@SecurityRequirement(name = "access_token")}, + tags = {"news"} + ) + @ApiResponse( + responseCode = "200", + description = "요청에 성공하였습니다." + ) + List getReadNews(); +} diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsController.java b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsController.java new file mode 100644 index 00000000..e32da2b7 --- /dev/null +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsController.java @@ -0,0 +1,27 @@ +package com.rollthedice.backend.domain.readNews.api; + +import com.rollthedice.backend.domain.news.dto.response.ReadNewsResponse; +import com.rollthedice.backend.domain.readNews.service.ReadNewsService; +import lombok.RequiredArgsConstructor; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseStatus; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@RestController +@RequiredArgsConstructor +@RequestMapping("read-news") +public class ReadNewsController implements ReadNewsApi { + + private final ReadNewsService readNewsService; + + @ResponseStatus(HttpStatus.OK) + @GetMapping("/viewed-history") + @Override + public List getReadNews() { + return readNewsService.getReadNews(); + } +} diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/news/entity/ReadNews.java b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/entity/ReadNews.java similarity index 87% rename from backend/core/src/main/java/com/rollthedice/backend/domain/news/entity/ReadNews.java rename to backend/core/src/main/java/com/rollthedice/backend/domain/readNews/entity/ReadNews.java index 03abeb91..012fb466 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/news/entity/ReadNews.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/entity/ReadNews.java @@ -1,6 +1,7 @@ -package com.rollthedice.backend.domain.news.entity; +package com.rollthedice.backend.domain.readNews.entity; import com.rollthedice.backend.domain.member.entity.Member; +import com.rollthedice.backend.domain.news.entity.News; import com.rollthedice.backend.global.config.BaseTimeEntity; import jakarta.persistence.*; import lombok.AccessLevel; diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/news/service/ReadNewsService.java b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/service/ReadNewsService.java similarity index 83% rename from backend/core/src/main/java/com/rollthedice/backend/domain/news/service/ReadNewsService.java rename to backend/core/src/main/java/com/rollthedice/backend/domain/readNews/service/ReadNewsService.java index c2618ff0..c0203c4d 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/news/service/ReadNewsService.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/service/ReadNewsService.java @@ -1,9 +1,10 @@ -package com.rollthedice.backend.domain.news.service; +package com.rollthedice.backend.domain.readNews.service; import com.rollthedice.backend.domain.member.entity.Member; import com.rollthedice.backend.domain.news.dto.response.ReadNewsResponse; -import com.rollthedice.backend.domain.news.entity.ReadNews; +import com.rollthedice.backend.domain.readNews.entity.ReadNews; import com.rollthedice.backend.domain.news.repository.ReadNewsRepository; +import com.rollthedice.backend.domain.news.service.NewsService; import com.rollthedice.backend.global.oauth2.service.AuthService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; diff --git a/backend/core/src/test/java/com/rollthedice/backend/domain/news/api/NewsControllerTest.java b/backend/core/src/test/java/com/rollthedice/backend/domain/news/api/NewsControllerTest.java index 200419be..f84a6de2 100644 --- a/backend/core/src/test/java/com/rollthedice/backend/domain/news/api/NewsControllerTest.java +++ b/backend/core/src/test/java/com/rollthedice/backend/domain/news/api/NewsControllerTest.java @@ -3,7 +3,7 @@ import com.rollthedice.backend.domain.news.exception.NewsNotFoundException; import com.rollthedice.backend.domain.news.repository.NewsRepository; import com.rollthedice.backend.domain.news.service.NewsService; -import com.rollthedice.backend.domain.news.service.ReadNewsService; +import com.rollthedice.backend.domain.readNews.service.ReadNewsService; import com.rollthedice.backend.global.BaseControllerTest; import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; @@ -82,7 +82,7 @@ void getDetailNewsNotFound() throws Exception { void getReadNews() throws Exception{ //when final ResultActions perform = mockMvc.perform( - get("/news/viewed-history") + get("/read-news/viewed-history") .contentType(MediaType.APPLICATION_JSON) .header("Authorization", "Bearer " + accessToken) ).andDo(print()); diff --git a/backend/core/src/test/java/com/rollthedice/backend/domain/news/repository/ReadNewsRepositoryTest.java b/backend/core/src/test/java/com/rollthedice/backend/domain/news/repository/ReadNewsRepositoryTest.java index 5427888c..dea0fcf8 100644 --- a/backend/core/src/test/java/com/rollthedice/backend/domain/news/repository/ReadNewsRepositoryTest.java +++ b/backend/core/src/test/java/com/rollthedice/backend/domain/news/repository/ReadNewsRepositoryTest.java @@ -4,7 +4,7 @@ import com.rollthedice.backend.domain.member.repository.MemberRepository; import com.rollthedice.backend.domain.news.entity.News; import com.rollthedice.backend.domain.news.entity.NewsCategory; -import com.rollthedice.backend.domain.news.entity.ReadNews; +import com.rollthedice.backend.domain.readNews.entity.ReadNews; import com.rollthedice.backend.support.RepositoryTest; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.DisplayName; From e13bb2ac51bd23ce0282df8c665cd4d6bbc8c041 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sat, 29 Jun 2024 23:29:55 +0900 Subject: [PATCH 02/19] =?UTF-8?q?refactor:=20ReadNews=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EB=B6=84=EB=A6=AC=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../statistics/repository/ReadNewsCustomRepositoryImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/repository/ReadNewsCustomRepositoryImpl.java b/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/repository/ReadNewsCustomRepositoryImpl.java index 8fe479f3..7e42c6c4 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/repository/ReadNewsCustomRepositoryImpl.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/repository/ReadNewsCustomRepositoryImpl.java @@ -7,7 +7,7 @@ import java.time.LocalDate; import static com.rollthedice.backend.domain.news.entity.QNews.news; -import static com.rollthedice.backend.domain.news.entity.QReadNews.readNews; +import static com.rollthedice.backend.domain.readNews.entity.QReadNews.readNews; @RequiredArgsConstructor public class ReadNewsCustomRepositoryImpl implements ReadNewsCustomRepository { From 8e786ec322d515098c39961e7301342e1e5cb538 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sat, 29 Jun 2024 23:58:02 +0900 Subject: [PATCH 03/19] =?UTF-8?q?refactor:=20ReadNews=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EB=B6=84=EB=A6=AC=20api=20Test=EC=97=90=20?= =?UTF-8?q?=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/news/api/NewsControllerTest.java | 18 ---------- .../readNews/api/ReadNewsControllerTest.java | 35 +++++++++++++++++++ 2 files changed, 35 insertions(+), 18 deletions(-) create mode 100644 backend/core/src/test/java/com/rollthedice/backend/domain/readNews/api/ReadNewsControllerTest.java diff --git a/backend/core/src/test/java/com/rollthedice/backend/domain/news/api/NewsControllerTest.java b/backend/core/src/test/java/com/rollthedice/backend/domain/news/api/NewsControllerTest.java index f84a6de2..056cb0f4 100644 --- a/backend/core/src/test/java/com/rollthedice/backend/domain/news/api/NewsControllerTest.java +++ b/backend/core/src/test/java/com/rollthedice/backend/domain/news/api/NewsControllerTest.java @@ -25,10 +25,6 @@ class NewsControllerTest extends BaseControllerTest { @MockBean private NewsService newsService; - @MockBean - private ReadNewsService readNewsService; - @MockBean - private NewsRepository newsRepository; @Test @DisplayName("News 전체 조회 API가 수행되는가") @@ -76,18 +72,4 @@ void getDetailNewsNotFound() throws Exception { perform.andExpect(status().isNotFound()) .andExpect(jsonPath(ERROR_MESSAGE, NEWS_NOT_FOUND_ERROR.getErrorMessage()).exists()); } - - @Test - @DisplayName("조회한 News 전체 조회 API가 수행되는가") - void getReadNews() throws Exception{ - //when - final ResultActions perform = mockMvc.perform( - get("/read-news/viewed-history") - .contentType(MediaType.APPLICATION_JSON) - .header("Authorization", "Bearer " + accessToken) - ).andDo(print()); - - //then - perform.andExpect(status().isOk()); - } } diff --git a/backend/core/src/test/java/com/rollthedice/backend/domain/readNews/api/ReadNewsControllerTest.java b/backend/core/src/test/java/com/rollthedice/backend/domain/readNews/api/ReadNewsControllerTest.java new file mode 100644 index 00000000..78e7653e --- /dev/null +++ b/backend/core/src/test/java/com/rollthedice/backend/domain/readNews/api/ReadNewsControllerTest.java @@ -0,0 +1,35 @@ +package com.rollthedice.backend.domain.readNews.api; + +import com.rollthedice.backend.domain.readNews.service.ReadNewsService; +import com.rollthedice.backend.global.BaseControllerTest; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; +import org.springframework.test.web.servlet.ResultActions; + +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +@DisplayName("ReadNewsController의 ") +@WebMvcTest(ReadNewsController.class) +class ReadNewsControllerTest extends BaseControllerTest { + @MockBean + private ReadNewsService readNewsService; + + @Test + @DisplayName("조회한 News 전체 조회 API가 수행되는가") + void getReadNews() throws Exception{ + //when + final ResultActions perform = mockMvc.perform( + get("/read-news/viewed-history") + .contentType(MediaType.APPLICATION_JSON) + .header("Authorization", "Bearer " + accessToken) + ).andDo(print()); + + //then + perform.andExpect(status().isOk()); + } +} From 167d066c7d634cd0f237c381b17d1f4664379cb7 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 00:08:35 +0900 Subject: [PATCH 04/19] =?UTF-8?q?refactor:=20ReadNews=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EB=B6=84=EB=A6=AC=20repository=20Test=20=EC=A0=81?= =?UTF-8?q?=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/readNews/ReadNewsFixture.java | 23 +++++++++++++++++++ .../repository/ReadNewsRepositoryTest.java | 6 +++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 backend/core/src/test/java/com/rollthedice/backend/domain/readNews/ReadNewsFixture.java rename backend/core/src/test/java/com/rollthedice/backend/domain/{news => readNews}/repository/ReadNewsRepositoryTest.java (90%) diff --git a/backend/core/src/test/java/com/rollthedice/backend/domain/readNews/ReadNewsFixture.java b/backend/core/src/test/java/com/rollthedice/backend/domain/readNews/ReadNewsFixture.java new file mode 100644 index 00000000..96b77256 --- /dev/null +++ b/backend/core/src/test/java/com/rollthedice/backend/domain/readNews/ReadNewsFixture.java @@ -0,0 +1,23 @@ +package com.rollthedice.backend.domain.readNews; + +import com.rollthedice.backend.domain.member.entity.Member; +import com.rollthedice.backend.domain.news.dto.response.ReadNewsResponse; +import com.rollthedice.backend.domain.readNews.entity.ReadNews; + +import static com.rollthedice.backend.domain.news.NewsFixture.NEWS; + +public class ReadNewsFixture { + public static ReadNews READ_NEWS(Member member) { + return ReadNews.builder() + .member(member) + .news(NEWS(member)) + .build(); + } + + public static ReadNewsResponse READ_NEWS_RESPONSE() { + return ReadNewsResponse.builder() + .id(1L) + .title("임연지 대통령 되다.") + .build(); + } +} diff --git a/backend/core/src/test/java/com/rollthedice/backend/domain/news/repository/ReadNewsRepositoryTest.java b/backend/core/src/test/java/com/rollthedice/backend/domain/readNews/repository/ReadNewsRepositoryTest.java similarity index 90% rename from backend/core/src/test/java/com/rollthedice/backend/domain/news/repository/ReadNewsRepositoryTest.java rename to backend/core/src/test/java/com/rollthedice/backend/domain/readNews/repository/ReadNewsRepositoryTest.java index dea0fcf8..5e2bf860 100644 --- a/backend/core/src/test/java/com/rollthedice/backend/domain/news/repository/ReadNewsRepositoryTest.java +++ b/backend/core/src/test/java/com/rollthedice/backend/domain/readNews/repository/ReadNewsRepositoryTest.java @@ -1,9 +1,11 @@ -package com.rollthedice.backend.domain.news.repository; +package com.rollthedice.backend.domain.readNews.repository; import com.rollthedice.backend.domain.member.entity.Member; import com.rollthedice.backend.domain.member.repository.MemberRepository; import com.rollthedice.backend.domain.news.entity.News; import com.rollthedice.backend.domain.news.entity.NewsCategory; +import com.rollthedice.backend.domain.news.repository.NewsRepository; +import com.rollthedice.backend.domain.news.repository.ReadNewsRepository; import com.rollthedice.backend.domain.readNews.entity.ReadNews; import com.rollthedice.backend.support.RepositoryTest; import org.junit.jupiter.api.BeforeEach; @@ -18,7 +20,7 @@ @DisplayName("ReadNewsRepository의 ") @RepositoryTest -public class ReadNewsRepositoryTest { +class ReadNewsRepositoryTest { @Autowired private ReadNewsRepository readNewsRepository; @Autowired From 83d8a83b82b1d1ebdf31cac03e98b4026bff65a3 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 00:12:56 +0900 Subject: [PATCH 05/19] =?UTF-8?q?refactor:=20=ED=95=84=EC=9A=94=EC=97=86?= =?UTF-8?q?=EB=8A=94=20mock=20bean=20=EC=A3=BC=EC=9E=85=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/news/service/NewsServiceTest.java | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/backend/core/src/test/java/com/rollthedice/backend/domain/news/service/NewsServiceTest.java b/backend/core/src/test/java/com/rollthedice/backend/domain/news/service/NewsServiceTest.java index 0ebf8b3b..0ab9133e 100644 --- a/backend/core/src/test/java/com/rollthedice/backend/domain/news/service/NewsServiceTest.java +++ b/backend/core/src/test/java/com/rollthedice/backend/domain/news/service/NewsServiceTest.java @@ -16,7 +16,6 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; -import org.mockito.Mock; import org.mockito.junit.jupiter.MockitoExtension; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.mock.mockito.MockBean; @@ -33,7 +32,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockito.BDDMockito.given; -@Slf4j @DisplayName("NewsService의") @ExtendWith(MockitoExtension.class) class NewsServiceTest extends LoginTest { @@ -44,11 +42,7 @@ class NewsServiceTest extends LoginTest { @MockBean private NewsRepository newsRepository; @MockBean - private BookmarkRepository bookmarkRepository; - @MockBean private ReadNewsRepository readNewsRepository; - @Mock - private NewsMapper newsMapper; private News news; @@ -87,7 +81,7 @@ void getNews() { } @Test - @DisplayName("뉴스를 상세조회할 수 있는가") + @DisplayName("뉴스를 상세 조회할 수 있는가") void getDetailNews() { //given NewsDetailResponse expect = NEWS_DETAIL_RESPONSE(); From b6a091a565a42096b1cf7227f82bc8eaec020f04 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 00:14:01 +0900 Subject: [PATCH 06/19] refactor: lambda -> method reference --- .../backend/domain/readNews/service/ReadNewsService.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/service/ReadNewsService.java b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/service/ReadNewsService.java index c0203c4d..78795df1 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/service/ReadNewsService.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/service/ReadNewsService.java @@ -22,6 +22,6 @@ public class ReadNewsService { public List getReadNews() { Member member = authService.getMember(); List readNews = readNewsReository.getTop3ByMemberOrderByCreatedAtDesc(member); - return newsService.getNewsByReadNews(readNews.stream().map(r -> r.getNews()).collect(Collectors.toList())); + return newsService.getNewsByReadNews(readNews.stream().map(ReadNews::getNews).collect(Collectors.toList())); } } From 2a702cb292ad257dbc4a321844e45ece354f00e3 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 15:10:43 +0900 Subject: [PATCH 07/19] feat: success response --- .../global/common/response/SuccessCode.java | 19 +++++++++++++++++++ .../common/response/SuccessResponse.java | 18 ++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100644 backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java create mode 100644 backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessResponse.java diff --git a/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java b/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java new file mode 100644 index 00000000..e7911554 --- /dev/null +++ b/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java @@ -0,0 +1,19 @@ +package com.rollthedice.backend.global.common.response; + +import lombok.Getter; +import lombok.RequiredArgsConstructor; + +@Getter +@RequiredArgsConstructor +public enum SuccessCode { + // bookmark + GET_ALL_BOOKMARK_SUCCESS(200, "북마크 전체 조회를 성공했습니다."), + GET_IS_BOOKMARKED_SUCCESS(200, "뉴스가 북마크 여부 조회를 성공했습니다."), + CREATE_BOOKMARK_SUCCESS(201, "북마크 저장에 성공했습니다."), + DELETE_BOOKMARK_SUCCESS(204, "북마크 삭제에 성공했습니다."), + + ; + + private final int status; + private final String message; +} diff --git a/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessResponse.java b/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessResponse.java new file mode 100644 index 00000000..803b9ac9 --- /dev/null +++ b/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessResponse.java @@ -0,0 +1,18 @@ +package com.rollthedice.backend.global.common.response; + +public record SuccessResponse( + int status, + String message, + T data +) { + + private static final String NOTHING = ""; + + public static SuccessResponse of(SuccessCode code) { + return new SuccessResponse<>(code.getStatus(), code.getMessage(), NOTHING); + } + + public static SuccessResponse of(SuccessCode code, T data) { + return new SuccessResponse<>(code.getStatus(), code.getMessage(), data); + } +} From 330873729e94b16eefb5400f45dd4eff057ce39f Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 15:11:11 +0900 Subject: [PATCH 08/19] refactor: directory config -> common --- .../backend/global/{config => common}/BaseTimeEntity.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename backend/core/src/main/java/com/rollthedice/backend/global/{config => common}/BaseTimeEntity.java (93%) diff --git a/backend/core/src/main/java/com/rollthedice/backend/global/config/BaseTimeEntity.java b/backend/core/src/main/java/com/rollthedice/backend/global/common/BaseTimeEntity.java similarity index 93% rename from backend/core/src/main/java/com/rollthedice/backend/global/config/BaseTimeEntity.java rename to backend/core/src/main/java/com/rollthedice/backend/global/common/BaseTimeEntity.java index 5aff4ca7..fce2d4d0 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/global/config/BaseTimeEntity.java +++ b/backend/core/src/main/java/com/rollthedice/backend/global/common/BaseTimeEntity.java @@ -1,4 +1,4 @@ -package com.rollthedice.backend.global.config; +package com.rollthedice.backend.global.common; import jakarta.persistence.Column; import jakarta.persistence.EntityListeners; From 7f5720476ca7d3dd4205c73b19a6bb0fdd76922b Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 15:12:01 +0900 Subject: [PATCH 09/19] =?UTF-8?q?feat:=20BookmarkApi=EC=97=90=20success=20?= =?UTF-8?q?response=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/bookmark/api/BookmarkApi.java | 9 +++++---- .../bookmark/api/BookmarkController.java | 19 +++++++++++++------ 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkApi.java index d9673019..e8afb307 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkApi.java @@ -2,6 +2,7 @@ import com.rollthedice.backend.domain.bookmark.dto.response.BookmarkResponse; import com.rollthedice.backend.domain.news.dto.response.NewsResponse; +import com.rollthedice.backend.global.common.response.SuccessResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.ParameterIn; @@ -22,7 +23,7 @@ public interface BookmarkApi { responseCode = "200", description = "OK" ) - List getAllBookmarkedNews( + SuccessResponse> getAllBookmarkedNews( Pageable pageable ); @@ -36,7 +37,7 @@ List getAllBookmarkedNews( responseCode = "200", description = "OK" ) - BookmarkResponse getIsBookmarked( + SuccessResponse getIsBookmarked( @Parameter(in = ParameterIn.PATH, description = "뉴스 ID", required = true) Long newsId ); @@ -52,7 +53,7 @@ BookmarkResponse getIsBookmarked( responseCode = "201", description = "Created" ) - void saveBookmark( + SuccessResponse saveBookmark( @Parameter(in = ParameterIn.PATH, description = "뉴스 ID", required = true) Long newsId ); @@ -67,7 +68,7 @@ void saveBookmark( responseCode = "204", description = "No Content" ) - void deleteBookmark( + SuccessResponse deleteBookmark( @Parameter(in = ParameterIn.PATH, description = "뉴스 ID", required = true) Long newsId ); diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkController.java b/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkController.java index 23dd1b85..d9556f93 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkController.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkController.java @@ -3,6 +3,7 @@ import com.rollthedice.backend.domain.bookmark.dto.response.BookmarkResponse; import com.rollthedice.backend.domain.bookmark.service.BookmarkService; import com.rollthedice.backend.domain.news.dto.response.NewsResponse; +import com.rollthedice.backend.global.common.response.SuccessResponse; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; @@ -10,6 +11,8 @@ import java.util.List; +import static com.rollthedice.backend.global.common.response.SuccessCode.*; + @RestController @RequiredArgsConstructor @RequestMapping("bookmarks") @@ -19,28 +22,32 @@ public class BookmarkController implements BookmarkApi { @ResponseStatus(HttpStatus.OK) @GetMapping("") @Override - public List getAllBookmarkedNews(final Pageable pageable) { - return bookmarkService.getAllBookmarkedNews(pageable); + public SuccessResponse> getAllBookmarkedNews(final Pageable pageable) { + List response = bookmarkService.getAllBookmarkedNews(pageable); + return SuccessResponse.of(GET_ALL_BOOKMARK_SUCCESS, response); } @ResponseStatus(HttpStatus.OK) @GetMapping("/{newsId}") @Override - public BookmarkResponse getIsBookmarked(@PathVariable final Long newsId) { - return bookmarkService.getIsBookmarked(newsId); + public SuccessResponse getIsBookmarked(@PathVariable final Long newsId) { + BookmarkResponse response = bookmarkService.getIsBookmarked(newsId); + return SuccessResponse.of(GET_IS_BOOKMARKED_SUCCESS, response); } @ResponseStatus(HttpStatus.CREATED) @PostMapping("/{newsId}") @Override - public void saveBookmark(@PathVariable final Long newsId) { + public SuccessResponse saveBookmark(@PathVariable final Long newsId) { bookmarkService.saveBookmark(newsId); + return SuccessResponse.of(CREATE_BOOKMARK_SUCCESS); } @ResponseStatus(HttpStatus.NO_CONTENT) @DeleteMapping("/{newsId}") @Override - public void deleteBookmark(@PathVariable final Long newsId) { + public SuccessResponse deleteBookmark(@PathVariable final Long newsId) { bookmarkService.deleteBookmark(newsId); + return SuccessResponse.of(DELETE_BOOKMARK_SUCCESS); } } From b43489d4de194dd529ead19d5fe8f9158fd78ae6 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 15:13:28 +0900 Subject: [PATCH 10/19] =?UTF-8?q?refactor:=20BaseTimeEntity=20directory=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rollthedice/backend/domain/bookmark/entity/Bookmark.java | 2 +- .../backend/domain/debate/entity/DebateMessage.java | 4 +--- .../rollthedice/backend/domain/debate/entity/DebateRoom.java | 2 +- .../com/rollthedice/backend/domain/member/entity/Member.java | 2 +- .../java/com/rollthedice/backend/domain/news/entity/News.java | 2 +- .../rollthedice/backend/domain/readNews/entity/ReadNews.java | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/entity/Bookmark.java b/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/entity/Bookmark.java index 6af1d02f..f3cb925a 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/entity/Bookmark.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/entity/Bookmark.java @@ -2,7 +2,7 @@ import com.rollthedice.backend.domain.member.entity.Member; import com.rollthedice.backend.domain.news.entity.News; -import com.rollthedice.backend.global.config.BaseTimeEntity; +import com.rollthedice.backend.global.common.BaseTimeEntity; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Builder; diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/entity/DebateMessage.java b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/entity/DebateMessage.java index 91221c01..162926df 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/entity/DebateMessage.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/entity/DebateMessage.java @@ -1,7 +1,6 @@ package com.rollthedice.backend.domain.debate.entity; -import com.rollthedice.backend.domain.member.entity.Member; -import com.rollthedice.backend.global.config.BaseTimeEntity; +import com.rollthedice.backend.global.common.BaseTimeEntity; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Builder; @@ -31,5 +30,4 @@ public DebateMessage(String message, SenderType senderType, DebateRoom debateRoo this.senderType = senderType; this.debateRoom = debateRoom; } - } diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/entity/DebateRoom.java b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/entity/DebateRoom.java index 566463e4..8ffeb0f4 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/entity/DebateRoom.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/entity/DebateRoom.java @@ -1,7 +1,7 @@ package com.rollthedice.backend.domain.debate.entity; import com.rollthedice.backend.domain.member.entity.Member; -import com.rollthedice.backend.global.config.BaseTimeEntity; +import com.rollthedice.backend.global.common.BaseTimeEntity; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Builder; diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/member/entity/Member.java b/backend/core/src/main/java/com/rollthedice/backend/domain/member/entity/Member.java index 6395057d..390f7490 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/member/entity/Member.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/member/entity/Member.java @@ -1,7 +1,7 @@ package com.rollthedice.backend.domain.member.entity; import com.rollthedice.backend.domain.member.dto.MemberServiceDto; -import com.rollthedice.backend.global.config.BaseTimeEntity; +import com.rollthedice.backend.global.common.BaseTimeEntity; import jakarta.persistence.*; import lombok.*; diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/news/entity/News.java b/backend/core/src/main/java/com/rollthedice/backend/domain/news/entity/News.java index c96859cd..eba53bfe 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/news/entity/News.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/news/entity/News.java @@ -1,6 +1,6 @@ package com.rollthedice.backend.domain.news.entity; -import com.rollthedice.backend.global.config.BaseTimeEntity; +import com.rollthedice.backend.global.common.BaseTimeEntity; import jakarta.persistence.*; import lombok.*; import lombok.extern.slf4j.Slf4j; diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/entity/ReadNews.java b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/entity/ReadNews.java index 012fb466..2d6f23be 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/entity/ReadNews.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/entity/ReadNews.java @@ -2,7 +2,7 @@ import com.rollthedice.backend.domain.member.entity.Member; import com.rollthedice.backend.domain.news.entity.News; -import com.rollthedice.backend.global.config.BaseTimeEntity; +import com.rollthedice.backend.global.common.BaseTimeEntity; import jakarta.persistence.*; import lombok.AccessLevel; import lombok.Builder; From dc2bca4172d542c0a5c4392a9e86a0767600011d Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 18:17:14 +0900 Subject: [PATCH 11/19] =?UTF-8?q?feat:=20Debate=20API=20=EC=97=90=20Succes?= =?UTF-8?q?s=20Response=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/debate/api/DebateApi.java | 19 ++++---- .../domain/debate/api/DebateController.java | 44 ++++++++++++------- .../global/common/response/SuccessCode.java | 10 +++++ 3 files changed, 48 insertions(+), 25 deletions(-) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java index f70a4d3b..b61ada20 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java @@ -6,6 +6,7 @@ import com.rollthedice.backend.domain.debate.dto.response.DebateRoomResponse; import com.rollthedice.backend.domain.debate.dto.response.DebateRoomSaveResponse; import com.rollthedice.backend.domain.debate.dto.response.DebateSummaryResponse; +import com.rollthedice.backend.global.common.response.SuccessResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.ParameterIn; @@ -30,7 +31,7 @@ public interface DebateApi { responseCode = "201", description = "Created" ) - DebateRoomSaveResponse saveDebateRoom(@RequestBody DebateRoomRequest request); + SuccessResponse saveDebateRoom(@RequestBody DebateRoomRequest request); @Operation( summary = "토론방 전체 조회", @@ -42,7 +43,7 @@ public interface DebateApi { responseCode = "200", description = "요청에 성공하였습니다." ) - List getDebateRooms(Pageable pageable); + SuccessResponse> getDebateRooms(Pageable pageable); @Operation( summary = "토론방 삭제", @@ -54,7 +55,7 @@ public interface DebateApi { responseCode = "204", description = "토론방 삭제에 성공하였으며, 응답값은 없습니다." ) - void deleteDebateRoom(@Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) + SuccessResponse deleteDebateRoom(@Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) Long roomId ); @@ -68,7 +69,7 @@ void deleteDebateRoom(@Parameter(in = ParameterIn.PATH, description = "토론방 responseCode = "201", description = "Created" ) - void saveHumanDebateMessage( + SuccessResponse saveHumanDebateMessage( @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) Long roomId, @@ -85,7 +86,7 @@ void saveHumanDebateMessage( responseCode = "201", description = "Created" ) - void saveAIDebateMessage( + SuccessResponse saveAIDebateMessage( @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) Long roomId, @@ -108,7 +109,7 @@ void saveAIDebateMessage( description = "토론방을 찾지 못했습니다." ) }) - void finishDebate( + SuccessResponse finishDebate( @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) Long roomId ); @@ -123,7 +124,7 @@ void finishDebate( responseCode = "200", description = "요청에 성공하였습니다." ) - List getDebateMessages( + SuccessResponse> getDebateMessages( @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) Long roomId ); @@ -144,7 +145,7 @@ List getDebateMessages( description = "토론방을 찾지 못했습니다." ) }) - DebateSummaryResponse summarizeDebate( + SuccessResponse summarizeDebate( @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) Long roomId ); @@ -165,7 +166,7 @@ DebateSummaryResponse summarizeDebate( description = "토론방을 찾지 못했습니다." ) }) - DebateSummaryResponse getSummarizedDebate( + SuccessResponse getSummarizedDebate( @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) Long roomId ); diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateController.java b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateController.java index 9c5863aa..e43c256e 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateController.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateController.java @@ -8,6 +8,7 @@ import com.rollthedice.backend.domain.debate.dto.response.DebateSummaryResponse; import com.rollthedice.backend.domain.debate.service.DebateMessageService; import com.rollthedice.backend.domain.debate.service.DebateRoomService; +import com.rollthedice.backend.global.common.response.SuccessResponse; import jakarta.validation.Valid; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; @@ -16,6 +17,8 @@ import java.util.List; +import static com.rollthedice.backend.global.common.response.SuccessCode.*; + @RestController @RequiredArgsConstructor @RequestMapping("debates") @@ -26,62 +29,71 @@ public class DebateController implements DebateApi { @ResponseStatus(HttpStatus.CREATED) @PostMapping("") @Override - public DebateRoomSaveResponse saveDebateRoom(@RequestBody @Valid final DebateRoomRequest request) { - return debateRoomService.saveDebateRoom(request); + public SuccessResponse saveDebateRoom(@RequestBody @Valid final DebateRoomRequest request) { + DebateRoomSaveResponse response = debateRoomService.saveDebateRoom(request); + return SuccessResponse.of(CREATE_DEBATE_ROOM_SUCCESS, response); } @ResponseStatus(HttpStatus.OK) @GetMapping("") @Override - public List getDebateRooms(final Pageable pageable) { - return debateRoomService.getDebateRooms(pageable); + public SuccessResponse> getDebateRooms(final Pageable pageable) { + List response = debateRoomService.getDebateRooms(pageable); + return SuccessResponse.of(GET_ALL_DEBATE_ROOM_SUCCESS, response); } @ResponseStatus(HttpStatus.NO_CONTENT) @DeleteMapping("/{roomId}") @Override - public void deleteDebateRoom(@PathVariable final Long roomId) { + public SuccessResponse deleteDebateRoom(@PathVariable final Long roomId) { debateRoomService.deleteDebateRoom(roomId); + return SuccessResponse.of(DELETE_DEBATE_ROOM_SUCCESS); } @ResponseStatus(HttpStatus.CREATED) @PostMapping("/{roomId}/human") @Override - public void saveHumanDebateMessage(@PathVariable final Long roomId, @RequestBody final DebateMessageRequest request) { + public SuccessResponse saveHumanDebateMessage(@PathVariable final Long roomId, @RequestBody final DebateMessageRequest request) { debateMessageService.saveHumanDebateMessage(roomId, request); + return SuccessResponse.of(CREATE_HUMAN_DEBATE_MESSAGE_SUCCESS); } @ResponseStatus(HttpStatus.CREATED) @PostMapping("/{roomId}/ai") @Override - public void saveAIDebateMessage(@PathVariable final Long roomId, @RequestBody final DebateMessageRequest request) { + public SuccessResponse saveAIDebateMessage(@PathVariable final Long roomId, @RequestBody final DebateMessageRequest request) { debateMessageService.saveAIDebateMessage(roomId, request); + return SuccessResponse.of(CREATE_AI_DEBATE_MESSAGE_SUCCESS); } @ResponseStatus(HttpStatus.NO_CONTENT) @PatchMapping("/{roomId}") - public void finishDebate(@PathVariable final Long roomId) { + public SuccessResponse finishDebate(@PathVariable final Long roomId) { debateRoomService.closeDebate(roomId); + return SuccessResponse.of(UPDATE_DEBATE_ROOM_IS_CLOSED_SUCCESS); } - @ResponseStatus(HttpStatus.CREATED) + @ResponseStatus(HttpStatus.OK) @GetMapping("/{roomId}") @Override - public List getDebateMessages(@PathVariable final Long roomId) { - return debateMessageService.getDebateMessages(roomId); + public SuccessResponse> getDebateMessages(@PathVariable final Long roomId) { + List response = debateMessageService.getDebateMessages(roomId); + return SuccessResponse.of(GET_DEBATE_MESSAGES_SUCCESS, response); } - @ResponseStatus(HttpStatus.OK) + @ResponseStatus(HttpStatus.CREATED) @PostMapping("/summary/{roomId}") @Override - public DebateSummaryResponse summarizeDebate(@PathVariable final Long roomId) { - return debateRoomService.summaryDebate(roomId); + public SuccessResponse summarizeDebate(@PathVariable final Long roomId) { + DebateSummaryResponse response = debateRoomService.summaryDebate(roomId); + return SuccessResponse.of(CREATE_DEBATE_SUMMARY_SUCCESS, response); } @ResponseStatus(HttpStatus.OK) @GetMapping("/summary/{roomId}") @Override - public DebateSummaryResponse getSummarizedDebate(@PathVariable final Long roomId) { - return debateRoomService.getSummarizedDebate(roomId); + public SuccessResponse getSummarizedDebate(@PathVariable final Long roomId) { + DebateSummaryResponse response = debateRoomService.getSummarizedDebate(roomId); + return SuccessResponse.of(GET_DEBATE_MESSAGES_SUCCESS, response); } } diff --git a/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java b/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java index e7911554..ac21abd5 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java +++ b/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java @@ -12,6 +12,16 @@ public enum SuccessCode { CREATE_BOOKMARK_SUCCESS(201, "북마크 저장에 성공했습니다."), DELETE_BOOKMARK_SUCCESS(204, "북마크 삭제에 성공했습니다."), + // debate + CREATE_DEBATE_ROOM_SUCCESS(201, "토론방 생성에 성공했습니다."), + GET_ALL_DEBATE_ROOM_SUCCESS(200, "토론방 전체 조회에 성공했습니다"), + DELETE_DEBATE_ROOM_SUCCESS(204, "토론방 삭제에 성공했습니다."), + CREATE_HUMAN_DEBATE_MESSAGE_SUCCESS(201, "사용자가 보낸 토론 메세지 저장에 성공했습니다."), + CREATE_AI_DEBATE_MESSAGE_SUCCESS(201, "AI가 보낸 토론 메세지 저장에 성공했습니다."), + UPDATE_DEBATE_ROOM_IS_CLOSED_SUCCESS(204, "토론 종료에 성공했습니다."), + GET_DEBATE_MESSAGES_SUCCESS(200, "토론 메세지 조회에 성공했습니다."), + CREATE_DEBATE_SUMMARY_SUCCESS(201, "토론 요약에 성공했습니다."), + GET_DEBATE_SUMMARY_SUCCESS(200, "토론 요약 조회에 성공했습니다."), ; private final int status; From cebd6bfd96e79844ef1adfcdb701fda36c00f5b3 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 18:20:00 +0900 Subject: [PATCH 12/19] =?UTF-8?q?feat:=20Member=20API=EC=97=90=20Success?= =?UTF-8?q?=20Response=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/member/api/MemberApi.java | 3 ++- .../backend/domain/member/api/MemberController.java | 12 ++++++------ .../backend/global/common/response/SuccessCode.java | 4 ++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberApi.java index 3f87ce34..273ade92 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberApi.java @@ -1,6 +1,7 @@ package com.rollthedice.backend.domain.member.api; import com.rollthedice.backend.domain.member.dto.response.MemberResponse; +import com.rollthedice.backend.global.common.response.SuccessResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; @@ -16,5 +17,5 @@ public interface MemberApi { responseCode = "200", description = "OK" ) - MemberResponse getMemberInfo(); + SuccessResponse getMemberInfo(); } diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberController.java b/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberController.java index 63411b19..d625e588 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberController.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberController.java @@ -1,15 +1,14 @@ package com.rollthedice.backend.domain.member.api; -import com.rollthedice.backend.domain.member.dto.MemberServiceDto; -import com.rollthedice.backend.domain.member.dto.MemberUpdateDto; import com.rollthedice.backend.domain.member.dto.response.MemberResponse; import com.rollthedice.backend.domain.member.service.MemberService; -import com.rollthedice.backend.global.annotation.LoginMemberEmail; +import com.rollthedice.backend.global.common.response.SuccessResponse; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; -import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import static com.rollthedice.backend.global.common.response.SuccessCode.GET_MEMBER_INFO_SUCCESS; + @RestController @RequiredArgsConstructor @RequestMapping("members") @@ -19,7 +18,8 @@ public class MemberController implements MemberApi{ @ResponseStatus(HttpStatus.OK) @GetMapping("") @Override - public MemberResponse getMemberInfo() { - return memberService.getMemberInfo(); + public SuccessResponse getMemberInfo() { + MemberResponse response = memberService.getMemberInfo(); + return SuccessResponse.of(GET_MEMBER_INFO_SUCCESS, response); } } diff --git a/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java b/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java index ac21abd5..d7f5105d 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java +++ b/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java @@ -22,6 +22,10 @@ public enum SuccessCode { GET_DEBATE_MESSAGES_SUCCESS(200, "토론 메세지 조회에 성공했습니다."), CREATE_DEBATE_SUMMARY_SUCCESS(201, "토론 요약에 성공했습니다."), GET_DEBATE_SUMMARY_SUCCESS(200, "토론 요약 조회에 성공했습니다."), + + // member + GET_MEMBER_INFO_SUCCESS(200, "사용자 정보 조회에 성공했습니다."), + ; private final int status; From 107726b61776a4dffa0f326aaa39941e3231ec67 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 18:23:34 +0900 Subject: [PATCH 13/19] =?UTF-8?q?feat:=20News=20API=EC=97=90=20Success=20R?= =?UTF-8?q?esponse=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/news/api/NewsApi.java | 5 +++-- .../backend/domain/news/api/NewsController.java | 14 ++++++++++---- .../global/common/response/SuccessCode.java | 4 ++++ 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java index a152eebc..5cc4c906 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java @@ -3,6 +3,7 @@ import com.rollthedice.backend.domain.news.dto.response.NewsDetailResponse; import com.rollthedice.backend.domain.news.dto.response.NewsResponse; import com.rollthedice.backend.domain.news.dto.response.ReadNewsResponse; +import com.rollthedice.backend.global.common.response.SuccessResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.enums.ParameterIn; @@ -24,7 +25,7 @@ public interface NewsApi { responseCode = "200", description = "요청에 성공하였습니다." ) - List getNews(Pageable pageable); + SuccessResponse> getNews(Pageable pageable); @Operation( summary = "요약 뉴스 상세 조회", @@ -42,7 +43,7 @@ public interface NewsApi { description = "뉴스를 찾지 못했습니다." ) }) - NewsDetailResponse getDetailNews( + SuccessResponse getDetailNews( @Parameter(in = ParameterIn.PATH, description = "뉴스 ID", required = true) Long newsId ); diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsController.java b/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsController.java index 84407564..977d1922 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsController.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsController.java @@ -3,6 +3,7 @@ import com.rollthedice.backend.domain.news.dto.response.NewsDetailResponse; import com.rollthedice.backend.domain.news.dto.response.NewsResponse; import com.rollthedice.backend.domain.news.service.NewsService; +import com.rollthedice.backend.global.common.response.SuccessResponse; import lombok.RequiredArgsConstructor; import org.springframework.data.domain.Pageable; import org.springframework.http.HttpStatus; @@ -10,6 +11,9 @@ import java.util.List; +import static com.rollthedice.backend.global.common.response.SuccessCode.GET_ALL_NEWS_SUCCESS; +import static com.rollthedice.backend.global.common.response.SuccessCode.GET_DETAIL_NEWS_SUCCESS; + @RestController @RequiredArgsConstructor @RequestMapping("news") @@ -19,14 +23,16 @@ public class NewsController implements NewsApi { @ResponseStatus(HttpStatus.OK) @GetMapping("") @Override - public List getNews(final Pageable pageable) { - return newsService.getNews(pageable); + public SuccessResponse> getNews(final Pageable pageable) { + List response = newsService.getNews(pageable); + return SuccessResponse.of(GET_ALL_NEWS_SUCCESS, response); } @ResponseStatus(HttpStatus.OK) @GetMapping("/{newsId}") @Override - public NewsDetailResponse getDetailNews(final @PathVariable Long newsId) { - return newsService.getDetailNews(newsId); + public SuccessResponse getDetailNews(final @PathVariable Long newsId) { + NewsDetailResponse response = newsService.getDetailNews(newsId); + return SuccessResponse.of(GET_DETAIL_NEWS_SUCCESS, response); } } diff --git a/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java b/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java index d7f5105d..d7cae1cb 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java +++ b/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java @@ -26,6 +26,10 @@ public enum SuccessCode { // member GET_MEMBER_INFO_SUCCESS(200, "사용자 정보 조회에 성공했습니다."), + // news + GET_ALL_NEWS_SUCCESS(200, "전체 뉴스 조회에 성공했습니다."), + GET_DETAIL_NEWS_SUCCESS(200, "요약 뉴스 상세 조회에 성공했습니다."), + ; private final int status; From d94fb91a3ed38b9dfb03342fa7b5fb472a1faeb7 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 18:26:40 +0900 Subject: [PATCH 14/19] =?UTF-8?q?feat:=20ReadNews=20API=EC=97=90=20Success?= =?UTF-8?q?=20Response=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/readNews/api/ReadNewsApi.java | 3 ++- .../backend/domain/readNews/api/ReadNewsController.java | 8 ++++++-- .../backend/global/common/response/SuccessCode.java | 3 +++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.java index 59aff96e..d8e86ce0 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.java @@ -1,6 +1,7 @@ package com.rollthedice.backend.domain.readNews.api; import com.rollthedice.backend.domain.news.dto.response.ReadNewsResponse; +import com.rollthedice.backend.global.common.response.SuccessResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; @@ -18,5 +19,5 @@ public interface ReadNewsApi { responseCode = "200", description = "요청에 성공하였습니다." ) - List getReadNews(); + SuccessResponse> getReadNews(); } diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsController.java b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsController.java index e32da2b7..67d02ed2 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsController.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsController.java @@ -2,6 +2,7 @@ import com.rollthedice.backend.domain.news.dto.response.ReadNewsResponse; import com.rollthedice.backend.domain.readNews.service.ReadNewsService; +import com.rollthedice.backend.global.common.response.SuccessResponse; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; @@ -11,6 +12,8 @@ import java.util.List; +import static com.rollthedice.backend.global.common.response.SuccessCode.GET_RECENT_READ_NEWS_SUCCESS; + @RestController @RequiredArgsConstructor @RequestMapping("read-news") @@ -21,7 +24,8 @@ public class ReadNewsController implements ReadNewsApi { @ResponseStatus(HttpStatus.OK) @GetMapping("/viewed-history") @Override - public List getReadNews() { - return readNewsService.getReadNews(); + public SuccessResponse> getReadNews() { + List response = readNewsService.getReadNews(); + return SuccessResponse.of(GET_RECENT_READ_NEWS_SUCCESS, response); } } diff --git a/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java b/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java index d7cae1cb..d22af479 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java +++ b/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java @@ -30,6 +30,9 @@ public enum SuccessCode { GET_ALL_NEWS_SUCCESS(200, "전체 뉴스 조회에 성공했습니다."), GET_DETAIL_NEWS_SUCCESS(200, "요약 뉴스 상세 조회에 성공했습니다."), + // read news + GET_RECENT_READ_NEWS_SUCCESS(200, "최근 읽은 뉴스 조회에 성공했습니다."), + ; private final int status; From e33a25e2dc4c6cf754b6dee8ea66e644283ae018 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 18:32:22 +0900 Subject: [PATCH 15/19] =?UTF-8?q?feat:=20Statistics=20API=EC=97=90=20Succe?= =?UTF-8?q?ss=20Response=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/statistics/api/StatisticsApi.java | 5 +++-- .../statistics/api/StatisticsController.java | 14 ++++++++++---- .../global/common/response/SuccessCode.java | 3 +++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/api/StatisticsApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/api/StatisticsApi.java index 6866c2bb..04993f4b 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/api/StatisticsApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/api/StatisticsApi.java @@ -2,6 +2,7 @@ import com.rollthedice.backend.domain.statistics.dto.response.CategoryStatisticsResponse; import com.rollthedice.backend.domain.statistics.dto.response.DateViewStatisticsResponse; +import com.rollthedice.backend.global.common.response.SuccessResponse; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; @@ -19,7 +20,7 @@ public interface StatisticsApi { responseCode = "200", description = "요청에 성공하였습니다." ) - List getViewsOfDates(); + SuccessResponse> getViewsOfDates(); @Operation( summary = "카테고리별 조회수 조회", @@ -31,5 +32,5 @@ public interface StatisticsApi { responseCode = "200", description = "요청에 성공하였습니다." ) - List getCategoryStatistics(); + SuccessResponse> getCategoryStatistics(); } diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/api/StatisticsController.java b/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/api/StatisticsController.java index 8dc19f3d..14634964 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/api/StatisticsController.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/api/StatisticsController.java @@ -3,6 +3,7 @@ import com.rollthedice.backend.domain.statistics.dto.response.CategoryStatisticsResponse; import com.rollthedice.backend.domain.statistics.dto.response.DateViewStatisticsResponse; import com.rollthedice.backend.domain.statistics.service.StatisticsService; +import com.rollthedice.backend.global.common.response.SuccessResponse; import lombok.RequiredArgsConstructor; import org.springframework.http.HttpStatus; import org.springframework.web.bind.annotation.GetMapping; @@ -12,6 +13,9 @@ import java.util.List; +import static com.rollthedice.backend.global.common.response.SuccessCode.GET_CATEGORY_VIEWS_SUCCESS; +import static com.rollthedice.backend.global.common.response.SuccessCode.GET_VIEWS_OF_DATE_SUCCESS; + @RestController @RequiredArgsConstructor @RequestMapping("statistics") @@ -21,14 +25,16 @@ public class StatisticsController implements StatisticsApi { @ResponseStatus(HttpStatus.OK) @GetMapping("/per-dates") @Override - public List getViewsOfDates() { - return statisticsService.getViewsOfDates(); + public SuccessResponse> getViewsOfDates() { + List response = statisticsService.getViewsOfDates(); + return SuccessResponse.of(GET_VIEWS_OF_DATE_SUCCESS, response); } @ResponseStatus(HttpStatus.OK) @GetMapping("/categories") @Override - public List getCategoryStatistics() { - return statisticsService.getCategoryStatistics(); + public SuccessResponse> getCategoryStatistics() { + List response = statisticsService.getCategoryStatistics(); + return SuccessResponse.of(GET_CATEGORY_VIEWS_SUCCESS, response); } } diff --git a/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java b/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java index d22af479..dfb73283 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java +++ b/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java @@ -33,6 +33,9 @@ public enum SuccessCode { // read news GET_RECENT_READ_NEWS_SUCCESS(200, "최근 읽은 뉴스 조회에 성공했습니다."), + // statistics + GET_VIEWS_OF_DATE_SUCCESS(200, "최근 일주일 날짜별 뉴스 조회수 조회에 성공했습니다."), + GET_CATEGORY_VIEWS_SUCCESS(200, "카테고리별 조회수 조회에 성공했습니다."), ; private final int status; From 7c4567db107763a4368b927a6f33e5755b83fba0 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 18:39:53 +0900 Subject: [PATCH 16/19] =?UTF-8?q?feat:=20Auth=20API=EC=97=90=20Success=20R?= =?UTF-8?q?esponse=20=EC=A0=81=EC=9A=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../global/common/response/SuccessCode.java | 4 ++++ .../backend/global/oauth2/api/AuthApi.java | 11 ++++++----- .../backend/global/oauth2/api/AuthController.java | 15 ++++++++++----- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java b/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java index dfb73283..0adb906f 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java +++ b/backend/core/src/main/java/com/rollthedice/backend/global/common/response/SuccessCode.java @@ -36,6 +36,10 @@ public enum SuccessCode { // statistics GET_VIEWS_OF_DATE_SUCCESS(200, "최근 일주일 날짜별 뉴스 조회수 조회에 성공했습니다."), GET_CATEGORY_VIEWS_SUCCESS(200, "카테고리별 조회수 조회에 성공했습니다."), + + // auth + GET_SOCIAL_LOGIN_SUCCESS(201, "소셜 로그인에 성공했습니다."), + UPDATE_NICKNAME_SUCCESS(204, "닉네임 입력에 성공했습니다.") ; private final int status; diff --git a/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/api/AuthApi.java b/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/api/AuthApi.java index b8528389..042de62c 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/api/AuthApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/api/AuthApi.java @@ -1,6 +1,7 @@ package com.rollthedice.backend.global.oauth2.api; import com.rollthedice.backend.domain.member.dto.MemberUpdateDto; +import com.rollthedice.backend.global.common.response.SuccessResponse; import com.rollthedice.backend.global.oauth2.dto.LoginRequest; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; @@ -18,10 +19,10 @@ public interface AuthApi { tags = {"인증"} ) @ApiResponse( - responseCode = "201", - description = "Created" + responseCode = "200", + description = "소셜 로그인에 성공했습니다." ) - ResponseEntity login( + SuccessResponse login( @RequestBody LoginRequest request, HttpServletResponse response ); @@ -34,9 +35,9 @@ ResponseEntity login( ) @ApiResponse( responseCode = "201", - description = "Created" + description = "닉네임 입력에 성공했습니다." ) - ResponseEntity updateMember( + SuccessResponse updateMember( String email, @RequestBody MemberUpdateDto memberUpdateDto ); diff --git a/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/api/AuthController.java b/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/api/AuthController.java index dad5b0f7..27ba7e0a 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/api/AuthController.java +++ b/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/api/AuthController.java @@ -3,6 +3,7 @@ import com.rollthedice.backend.domain.member.dto.MemberUpdateDto; import com.rollthedice.backend.domain.member.service.MemberService; import com.rollthedice.backend.global.annotation.LoginMemberEmail; +import com.rollthedice.backend.global.common.response.SuccessResponse; import com.rollthedice.backend.global.oauth2.dto.LoginRequest; import com.rollthedice.backend.global.oauth2.service.AuthService; import jakarta.servlet.http.HttpServletResponse; @@ -12,8 +13,12 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.ResponseStatus; import org.springframework.web.bind.annotation.RestController; +import static com.rollthedice.backend.global.common.response.SuccessCode.GET_SOCIAL_LOGIN_SUCCESS; +import static com.rollthedice.backend.global.common.response.SuccessCode.UPDATE_NICKNAME_SUCCESS; + @Slf4j @RestController @RequiredArgsConstructor @@ -21,20 +26,20 @@ public class AuthController implements AuthApi { private final AuthService authService; private final MemberService memberService; + @ResponseStatus(HttpStatus.OK) @PostMapping("/login") @Override - public ResponseEntity login(@RequestBody LoginRequest request, HttpServletResponse response) { + public SuccessResponse login(@RequestBody LoginRequest request, HttpServletResponse response) { authService.authenticateOrRegisterUser(request, response); - return new ResponseEntity<>(HttpStatus.OK); + return SuccessResponse.of(GET_SOCIAL_LOGIN_SUCCESS); } @PostMapping("/oauth2/sign-up") @Override - public ResponseEntity updateMember(@LoginMemberEmail String email, + public SuccessResponse updateMember(@LoginMemberEmail String email, @RequestBody MemberUpdateDto memberUpdateDto) { memberService.update(memberUpdateDto); - - return ResponseEntity.status(HttpStatus.OK).build(); + return SuccessResponse.of(UPDATE_NICKNAME_SUCCESS); } } \ No newline at end of file From 86c8b0a3db945427e2b88e1c7bc2c877258b54e8 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 18:45:09 +0900 Subject: [PATCH 17/19] =?UTF-8?q?feat:=20success=20message=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/bookmark/api/BookmarkApi.java | 8 ++++---- .../backend/domain/debate/api/DebateApi.java | 18 +++++++++--------- .../backend/domain/member/api/MemberApi.java | 2 +- .../backend/domain/news/api/NewsApi.java | 4 ++-- .../domain/readNews/api/ReadNewsApi.java | 2 +- .../domain/statistics/api/StatisticsApi.java | 4 ++-- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkApi.java index e8afb307..7eff090b 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkApi.java @@ -21,7 +21,7 @@ public interface BookmarkApi { ) @ApiResponse( responseCode = "200", - description = "OK" + description = "북마크 전체 조회를 성공했습니다." ) SuccessResponse> getAllBookmarkedNews( Pageable pageable @@ -35,7 +35,7 @@ SuccessResponse> getAllBookmarkedNews( ) @ApiResponse( responseCode = "200", - description = "OK" + description = "뉴스가 북마크 여부 조회를 성공했습니다." ) SuccessResponse getIsBookmarked( @Parameter(in = ParameterIn.PATH, description = "뉴스 ID", required = true) @@ -51,7 +51,7 @@ SuccessResponse getIsBookmarked( ) @ApiResponse( responseCode = "201", - description = "Created" + description = "북마크 저장에 성공했습니다." ) SuccessResponse saveBookmark( @Parameter(in = ParameterIn.PATH, description = "뉴스 ID", required = true) @@ -66,7 +66,7 @@ SuccessResponse saveBookmark( ) @ApiResponse( responseCode = "204", - description = "No Content" + description = "북마크 삭제에 성공했습니다." ) SuccessResponse deleteBookmark( @Parameter(in = ParameterIn.PATH, description = "뉴스 ID", required = true) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java index b61ada20..f1093280 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java @@ -29,7 +29,7 @@ public interface DebateApi { ) @ApiResponse( responseCode = "201", - description = "Created" + description = "토론방 생성에 성공했습니다." ) SuccessResponse saveDebateRoom(@RequestBody DebateRoomRequest request); @@ -41,7 +41,7 @@ public interface DebateApi { ) @ApiResponse( responseCode = "200", - description = "요청에 성공하였습니다." + description = "토론방 전체 조회에 성공했습니다" ) SuccessResponse> getDebateRooms(Pageable pageable); @@ -53,7 +53,7 @@ public interface DebateApi { ) @ApiResponse( responseCode = "204", - description = "토론방 삭제에 성공하였으며, 응답값은 없습니다." + description = "토론방 삭제에 성공했습니다." ) SuccessResponse deleteDebateRoom(@Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) Long roomId @@ -67,7 +67,7 @@ SuccessResponse deleteDebateRoom(@Parameter(in = ParameterIn.PATH, descr ) @ApiResponse( responseCode = "201", - description = "Created" + description = "사용자가 보낸 토론 메세지 저장에 성공했습니다." ) SuccessResponse saveHumanDebateMessage( @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) @@ -84,7 +84,7 @@ SuccessResponse saveHumanDebateMessage( ) @ApiResponse( responseCode = "201", - description = "Created" + description = "AI가 보낸 토론 메세지 저장에 성공했습니다." ) SuccessResponse saveAIDebateMessage( @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) @@ -102,7 +102,7 @@ SuccessResponse saveAIDebateMessage( @ApiResponses(value = { @ApiResponse( responseCode = "204", - description = "요청에 성공하였으며 응답값은 없습니다." + description = "토론 종료에 성공했습니다." ), @ApiResponse( responseCode = "404", @@ -122,7 +122,7 @@ SuccessResponse finishDebate( ) @ApiResponse( responseCode = "200", - description = "요청에 성공하였습니다." + description = "토론 메세지 조회에 성공했습니다." ) SuccessResponse> getDebateMessages( @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) @@ -138,7 +138,7 @@ SuccessResponse> getDebateMessages( @ApiResponses(value = { @ApiResponse( responseCode = "201", - description = "토론 요약이 성공하였습니다." + description = "토론 요약에 성공했습니다." ), @ApiResponse( responseCode = "404", @@ -159,7 +159,7 @@ SuccessResponse summarizeDebate( @ApiResponses(value = { @ApiResponse( responseCode = "200", - description = "요청에 성공하였습니다." + description = "토론 요약 조회에 성공했습니다." ), @ApiResponse( responseCode = "404", diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberApi.java index 273ade92..fcb8ad10 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberApi.java @@ -15,7 +15,7 @@ public interface MemberApi { ) @ApiResponse( responseCode = "200", - description = "OK" + description = "사용자 정보 조회에 성공했습니다." ) SuccessResponse getMemberInfo(); } diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java index 5cc4c906..78b8356b 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java @@ -23,7 +23,7 @@ public interface NewsApi { ) @ApiResponse( responseCode = "200", - description = "요청에 성공하였습니다." + description = "전체 뉴스 조회에 성공했습니다." ) SuccessResponse> getNews(Pageable pageable); @@ -36,7 +36,7 @@ public interface NewsApi { @ApiResponses(value = { @ApiResponse( responseCode = "200", - description = "요청에 성공하였습니다." + description = "요약 뉴스 상세 조회에 성공했습니다." ), @ApiResponse( responseCode = "404", diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.java index d8e86ce0..d52f7065 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.java @@ -17,7 +17,7 @@ public interface ReadNewsApi { ) @ApiResponse( responseCode = "200", - description = "요청에 성공하였습니다." + description = "최근 읽은 뉴스 조회에 성공했습니다." ) SuccessResponse> getReadNews(); } diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/api/StatisticsApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/api/StatisticsApi.java index 04993f4b..80066ddc 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/api/StatisticsApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/api/StatisticsApi.java @@ -18,7 +18,7 @@ public interface StatisticsApi { ) @ApiResponse( responseCode = "200", - description = "요청에 성공하였습니다." + description = "최근 일주일 날짜별 뉴스 조회수 조회에 성공했습니다." ) SuccessResponse> getViewsOfDates(); @@ -30,7 +30,7 @@ public interface StatisticsApi { ) @ApiResponse( responseCode = "200", - description = "요청에 성공하였습니다." + description = "카테고리별 조회수 조회에 성공했습니다." ) SuccessResponse> getCategoryStatistics(); } From 79686b88da94784dc97fe3feae241b9f26b01c62 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 18:51:09 +0900 Subject: [PATCH 18/19] refactor: swagger tags -> @Tag --- .../domain/bookmark/api/BookmarkApi.java | 14 ++++----- .../backend/domain/debate/api/DebateApi.java | 31 +++++++------------ .../backend/domain/member/api/MemberApi.java | 5 +-- .../backend/domain/news/api/NewsApi.java | 8 ++--- .../domain/readNews/api/ReadNewsApi.java | 5 +-- .../domain/statistics/api/StatisticsApi.java | 8 ++--- .../backend/global/oauth2/api/AuthApi.java | 8 ++--- 7 files changed, 35 insertions(+), 44 deletions(-) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkApi.java index 7eff090b..3b0e9760 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/bookmark/api/BookmarkApi.java @@ -8,16 +8,17 @@ import io.swagger.v3.oas.annotations.enums.ParameterIn; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.data.domain.Pageable; import java.util.List; +@Tag(name = "Bookmark") public interface BookmarkApi { @Operation( summary = "북마크 전체 조회", description = "회원이 북마크한 뉴스를 페이지로 나누어 조회합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"북마크"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "200", @@ -30,8 +31,7 @@ SuccessResponse> getAllBookmarkedNews( @Operation( summary = "뉴스 북마크 여부 조회", description = "로그인한 회원이 해당 뉴스를 북마크 했는지 여부를 조회합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"북마크"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "200", @@ -46,8 +46,7 @@ SuccessResponse getIsBookmarked( @Operation( summary = "북마크 저장", description = "뉴스에 대하여 북마크로 저장합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"북마크"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "201", @@ -61,8 +60,7 @@ SuccessResponse saveBookmark( @Operation( summary = "북마크 삭제", description = "저장된 북마크를 해제합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"북마크"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "204", diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java index f1093280..8c808f47 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/api/DebateApi.java @@ -13,19 +13,19 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.data.domain.Pageable; import org.springframework.web.bind.annotation.RequestBody; import java.util.List; - +@Tag(name = "Debate") public interface DebateApi { @Operation( summary = "토론방 생성", description = "주제가 선택된 토론방을 생성합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"토론방"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "201", @@ -36,8 +36,7 @@ public interface DebateApi { @Operation( summary = "토론방 전체 조회", description = "회원의 토론방을 페이지로 나누어 조회합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"토론방"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "200", @@ -48,8 +47,7 @@ public interface DebateApi { @Operation( summary = "토론방 삭제", description = "토론방을 삭제합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"토론방"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "204", @@ -62,8 +60,7 @@ SuccessResponse deleteDebateRoom(@Parameter(in = ParameterIn.PATH, descr @Operation( summary = "[인간] 토론 메세지 저장", description = "사용자가 보낸 토론 메세지를 저장합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"토론 메세지"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "201", @@ -79,8 +76,7 @@ SuccessResponse saveHumanDebateMessage( @Operation( summary = "[AI] 토론 메세지 저장", description = "ChatGPT OPENAI가 보낸 토론 메세지를 저장합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"토론 메세지"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "201", @@ -96,8 +92,7 @@ SuccessResponse saveAIDebateMessage( @Operation( summary = "토론 종료", description = "토론을 종료합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"토론방"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponses(value = { @ApiResponse( @@ -117,8 +112,7 @@ SuccessResponse finishDebate( @Operation( summary = "토론 메세지 조회", description = "토론방의 토론 메세지 이력을 조회합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"토론 메세지"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "200", @@ -132,8 +126,7 @@ SuccessResponse> getDebateMessages( @Operation( summary = "토론 요약", description = "토론방의 토론 메세지들을 요약합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"토론방"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponses(value = { @ApiResponse( @@ -153,8 +146,7 @@ SuccessResponse summarizeDebate( @Operation( summary = "토론 요약 조회", description = "토론 요약 내용을 조회합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"토론방"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponses(value = { @ApiResponse( @@ -170,5 +162,4 @@ SuccessResponse getSummarizedDebate( @Parameter(in = ParameterIn.PATH, description = "토론방 ID", required = true) Long roomId ); - } diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberApi.java index fcb8ad10..3ebcc3ee 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/member/api/MemberApi.java @@ -5,13 +5,14 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; +@Tag(name = "Member") public interface MemberApi { @Operation( summary = "회원 정보 조회", description = "회원 정보를 조회합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"member"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "200", diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java index 78b8356b..ccc2d8c8 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/news/api/NewsApi.java @@ -10,16 +10,17 @@ import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.responses.ApiResponses; import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.data.domain.Pageable; import java.util.List; +@Tag(name = "Tag") public interface NewsApi { @Operation( summary = "요약 뉴스 전체 조회", description = "요약 뉴스를 페이지로 나누어 조회합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"news"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "200", @@ -30,8 +31,7 @@ public interface NewsApi { @Operation( summary = "요약 뉴스 상세 조회", description = "하나의 요약 뉴스를 상세 조회합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"news"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponses(value = { @ApiResponse( diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.java index d52f7065..6279d7e8 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/readNews/api/ReadNewsApi.java @@ -5,15 +5,16 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import java.util.List; +@Tag(name = "Read News") public interface ReadNewsApi { @Operation( summary = "최근 읽은 뉴스 조회", description = "가장 최근에 읽은 3개의 뉴스를 조회합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"news"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "200", diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/api/StatisticsApi.java b/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/api/StatisticsApi.java index 80066ddc..be7e86e7 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/api/StatisticsApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/statistics/api/StatisticsApi.java @@ -6,15 +6,16 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import java.util.List; +@Tag(name = "Statistics") public interface StatisticsApi { @Operation( summary = "최근 일주일 날짜별 뉴스 조회수 조회", description = "최근 일주일간 날짜별로 뉴스 조회수를 조회합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"통계"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "200", @@ -25,8 +26,7 @@ public interface StatisticsApi { @Operation( summary = "카테고리별 조회수 조회", description = "카테고리별 조회수를 조회합니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"통계"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "200", diff --git a/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/api/AuthApi.java b/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/api/AuthApi.java index 042de62c..c9cabee7 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/api/AuthApi.java +++ b/backend/core/src/main/java/com/rollthedice/backend/global/oauth2/api/AuthApi.java @@ -6,17 +6,18 @@ import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.responses.ApiResponse; import io.swagger.v3.oas.annotations.security.SecurityRequirement; +import io.swagger.v3.oas.annotations.tags.Tag; import jakarta.servlet.http.HttpServletResponse; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.RequestBody; +@Tag(name = "Auth") public interface AuthApi { @Operation( summary = "소셜 로그인", description = "소셜 로그인을 합니다. 회원가입이 되어있지 않은 회원일 경우, 회원가입이 진행됩니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"인증"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "200", @@ -30,8 +31,7 @@ SuccessResponse login( @Operation( summary = "닉네임 입력", description = "닉네임을 입력합니다. 해당 로직이 진행되어야 회원가입이 완료됩니다.", - security = {@SecurityRequirement(name = "access_token")}, - tags = {"인증"} + security = {@SecurityRequirement(name = "access_token")} ) @ApiResponse( responseCode = "201", From 43f02088d6de5c504b09e9f7e483cd21e5e296e0 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 18:51:37 +0900 Subject: [PATCH 19/19] =?UTF-8?q?refactor:=20=ED=95=84=EC=9A=94=EC=97=86?= =?UTF-8?q?=EB=8A=94=20log=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../backend/domain/debate/service/ClovaSummary.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/service/ClovaSummary.java b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/service/ClovaSummary.java index 6f1b71d7..c4a2f3c9 100644 --- a/backend/core/src/main/java/com/rollthedice/backend/domain/debate/service/ClovaSummary.java +++ b/backend/core/src/main/java/com/rollthedice/backend/domain/debate/service/ClovaSummary.java @@ -36,15 +36,12 @@ public class ClovaSummary { private String CLIENT_ID; public String summaryDebate(String messages) { - log.info("요약할 메세지: {}" ,messages); try { URL url = new URL(API_URL); HttpURLConnection connection = createRequestHeader(url); createRequestBody(connection, messages); - log.info("정상1"); StringBuilder response = getResponse(connection); - log.info("정상2"); return parseResponse(response); } catch (Exception e) { e.printStackTrace();