-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feat] 월별 총 리뷰 갯수 조회 기능, 연도별 총 리뷰 갯수 조회 기능 추가
- Loading branch information
Showing
5 changed files
with
81 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...in/java/com/mookive/mookive_backend/record/application/service/RecordTotalGetService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package com.mookive.mookive_backend.record.application.service; | ||
|
||
import com.mookive.mookive_backend.record.application.dto.response.RecordResponse; | ||
import com.mookive.mookive_backend.record.domain.service.RecordQueryService; | ||
import jakarta.transaction.Transactional; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.LocalTime; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
@Transactional | ||
public class RecordTotalGetService { | ||
|
||
private final RecordQueryService recordQueryService; | ||
|
||
public RecordResponse.RecordTotalResponse getRecordTotalOfMonth(Long userId) { | ||
LocalDate now = LocalDate.now(); | ||
LocalDate startDate = LocalDate.of(now.getYear(), now.getMonthValue(), 1); | ||
LocalTime startTime = LocalTime.of(0,0,0,0); | ||
LocalDateTime startLocalDateTime = LocalDateTime.of(startDate, startTime); | ||
|
||
LocalDate endDate = LocalDate.of(now.getYear(), now.getMonthValue(), now.lengthOfMonth()); | ||
LocalTime endTime = LocalTime.of(23,59,9,999999999); | ||
LocalDateTime endLocalDateTime = LocalDateTime.of(endDate, endTime); | ||
|
||
int total = recordQueryService.countByUserIdAndCreatedAtBetween(userId, startLocalDateTime, endLocalDateTime); | ||
return RecordResponse.RecordTotalResponse.builder() | ||
.total(total) | ||
.build(); | ||
} | ||
|
||
public RecordResponse.RecordTotalResponse getRecordTotalOfYear(Long userId) { | ||
LocalDate now = LocalDate.now(); | ||
LocalDate startDate = LocalDate.of(now.getYear(), 1, 1); | ||
LocalTime startTime = LocalTime.of(0,0,0,0); | ||
LocalDateTime startLocalDateTime = LocalDateTime.of(startDate, startTime); | ||
|
||
LocalDate endDate = LocalDate.of(now.getYear(), 12, 31); | ||
LocalTime endTime = LocalTime.of(23,59,9,999999999); | ||
LocalDateTime endLocalDateTime = LocalDateTime.of(endDate, endTime); | ||
|
||
int total = recordQueryService.countByUserIdAndCreatedAtBetween(userId, startLocalDateTime, endLocalDateTime); | ||
return RecordResponse.RecordTotalResponse.builder() | ||
.total(total) | ||
.build(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters