-
Notifications
You must be signed in to change notification settings - Fork 1
feat: 경매장 거래 내역 통계 조회 API 구현 #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
755aba9
881d011
ea13562
f5a6586
6fb6066
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,24 +20,24 @@ public class ItemDailyStatisticsService { | |
| private final ItemDailyStatisticsRepository repository; | ||
| private final ItemDailyStatisticsMapper mapper; | ||
|
|
||
| /** 아이템별 일간 통계 전체 조회 (페이징) */ | ||
| /** 아이템별 일간 통계 조회 (itemName, subCategory, topCategory, 날짜 범위) */ | ||
| @Transactional(readOnly = true) | ||
| public PageResponseDto<ItemDailyStatisticsResponse> findAll(Pageable pageable) { | ||
| Page<ItemDailyStatistics> page = repository.findAll(pageable); | ||
| Page<ItemDailyStatisticsResponse> dtoPage = page.map(mapper::toDto); | ||
| return PageResponseDto.of(dtoPage); | ||
| } | ||
| public java.util.List<ItemDailyStatisticsResponse> search( | ||
| String itemName, | ||
| String subCategory, | ||
| String topCategory, | ||
| java.time.LocalDate startDate, | ||
| java.time.LocalDate endDate) { | ||
|
Comment on lines
+25
to
+30
|
||
| // 날짜 범위 검증 (최대 30일) | ||
| until.the.eternity.statistics.util.DateRangeValidator.validateDailyDateRange( | ||
| startDate, endDate); | ||
|
|
||
| /** 아이템별 일간 통계 ID로 단건 조회 */ | ||
| @Transactional(readOnly = true) | ||
| public ItemDailyStatisticsResponse findById(Long id) { | ||
| ItemDailyStatistics entity = | ||
| repository | ||
| .findById(id) | ||
| .orElseThrow( | ||
| () -> | ||
| new IllegalArgumentException( | ||
| "ItemDailyStatistics not found: " + id)); | ||
| return mapper.toDto(entity); | ||
| // 조회 | ||
| java.util.List<ItemDailyStatistics> results = | ||
| repository.findByItemAndDateRange( | ||
| itemName, subCategory, topCategory, startDate, endDate); | ||
|
|
||
| // DTO 변환 | ||
| return results.stream().map(mapper::toDto).collect(java.util.stream.Collectors.toList()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,24 +20,24 @@ public class ItemWeeklyStatisticsService { | |
| private final ItemWeeklyStatisticsRepository repository; | ||
| private final ItemWeeklyStatisticsMapper mapper; | ||
|
|
||
| /** 아이템별 주간 통계 전체 조회 (페이징) */ | ||
| /** 아이템별 주간 통계 조회 (itemName, subCategory, topCategory, 날짜 범위) */ | ||
| @Transactional(readOnly = true) | ||
| public PageResponseDto<ItemWeeklyStatisticsResponse> findAll(Pageable pageable) { | ||
| Page<ItemWeeklyStatistics> page = repository.findAll(pageable); | ||
| Page<ItemWeeklyStatisticsResponse> dtoPage = page.map(mapper::toDto); | ||
| return PageResponseDto.of(dtoPage); | ||
| } | ||
| public java.util.List<ItemWeeklyStatisticsResponse> search( | ||
|
||
| String itemName, | ||
| String subCategory, | ||
| String topCategory, | ||
| java.time.LocalDate startDate, | ||
| java.time.LocalDate endDate) { | ||
|
Comment on lines
+25
to
+30
|
||
| // 날짜 범위 검증 (최대 4개월) | ||
| until.the.eternity.statistics.util.DateRangeValidator.validateWeeklyDateRange( | ||
| startDate, endDate); | ||
|
|
||
| /** 아이템별 주간 통계 ID로 단건 조회 */ | ||
| @Transactional(readOnly = true) | ||
| public ItemWeeklyStatisticsResponse findById(Long id) { | ||
| ItemWeeklyStatistics entity = | ||
| repository | ||
| .findById(id) | ||
| .orElseThrow( | ||
| () -> | ||
| new IllegalArgumentException( | ||
| "ItemWeeklyStatistics not found: " + id)); | ||
| return mapper.toDto(entity); | ||
| // 조회 | ||
| java.util.List<ItemWeeklyStatistics> results = | ||
| repository.findByItemAndDateRange( | ||
| itemName, subCategory, topCategory, startDate, endDate); | ||
|
|
||
| // DTO 변환 | ||
| return results.stream().map(mapper::toDto).collect(java.util.stream.Collectors.toList()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,24 +20,22 @@ public class SubcategoryDailyStatisticsService { | |
| private final SubcategoryDailyStatisticsRepository repository; | ||
| private final SubcategoryDailyStatisticsMapper mapper; | ||
|
|
||
| /** 서브카테고리별 일간 통계 전체 조회 (페이징) */ | ||
| /** 서브카테고리별 일간 통계 조회 (subCategory, 날짜 범위) */ | ||
| @Transactional(readOnly = true) | ||
| public PageResponseDto<SubcategoryDailyStatisticsResponse> findAll(Pageable pageable) { | ||
| Page<SubcategoryDailyStatistics> page = repository.findAll(pageable); | ||
| Page<SubcategoryDailyStatisticsResponse> dtoPage = page.map(mapper::toDto); | ||
| return PageResponseDto.of(dtoPage); | ||
| } | ||
| public java.util.List<SubcategoryDailyStatisticsResponse> search( | ||
|
||
| String topCategory, // topCategory는 파라미터로 받지만 조회에는 사용하지 않음 (DB 구조상) | ||
| String subCategory, | ||
| java.time.LocalDate startDate, | ||
| java.time.LocalDate endDate) { | ||
|
Comment on lines
+25
to
+29
|
||
| // 날짜 범위 검증 (최대 30일) | ||
| until.the.eternity.statistics.util.DateRangeValidator.validateDailyDateRange( | ||
| startDate, endDate); | ||
|
|
||
| /** 서브카테고리별 일간 통계 ID로 단건 조회 */ | ||
| @Transactional(readOnly = true) | ||
| public SubcategoryDailyStatisticsResponse findById(Long id) { | ||
| SubcategoryDailyStatistics entity = | ||
| repository | ||
| .findById(id) | ||
| .orElseThrow( | ||
| () -> | ||
| new IllegalArgumentException( | ||
| "SubcategoryDailyStatistics not found: " + id)); | ||
| return mapper.toDto(entity); | ||
| // 조회 | ||
| java.util.List<SubcategoryDailyStatistics> results = | ||
| repository.findBySubcategoryAndDateRange(subCategory, startDate, endDate); | ||
|
|
||
| // DTO 변환 | ||
| return results.stream().map(mapper::toDto).collect(java.util.stream.Collectors.toList()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -20,24 +20,22 @@ public class SubcategoryWeeklyStatisticsService { | |||
| private final SubcategoryWeeklyStatisticsRepository repository; | ||||
| private final SubcategoryWeeklyStatisticsMapper mapper; | ||||
|
|
||||
| /** 서브카테고리별 주간 통계 전체 조회 (페이징) */ | ||||
| /** 서브카테고리별 주간 통계 조회 (subCategory, 날짜 범위) */ | ||||
| @Transactional(readOnly = true) | ||||
| public PageResponseDto<SubcategoryWeeklyStatisticsResponse> findAll(Pageable pageable) { | ||||
| Page<SubcategoryWeeklyStatistics> page = repository.findAll(pageable); | ||||
| Page<SubcategoryWeeklyStatisticsResponse> dtoPage = page.map(mapper::toDto); | ||||
| return PageResponseDto.of(dtoPage); | ||||
| } | ||||
| public java.util.List<SubcategoryWeeklyStatisticsResponse> search( | ||||
|
||||
| String topCategory, // topCategory는 파라미터로 받지만 조회에는 사용하지 않음 (DB 구조상) | ||||
|
||||
| String topCategory, // topCategory는 파라미터로 받지만 조회에는 사용하지 않음 (DB 구조상) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,24 +20,19 @@ public class TopCategoryDailyStatisticsService { | |
| private final TopCategoryDailyStatisticsRepository repository; | ||
| private final TopCategoryDailyStatisticsMapper mapper; | ||
|
|
||
| /** 탑카테고리별 일간 통계 전체 조회 (페이징) */ | ||
| /** 탑카테고리별 일간 통계 조회 (topCategory, 날짜 범위) */ | ||
| @Transactional(readOnly = true) | ||
| public PageResponseDto<TopCategoryDailyStatisticsResponse> findAll(Pageable pageable) { | ||
| Page<TopCategoryDailyStatistics> page = repository.findAll(pageable); | ||
| Page<TopCategoryDailyStatisticsResponse> dtoPage = page.map(mapper::toDto); | ||
| return PageResponseDto.of(dtoPage); | ||
| } | ||
| public java.util.List<TopCategoryDailyStatisticsResponse> search( | ||
|
||
| String topCategory, java.time.LocalDate startDate, java.time.LocalDate endDate) { | ||
| // 날짜 범위 검증 (최대 30일) | ||
| until.the.eternity.statistics.util.DateRangeValidator.validateDailyDateRange( | ||
|
Comment on lines
+25
to
+28
|
||
| startDate, endDate); | ||
|
|
||
| /** 탑카테고리별 일간 통계 ID로 단건 조회 */ | ||
| @Transactional(readOnly = true) | ||
| public TopCategoryDailyStatisticsResponse findById(Long id) { | ||
| TopCategoryDailyStatistics entity = | ||
| repository | ||
| .findById(id) | ||
| .orElseThrow( | ||
| () -> | ||
| new IllegalArgumentException( | ||
| "TopCategoryDailyStatistics not found: " + id)); | ||
| return mapper.toDto(entity); | ||
| // 조회 | ||
| java.util.List<TopCategoryDailyStatistics> results = | ||
| repository.findByTopCategoryAndDateRange(topCategory, startDate, endDate); | ||
|
|
||
| // DTO 변환 | ||
| return results.stream().map(mapper::toDto).collect(java.util.stream.Collectors.toList()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,24 +20,19 @@ public class TopCategoryWeeklyStatisticsService { | |
| private final TopCategoryWeeklyStatisticsRepository repository; | ||
| private final TopCategoryWeeklyStatisticsMapper mapper; | ||
|
|
||
| /** 탑카테고리별 주간 통계 전체 조회 (페이징) */ | ||
| /** 탑카테고리별 주간 통계 조회 (topCategory, 날짜 범위) */ | ||
| @Transactional(readOnly = true) | ||
| public PageResponseDto<TopCategoryWeeklyStatisticsResponse> findAll(Pageable pageable) { | ||
| Page<TopCategoryWeeklyStatistics> page = repository.findAll(pageable); | ||
| Page<TopCategoryWeeklyStatisticsResponse> dtoPage = page.map(mapper::toDto); | ||
| return PageResponseDto.of(dtoPage); | ||
| } | ||
| public java.util.List<TopCategoryWeeklyStatisticsResponse> search( | ||
|
||
| String topCategory, java.time.LocalDate startDate, java.time.LocalDate endDate) { | ||
| // 날짜 범위 검증 (최대 4개월) | ||
| until.the.eternity.statistics.util.DateRangeValidator.validateWeeklyDateRange( | ||
|
Comment on lines
+25
to
+28
|
||
| startDate, endDate); | ||
|
|
||
| /** 탑카테고리별 주간 통계 ID로 단건 조회 */ | ||
| @Transactional(readOnly = true) | ||
| public TopCategoryWeeklyStatisticsResponse findById(Long id) { | ||
| TopCategoryWeeklyStatistics entity = | ||
| repository | ||
| .findById(id) | ||
| .orElseThrow( | ||
| () -> | ||
| new IllegalArgumentException( | ||
| "TopCategoryWeeklyStatistics not found: " + id)); | ||
| return mapper.toDto(entity); | ||
| // 조회 | ||
| java.util.List<TopCategoryWeeklyStatistics> results = | ||
| repository.findByTopCategoryAndDateRange(topCategory, startDate, endDate); | ||
|
|
||
| // DTO 변환 | ||
| return results.stream().map(mapper::toDto).collect(java.util.stream.Collectors.toList()); | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,21 +22,20 @@ public class ItemWeeklyStatisticsController { | |
|
|
||
| @GetMapping | ||
| @Operation( | ||
| summary = "아이템별 주간 통계 목록 조회", | ||
| description = | ||
| "아이템별 주간 거래 통계 목록을 페이징하여 조회합니다. 최저가, 최고가, 평균가, 거래 총량, 거래 수량, 연도, 주차 정보를 포함합니다.") | ||
| public ResponseEntity<PageResponseDto<ItemWeeklyStatisticsResponse>> getItemWeeklyStatistics( | ||
| @ParameterObject @ModelAttribute PageRequestDto pageDto) { | ||
| PageResponseDto<ItemWeeklyStatisticsResponse> result = | ||
| service.findAll(pageDto.toPageable()); | ||
| return ResponseEntity.ok(result); | ||
| } | ||
|
|
||
| @GetMapping("/{id}") | ||
| @Operation(summary = "아이템별 주간 통계 단건 조회", description = "ID를 통해 특정 아이템의 주간 거래 통계를 조회합니다.") | ||
| public ResponseEntity<ItemWeeklyStatisticsResponse> getItemWeeklyStatisticsById( | ||
| @Parameter(description = "통계 ID", example = "1") @PathVariable Long id) { | ||
| ItemWeeklyStatisticsResponse result = service.findById(id); | ||
| return ResponseEntity.ok(result); | ||
| summary = "아이템별 주간 통계 조회", | ||
| description = "아이템 이름, 서브 카테고리, 탑 카테고리로 주간 통계를 조회합니다. 최대 4개월까지 조회 가능합니다.") | ||
| public ResponseEntity<java.util.List<ItemWeeklyStatisticsResponse>> searchItemWeeklyStatistics( | ||
| @ParameterObject @ModelAttribute | ||
| @jakarta.validation.Valid | ||
| until.the.eternity.statistics.interfaces.rest.dto.request.ItemWeeklyStatisticsSearchRequest | ||
|
Comment on lines
+27
to
+30
|
||
| request) { | ||
| java.util.List<ItemWeeklyStatisticsResponse> results = | ||
| service.search( | ||
| request.itemName(), | ||
| request.subCategory(), | ||
| request.topCategory(), | ||
| request.getStartDateWithDefault(), | ||
| request.getEndDateWithDefault()); | ||
| return ResponseEntity.ok(results); | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new search method lacks test coverage. The existing tests only cover findAll and findById which have been removed. Add tests for the search method including validation and query scenarios.