diff --git a/src/main/java/kusitms/server/domain/tumbler/current/dto/response/MainResponseDto.java b/src/main/java/kusitms/server/domain/tumbler/current/dto/response/MainResponseDto.java index ed4cfdf..4c63abf 100644 --- a/src/main/java/kusitms/server/domain/tumbler/current/dto/response/MainResponseDto.java +++ b/src/main/java/kusitms/server/domain/tumbler/current/dto/response/MainResponseDto.java @@ -1,10 +1,14 @@ package kusitms.server.domain.tumbler.current.dto.response; import io.swagger.v3.oas.annotations.media.Schema; +import kusitms.server.domain.tumbler.history.dto.response.HistoryMonthDetailResponseDto; import lombok.Builder; import lombok.Getter; import lombok.NoArgsConstructor; +import java.util.ArrayList; +import java.util.List; + @NoArgsConstructor @Getter @Schema(description = "부서 메인 조회 응답 객체") @@ -13,24 +17,28 @@ public class MainResponseDto { @Schema(description = "이번달 부서별 텀블러 등급", example = "1") private Integer tumblerGrade; - @Schema(description = "이번달 부서별 텀블러 명", example = "") + @Schema(description = "이번달 부서별 텀블러 명", example = "AA건전지") private String tumblerName; - @Schema(description = "부서명", example = "") + @Schema(description = "부서명", example = "A") private String deptName; - @Schema(description = "이번달 부서별 텀블러 퍼센트", example = "") + @Schema(description = "이번달 부서별 텀블러 퍼센트", example = "50.0") private Double tumblerPercent; - @Schema(description = "이번달 목표 수 - 현재 적립 수", example = "") + @Schema(description = "이번달 목표 수 - 현재 적립 수", example = "288") private Integer toGoalCount; + @Schema(description = "이번달 랭킹 TOP3") + private List rankList = new ArrayList<>(); + @Builder - public MainResponseDto(Integer tumblerGrade, String tumblerName, String deptName, Double tumblerPercent, Integer toGoalCount) { + public MainResponseDto(Integer tumblerGrade, String tumblerName, String deptName, Double tumblerPercent, Integer toGoalCount, List rankList) { this.tumblerGrade = tumblerGrade; this.tumblerName = tumblerName; this.deptName = deptName; this.tumblerPercent = tumblerPercent; this.toGoalCount = toGoalCount; + this.rankList = rankList; } } diff --git a/src/main/java/kusitms/server/domain/tumbler/current/service/TumblerCurrentService.java b/src/main/java/kusitms/server/domain/tumbler/current/service/TumblerCurrentService.java index 7a5e6dc..d128a7d 100644 --- a/src/main/java/kusitms/server/domain/tumbler/current/service/TumblerCurrentService.java +++ b/src/main/java/kusitms/server/domain/tumbler/current/service/TumblerCurrentService.java @@ -2,14 +2,18 @@ import kusitms.server.domain.department.entity.Department; import kusitms.server.domain.department.repository.DepartmentRepository; -import kusitms.server.domain.tumbler.current.dto.request.MainRequestDto; import kusitms.server.domain.tumbler.current.dto.response.MainResponseDto; import kusitms.server.domain.tumbler.current.entity.TumblerCurrent; import kusitms.server.domain.tumbler.current.repository.TumblerCurrentRepository; +import kusitms.server.domain.tumbler.history.dto.response.HistoryMonthDetailResponseDto; +import kusitms.server.domain.tumbler.history.service.TumblerHistoryService; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; +import java.util.List; + @RequiredArgsConstructor @Service @Transactional @@ -17,6 +21,7 @@ public class TumblerCurrentService { private final DepartmentRepository departmentRepository; private final TumblerCurrentRepository tumblerCurrentRepository; + private final TumblerHistoryService tumblerHistoryService; public MainResponseDto getTumblerCurrent(Long userId) { @@ -34,12 +39,15 @@ public MainResponseDto getTumblerCurrent(Long userId) { Double tumblerPercent = tumblerCurrent.getTumblerPercent(); // 이번달 부서별 텀블러 퍼센트 Integer tumblerGrade = tumblerCurrent.getTumblerGrade(); // 이번달 부서별 텀블러 등급 + List rankList = tumblerHistoryService.findDetailByMonth("202310", userId); + MainResponseDto res = MainResponseDto.builder() .tumblerGrade(tumblerGrade) .tumblerName(tumblerName) .deptName(deptName) .tumblerPercent(tumblerPercent) .toGoalCount(tumblerGoal - tumblerCount) + .rankList(rankList) .build(); return res;