From e33a25e2dc4c6cf754b6dee8ea66e644283ae018 Mon Sep 17 00:00:00 2001 From: yeonjy Date: Sun, 30 Jun 2024 18:32:22 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20Statistics=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 --- .../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;