forked from codesquad-members-2023/issue-tracker-max
-
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.
- Loading branch information
Showing
10 changed files
with
280 additions
and
3 deletions.
There are no files selected for viewing
22 changes: 22 additions & 0 deletions
22
...ain/java/com/issuetrackermax/controller/milestone/dto/request/MilestoneModifyRequest.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,22 @@ | ||
package com.issuetrackermax.controller.milestone.dto.request; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class MilestoneModifyRequest { | ||
private String name; | ||
private String description; | ||
private LocalDateTime dueDate; | ||
|
||
@Builder | ||
public MilestoneModifyRequest(String name, String description, LocalDateTime dueDate) { | ||
this.name = name; | ||
this.description = description; | ||
this.dueDate = dueDate; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
.../main/java/com/issuetrackermax/controller/milestone/dto/request/MilestonePostRequest.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,22 @@ | ||
package com.issuetrackermax.controller.milestone.dto.request; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class MilestonePostRequest { | ||
private String name; | ||
private LocalDateTime dueDate; | ||
private String description; | ||
|
||
@Builder | ||
public MilestonePostRequest(String name, LocalDateTime dueDate, String description) { | ||
this.name = name; | ||
this.dueDate = dueDate; | ||
this.description = description; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...in/java/com/issuetrackermax/controller/milestone/dto/response/MilestoneCloseResponse.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,21 @@ | ||
package com.issuetrackermax.controller.milestone.dto.response; | ||
|
||
import java.util.List; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class MilestoneCloseResponse { | ||
private Long labelCount; | ||
private Long openMilestoneCount; | ||
private List<MilestoneDetailResponse> milestones; | ||
|
||
@Builder | ||
public MilestoneCloseResponse(Long labelCount, Long openMilestoneCount, | ||
List<MilestoneDetailResponse> milestones) { | ||
this.labelCount = labelCount; | ||
this.openMilestoneCount = openMilestoneCount; | ||
this.milestones = milestones; | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
...n/java/com/issuetrackermax/controller/milestone/dto/response/MilestoneDetailResponse.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,27 @@ | ||
package com.issuetrackermax.controller.milestone.dto.response; | ||
|
||
import java.time.LocalDateTime; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class MilestoneDetailResponse { | ||
private Long id; | ||
private String name; | ||
private String description; | ||
private LocalDateTime dueDate; | ||
private Long openIssueCount; | ||
private Long closedIssueCount; | ||
|
||
@Builder | ||
public MilestoneDetailResponse(Long id, String name, String description, LocalDateTime dueDate, | ||
Long openIssueCount, Long closedIssueCount) { | ||
this.id = id; | ||
this.name = name; | ||
this.description = description; | ||
this.dueDate = dueDate; | ||
this.openIssueCount = openIssueCount; | ||
this.closedIssueCount = closedIssueCount; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ain/java/com/issuetrackermax/controller/milestone/dto/response/MilestoneOpenResponse.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,23 @@ | ||
package com.issuetrackermax.controller.milestone.dto.response; | ||
|
||
import java.util.List; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
public class MilestoneOpenResponse { | ||
private Long labelCount; | ||
private Long closedMilestoneCount; | ||
private List<MilestoneDetailResponse> milestones; | ||
|
||
@Builder | ||
public MilestoneOpenResponse(Long labelCount, Long closedMilestoneCount, | ||
List<MilestoneDetailResponse> milestones) { | ||
this.labelCount = labelCount; | ||
this.closedMilestoneCount = closedMilestoneCount; | ||
this.milestones = milestones; | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
...ain/java/com/issuetrackermax/controller/milestone/dto/response/MilestonePostResponse.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,14 @@ | ||
package com.issuetrackermax.controller.milestone.dto.response; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class MilestonePostResponse { | ||
private Long id; | ||
|
||
@Builder | ||
public MilestonePostResponse(Long id) { | ||
this.id = id; | ||
} | ||
} |
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
70 changes: 69 additions & 1 deletion
70
be/src/main/java/com/issuetrackermax/service/milestone/MilestoneService.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 |
---|---|---|
@@ -1,18 +1,86 @@ | ||
package com.issuetrackermax.service.milestone; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
import org.springframework.stereotype.Service; | ||
|
||
import com.issuetrackermax.controller.milestone.dto.request.MilestoneModifyRequest; | ||
import com.issuetrackermax.controller.milestone.dto.request.MilestonePostRequest; | ||
import com.issuetrackermax.controller.milestone.dto.response.MilestoneDetailResponse; | ||
import com.issuetrackermax.domain.issue.IssueRepository; | ||
import com.issuetrackermax.domain.issue.entity.Issue; | ||
import com.issuetrackermax.domain.milestone.MilestoneRepository; | ||
import com.issuetrackermax.domain.milestone.entity.Milestone; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
|
||
@RequiredArgsConstructor | ||
@Service | ||
public class MilestoneService { | ||
private final MilestoneRepository milestoneRepository; | ||
private final IssueRepository issueRepository; | ||
|
||
public Long getMilstoneCount() { | ||
public Long getMilestoneCount() { | ||
return milestoneRepository.getMilestoneCount(); | ||
} | ||
|
||
public List<MilestoneDetailResponse> getOpenMilestone() { | ||
List<Milestone> openMilestone = milestoneRepository.getOpenMilestone(); | ||
return getMilestoneDetailResponses(openMilestone); | ||
} | ||
|
||
public List<MilestoneDetailResponse> getClosedMilestone() { | ||
List<Milestone> closedMilestone = milestoneRepository.getClosedMilestone(); | ||
return getMilestoneDetailResponses(closedMilestone); | ||
|
||
} | ||
|
||
private List<MilestoneDetailResponse> getMilestoneDetailResponses(List<Milestone> openMilestone) { | ||
List<MilestoneDetailResponse> response = | ||
openMilestone.stream() | ||
.map(milestone -> { | ||
long openIssueCount = issueRepository.findByMilestoneId(milestone.getId()) | ||
.stream() | ||
.filter(Issue::getIsOpen) | ||
.count(); | ||
|
||
long closedIssueCount = issueRepository.findByMilestoneId(milestone.getId()) | ||
.stream() | ||
.filter(issue -> !issue.getIsOpen()) | ||
.count(); | ||
|
||
return MilestoneDetailResponse.builder() | ||
.id(milestone.getId()) | ||
.description(milestone.getDescription()) | ||
.name(milestone.getTitle()) | ||
.dueDate(milestone.getDuedate()) | ||
.openIssueCount(openIssueCount) | ||
.closedIssueCount(closedIssueCount) | ||
.build(); | ||
}) | ||
.collect(Collectors.toList()); | ||
|
||
return response; | ||
} | ||
|
||
public Long save(MilestonePostRequest milestonePostRequest) { | ||
Milestone milestone = Milestone.from(milestonePostRequest); | ||
return milestoneRepository.save(milestone); | ||
} | ||
|
||
public void update(Long id, MilestoneModifyRequest milestoneModifyRequest) { | ||
milestoneRepository.update(id, Milestone.from(milestoneModifyRequest)); | ||
return; | ||
} | ||
|
||
public void delete(Long id) { | ||
int count = milestoneRepository.deleteById(id); | ||
return; | ||
} | ||
|
||
public void updateStatus(Long id) { | ||
milestoneRepository.updateStatus(id); | ||
return; | ||
} | ||
} |