Skip to content

Commit

Permalink
feat: Statistics API에 Success Response 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
yeonjy committed Jun 30, 2024
1 parent d94fb91 commit e33a25e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -19,7 +20,7 @@ public interface StatisticsApi {
responseCode = "200",
description = "요청에 성공하였습니다."
)
List<DateViewStatisticsResponse> getViewsOfDates();
SuccessResponse<List<DateViewStatisticsResponse>> getViewsOfDates();

@Operation(
summary = "카테고리별 조회수 조회",
Expand All @@ -31,5 +32,5 @@ public interface StatisticsApi {
responseCode = "200",
description = "요청에 성공하였습니다."
)
List<CategoryStatisticsResponse> getCategoryStatistics();
SuccessResponse<List<CategoryStatisticsResponse>> getCategoryStatistics();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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")
Expand All @@ -21,14 +25,16 @@ public class StatisticsController implements StatisticsApi {
@ResponseStatus(HttpStatus.OK)
@GetMapping("/per-dates")
@Override
public List<DateViewStatisticsResponse> getViewsOfDates() {
return statisticsService.getViewsOfDates();
public SuccessResponse<List<DateViewStatisticsResponse>> getViewsOfDates() {
List<DateViewStatisticsResponse> response = statisticsService.getViewsOfDates();
return SuccessResponse.of(GET_VIEWS_OF_DATE_SUCCESS, response);
}

@ResponseStatus(HttpStatus.OK)
@GetMapping("/categories")
@Override
public List<CategoryStatisticsResponse> getCategoryStatistics() {
return statisticsService.getCategoryStatistics();
public SuccessResponse<List<CategoryStatisticsResponse>> getCategoryStatistics() {
List<CategoryStatisticsResponse> response = statisticsService.getCategoryStatistics();
return SuccessResponse.of(GET_CATEGORY_VIEWS_SUCCESS, response);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e33a25e

Please sign in to comment.