Skip to content

Commit

Permalink
[BE/#17] Feat : milestone 테이블에 progress 컬럼 추가에 따른 클래스 내부 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
hanurii committed Jun 19, 2020
1 parent 442b8e9 commit 33043d6
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,27 @@ public class Milestone {

private LocalDateTime updatedDateTime;

private Milestone(Integer id, String title, String description, LocalDate dueDate, LocalDateTime createdDateTime, LocalDateTime updatedDateTime) {
private Double progress;

private Milestone(Integer id, String title, String description, LocalDate dueDate, LocalDateTime createdDateTime, LocalDateTime updatedDateTime, Double progress) {
this.id = id;
this.title = title;
this.description = description;
this.dueDate = dueDate;
this.createdDateTime = createdDateTime;
this.updatedDateTime = updatedDateTime;
this.progress = progress;
}

public static Milestone of(Integer id, String title, String description, LocalDate dueDate, LocalDateTime createdDateTime, LocalDateTime updatedDateTime) {
public static Milestone of(Integer id, String title, String description, LocalDate dueDate, LocalDateTime createdDateTime, LocalDateTime updatedDateTime, Double progress) {
return new Builder()
.id(id)
.title(title)
.description(description)
.dueDate(dueDate)
.createdDateTime(createdDateTime)
.updatedDateTime(updatedDateTime)
.progress(progress)
.build();
}

Expand Down Expand Up @@ -61,13 +65,18 @@ public LocalDateTime getUpdatedDateTime() {
return updatedDateTime;
}

public Double getProgress() {
return progress;
}

private static class Builder {
private Integer id;
private String title;
private String description;
private LocalDate dueDate;
private LocalDateTime createdDateTime;
private LocalDateTime updatedDateTime;
private Double progress;

private Builder() {}

Expand Down Expand Up @@ -101,8 +110,13 @@ private Builder updatedDateTime(LocalDateTime updatedDateTime) {
return this;
}

private Builder progress(Double progress) {
this.progress = progress;
return this;
}

private Milestone build() {
return new Milestone(id, title, description, dueDate, createdDateTime, updatedDateTime);
return new Milestone(id, title, description, dueDate, createdDateTime, updatedDateTime, progress);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,15 @@ private IssueDetails mapToIssueDetails(Issue issue) {
List<UserSummary> allocatedAssignees = userService_hamill.findUserSummaryByIssueId(issue.getId());
User user = userService_hamill.findUserByUserId(issue.getUserId());

return IssueDetails.of(issue.getId(), issue.getTitle(), MilestoneSummary.of(milestone.getId(), milestone.getTitle()),
attachedLabels, UserSummary.of(user.getId(), user.getName(), user.getAvatarUrl()), allocatedAssignees,
issue.getCreatedDateTime(), issue.isOpened());
return IssueDetails.of(
issue.getId(),
issue.getTitle(),
MilestoneSummary.of(milestone.getId(), milestone.getTitle(), milestone.getProgress()),
attachedLabels,
UserSummary.of(user.getId(), user.getName(), user.getAvatarUrl()),
allocatedAssignees,
issue.getCreatedDateTime(),
issue.isOpened());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

@Service
public class MilestoneService_Hamill {
Expand All @@ -29,7 +27,7 @@ public MilestoneInformation findMilestoneInformation() {

List<MilestoneSummary> milestoneSummaries = new ArrayList<>();
for (Milestone value : milestones) {
MilestoneSummary milestoneSummary = MilestoneSummary.of(value.getId(), value.getTitle());
MilestoneSummary milestoneSummary = MilestoneSummary.of(value.getId(), value.getTitle(), value.getProgress());
milestoneSummaries.add(milestoneSummary);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,24 @@ public class MilestoneSummary {

private String title;

private MilestoneSummary(Integer id, String title) {
private Double progress;

private MilestoneSummary(Integer id, String title, Double progress) {
this.id = id;
this.title = title;
this.progress = progress;
}

public static MilestoneSummary of(Integer id, String title) {
return new MilestoneSummary(id, title);
public static MilestoneSummary of(Integer id, String title, Double progress) {
return new MilestoneSummary(id, title, progress);
}

public Integer getId() { return id; }

public String getTitle() { return title; }

public Double getProgress() {
return progress;
}
}

1 change: 1 addition & 0 deletions BE/src/main/resources/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ CREATE TABLE IF NOT EXISTS milestone
due_date DATE,
created_date_time DATETIME,
updated_date_time DATETIME,
progress Double,
PRIMARY KEY (id)
);

Expand Down

0 comments on commit 33043d6

Please sign in to comment.