Skip to content

Commit

Permalink
Feat : 네이밍컨벤션을 위해 수정
Browse files Browse the repository at this point in the history
TagStatisticsWithDateResponseDTO 로 클래스 이름 수정
  • Loading branch information
Mouon committed Feb 4, 2024
1 parent e63ce1d commit ae2c777
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
package com.kuit.chatdiary.controller.diary;

import com.kuit.chatdiary.dto.diary.DateRangeDTO;
import com.kuit.chatdiary.dto.diary.TagStatisticResponseDTO;
import com.kuit.chatdiary.dto.diary.TagStatisticsWithDateDTO;
import com.kuit.chatdiary.dto.diary.TagStatisticsWithDateResponseDTO;
import com.kuit.chatdiary.service.diary.DiaryTagStatisticsService;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;
import java.util.List;

@RestController
@RequestMapping("/diary")
public class DiaryTagStatisticsController {
Expand All @@ -22,10 +16,10 @@ public DiaryTagStatisticsController(DiaryTagStatisticsService diaryTagStatistics
}

@GetMapping("/tags")
public ResponseEntity<TagStatisticsWithDateDTO> getTagStatistics(
public ResponseEntity<TagStatisticsWithDateResponseDTO> getTagStatistics(
@RequestParam("memberId") Long memberId,
@RequestParam("type") String type) {
TagStatisticsWithDateDTO tagStatistics = diaryTagStatisticsService.calculateTagStatistics(memberId, type);
TagStatisticsWithDateResponseDTO tagStatistics = diaryTagStatisticsService.calculateTagStatistics(memberId, type);
return ResponseEntity.ok(tagStatistics);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
@Getter
@Setter
@AllArgsConstructor
public class TagStatisticsWithDateDTO {
public class TagStatisticsWithDateResponseDTO {
private Date startDate;
private Date endDate;
private List<TagStatisticResponseDTO> Statistics;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.kuit.chatdiary.dto.diary.DateRangeDTO;
import com.kuit.chatdiary.dto.diary.TagStatisticResponseDTO;
import com.kuit.chatdiary.dto.diary.TagStatisticsWithDateDTO;
import com.kuit.chatdiary.dto.diary.TagStatisticsWithDateResponseDTO;
import com.kuit.chatdiary.repository.diary.DiaryTagRepository;
import org.springframework.stereotype.Service;

Expand All @@ -20,14 +20,14 @@ public DiaryTagStatisticsService(DiaryTagRepository diaryTagRepository) {
}

/** TagStatisticsWithDateDTO로 수정 */
public TagStatisticsWithDateDTO calculateTagStatistics(Long memberId, String type) {
public TagStatisticsWithDateResponseDTO calculateTagStatistics(Long memberId, String type) {
LocalDate localDate = LocalDate.now();
DateRangeDTO dateRange = calculateDateRangeBasedOnType(type, localDate);
List<Object[]> tagStatistics = diaryTagRepository.findTagStatisticsByMember(memberId, dateRange.getStartDate(), dateRange.getEndDate());
long totalTags = calculateTotalTags(tagStatistics);
List<TagStatisticResponseDTO> statisticsList = buildStatisticsList(tagStatistics, totalTags);
sortStatisticsListByCount(statisticsList);
return new TagStatisticsWithDateDTO(dateRange.getStartDate(), dateRange.getEndDate(), statisticsList);
return new TagStatisticsWithDateResponseDTO(dateRange.getStartDate(), dateRange.getEndDate(), statisticsList);
}

/** 타입별로 나눠서 계산 */
Expand Down

0 comments on commit ae2c777

Please sign in to comment.