diff --git a/be/issue-tracker/src/main/java/com/issuetracker/global/controller/HomeController.java b/be/issue-tracker/src/main/java/com/issuetracker/global/controller/HomeController.java index 07d2236ad..e10105865 100644 --- a/be/issue-tracker/src/main/java/com/issuetracker/global/controller/HomeController.java +++ b/be/issue-tracker/src/main/java/com/issuetracker/global/controller/HomeController.java @@ -1,5 +1,6 @@ package com.issuetracker.global.controller; +import com.issuetracker.global.dto.HomeComponentResponse; import com.issuetracker.global.dto.HomeIssueResponse; import com.issuetracker.global.service.HomeService; import com.issuetracker.issue.dto.IssueQueryDto; @@ -16,6 +17,12 @@ public class HomeController { private final HomeService homeService; + @GetMapping("/components") + public ResponseEntity getComponents() { + HomeComponentResponse homeComponentResponse = homeService.getComponents(); + return ResponseEntity.ok().body(homeComponentResponse); + } + @GetMapping("/issues") public ResponseEntity getFilteredIssues(@ModelAttribute IssueQueryDto issueQueryDto) { HomeIssueResponse homeIssueResponse = homeService.getFilteredIssues(issueQueryDto); diff --git a/be/issue-tracker/src/main/java/com/issuetracker/global/dto/HomeComponentResponse.java b/be/issue-tracker/src/main/java/com/issuetracker/global/dto/HomeComponentResponse.java index c8046b6ff..a1d0c523f 100644 --- a/be/issue-tracker/src/main/java/com/issuetracker/global/dto/HomeComponentResponse.java +++ b/be/issue-tracker/src/main/java/com/issuetracker/global/dto/HomeComponentResponse.java @@ -1,9 +1,7 @@ package com.issuetracker.global.dto; -import com.issuetracker.label.dto.LabelListDto; -import com.issuetracker.member.dto.SimpleMemberDto; -import com.issuetracker.milestone.dto.MilestoneListDto; -import java.util.List; +import com.issuetracker.label.dto.LabelCountDto; +import com.issuetracker.milestone.dto.MilestoneCountDto; import lombok.Builder; import lombok.Getter; import lombok.ToString; @@ -12,8 +10,6 @@ @ToString @Builder public class HomeComponentResponse { - private final List assignees; - private final LabelListDto labels; - private final MilestoneListDto milestones; - private final List authors; + private final LabelCountDto labelCount; + private final MilestoneCountDto milestoneCount; } diff --git a/be/issue-tracker/src/main/java/com/issuetracker/global/service/HomeService.java b/be/issue-tracker/src/main/java/com/issuetracker/global/service/HomeService.java index e14757179..ec548c4ec 100644 --- a/be/issue-tracker/src/main/java/com/issuetracker/global/service/HomeService.java +++ b/be/issue-tracker/src/main/java/com/issuetracker/global/service/HomeService.java @@ -6,7 +6,6 @@ import com.issuetracker.issue.service.IssueFilterService; import com.issuetracker.issue.service.IssueQueryService; import com.issuetracker.label.service.LabelService; -import com.issuetracker.member.service.MemberService; import com.issuetracker.milestone.service.MilestoneService; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; @@ -21,18 +20,15 @@ public class HomeService { private final IssueFilterService issueFilterService; private final LabelService labelService; private final MilestoneService milestoneService; - private final MemberService memberService; /** - * 홈 화면의 상위 컴포넌트를 반환한다. + * 라벨의 개수와 마일스톤의 개수를 나타내는 홈 화면의 상위 컴포넌트를 반환한다. */ @Transactional(readOnly = true) public HomeComponentResponse getComponents() { return HomeComponentResponse.builder() - .assignees(memberService.getMembers()) - .labels(labelService.getLabelListDto()) - .milestones(milestoneService.showMilestoneList(false)) - .authors(memberService.getMembers()) + .labelCount(labelService.countLabels()) + .milestoneCount(milestoneService.countMilestones()) .build(); } diff --git a/be/issue-tracker/src/main/java/com/issuetracker/label/service/LabelService.java b/be/issue-tracker/src/main/java/com/issuetracker/label/service/LabelService.java index a3d8f814b..4698320e4 100644 --- a/be/issue-tracker/src/main/java/com/issuetracker/label/service/LabelService.java +++ b/be/issue-tracker/src/main/java/com/issuetracker/label/service/LabelService.java @@ -1,6 +1,7 @@ package com.issuetracker.label.service; import com.issuetracker.label.dto.LabelBgColorDto; +import com.issuetracker.label.dto.LabelCountDto; import com.issuetracker.label.dto.LabelCoverDto; import com.issuetracker.label.dto.LabelDto; import com.issuetracker.label.dto.LabelListDto; @@ -22,7 +23,7 @@ public class LabelService { private final LabelRepository labelRepository; private final HexColorGenerator hexColorGenerator; - + /** * 라벨의 개수와 함께 라벨의 전체 리스트를 반환한다. */ @@ -102,6 +103,15 @@ public LabelBgColorDto refreshLabelBackgroundColor() { return new LabelBgColorDto(hexColorGenerator.generateRandomHexColor()); } + /** + * 라벨의 총 개수를 반환한다. + */ + @Transactional(readOnly = true) + public LabelCountDto countLabels() { + long count = labelRepository.countAll(); + return new LabelCountDto(count); + } + private void validateLabelExists(Long id) { if (!labelRepository.existsById(id)) { throw new LabelNotFoundException();