Skip to content

Commit

Permalink
[#59] 이슈 라벨 추가 (#91)
Browse files Browse the repository at this point in the history
* feat: 이슈 라벨 Enum 추가 및 컨버터 등록

* refactor: assigneeDto from 메서드 사용 및 카카오 이미지 url 추가

* refactor: assigneeDto member 패키지 밑으로 이동하면서 리펙터링

* feat(EpicFactory): 라벨 추가

* feat: 라벨 추가 및 생성자 관련 SuperBuilder로 리펙터링

* refactor: superBuilder 지우고 생성자로 다시 변경

story와 task 같은 경우 생성할때 추가적인 로직이 존재하기 때문에 단순화를 위해 생성자로 다시 사용합니다

* feat: 라벨 추가 및 assigneeDto관련 리펙터링

* style: assigneeDto 패키지 임포트 경로 수정

* refactor(SimpleIssueResponse): label 추가

* feat: storyFactory, taskFactory label 추가

* refactor: 스프린트들 조회시 스프린트 상태도 반환하도록 수정

* refactor: 스키마에 라벨 추가
  • Loading branch information
minsang-alt authored May 5, 2024
1 parent c50c062 commit af14c00
Show file tree
Hide file tree
Showing 24 changed files with 225 additions and 162 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package dynamicquad.agilehub.global.config;

import dynamicquad.agilehub.global.auth.util.MemberArgumentResolver;
import dynamicquad.agilehub.global.util.StringToIssueLabelConverter;
import dynamicquad.agilehub.global.util.StringToIssueStatusConverter;
import dynamicquad.agilehub.global.util.StringToIssueTypeConverter;
import java.util.List;
Expand All @@ -18,6 +19,7 @@ public class WebConfig implements WebMvcConfigurer {
public void addFormatters(FormatterRegistry registry) {
registry.addConverter(new StringToIssueTypeConverter());
registry.addConverter(new StringToIssueStatusConverter());
registry.addConverter(new StringToIssueLabelConverter());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package dynamicquad.agilehub.global.util;

import dynamicquad.agilehub.issue.domain.IssueLabel;
import org.springframework.core.convert.converter.Converter;

public class StringToIssueLabelConverter implements Converter<String, IssueLabel> {

@Override
public IssueLabel convert(String source) {
return IssueLabel.parsing(source);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package dynamicquad.agilehub.global.util;

import dynamicquad.agilehub.issue.controller.request.IssueType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.convert.converter.Converter;

@Slf4j
public class StringToIssueTypeConverter implements Converter<String, IssueType> {

@Override
public IssueType convert(String source) {
log.info("StringToIssueTypeConverter convert source: {}", source);
return IssueType.parsing(source);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dynamicquad.agilehub.issue.controller.request;

import dynamicquad.agilehub.issue.domain.IssueLabel;
import dynamicquad.agilehub.issue.domain.IssueStatus;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
Expand Down Expand Up @@ -38,6 +39,9 @@ public static class IssueCreateRequest {
@NotNull(message = "상태는 필수입니다.")
private IssueStatus status;

@Schema(description = "이슈 라벨 (PLAN, DESIGN, DEVELOP, TEST, FEEDBACK)", example = "PLAN")
private IssueLabel label;

@Schema(description = "이슈 내용", example = "이슈 내용")
private String content;

Expand Down Expand Up @@ -80,6 +84,9 @@ public static class IssueEditRequest {
@NotNull(message = "상태는 필수입니다.")
private IssueStatus status;

@Schema(description = "이슈 라벨 (PLAN, DESIGN, DEVELOP, TEST, FEEDBACK)", example = "PLAN, DESIGN, DEVELOP, TEST, FEEDBACK")
private IssueLabel label;

@Schema(description = "이슈 내용", example = "이슈 내용")
private String content;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dynamicquad.agilehub.issue.controller.response;

import dynamicquad.agilehub.issue.controller.request.IssueType;
import dynamicquad.agilehub.issue.controller.response.IssueResponse.AssigneeDto;
import dynamicquad.agilehub.issue.domain.epic.Epic;
import dynamicquad.agilehub.member.dto.AssigneeDto;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -16,17 +16,19 @@ public class EpicResponse {
private String key;
private String status;
private String type;
private String label;
private String startDate;
private String endDate;
private AssigneeDto assignee;
//TODO: 태그 추가 필요


public static EpicResponse fromEntity(Epic epic, String projectKey, AssigneeDto assigneeDto) {
return EpicResponse.builder()
.id(epic.getId())
.title(epic.getTitle())
.key(projectKey + "-" + epic.getNumber())
.status(epic.getStatus().toString())
.label(epic.getLabel().toString())
.type(IssueType.EPIC.toString())
.startDate(epic.getStartDate() == null ? "" : epic.getStartDate().toString())
.endDate(epic.getEndDate() == null ? "" : epic.getEndDate().toString())
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package dynamicquad.agilehub.issue.controller.response;

import dynamicquad.agilehub.member.dto.AssigneeDto;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
Expand All @@ -17,6 +18,7 @@ public static class IssueDto {
private String title;
private String type;
private String status;
private String label;
private String startDate;
private String endDate;
private ContentDto content;
Expand All @@ -37,30 +39,6 @@ public ContentDto() {
}
}

@Builder
@Getter
@AllArgsConstructor
@EqualsAndHashCode
public static class AssigneeDto {
private Long id;
private String name;
private String profileImageURL;

public AssigneeDto() {
this.id = null;
this.name = "";
this.profileImageURL = "";
}

public static AssigneeDto from(Long id, String name, String profileImageURL) {
return AssigneeDto.builder()
.id(id)
.name(name)
.profileImageURL(profileImageURL)
.build();
}
}

@Builder
@Getter
@AllArgsConstructor
Expand All @@ -79,6 +57,7 @@ public static class SubIssueDto {
private Long issueId;
private String key;
private String status;
private String label;
private String type;
private String title;
private AssigneeDto assignee;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dynamicquad.agilehub.issue.controller.response;

import dynamicquad.agilehub.issue.controller.request.IssueType;
import dynamicquad.agilehub.issue.controller.response.IssueResponse.AssigneeDto;
import dynamicquad.agilehub.issue.domain.Issue;
import dynamicquad.agilehub.member.dto.AssigneeDto;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -16,6 +16,7 @@ public class SimpleIssueResponse {
private String type;
private String key;
private String status;
private String label;
private AssigneeDto assignee;

public static SimpleIssueResponse fromEntity(Issue issue, String projectKey, IssueType issueType,
Expand All @@ -25,6 +26,7 @@ public static SimpleIssueResponse fromEntity(Issue issue, String projectKey, Iss
.title(issue.getTitle())
.type(issueType.toString())
.status(String.valueOf(issue.getStatus()))
.label(String.valueOf(issue.getLabel()))
.assignee(assignee)
.key(projectKey + "-" + issue.getNumber())
.build();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dynamicquad.agilehub.issue.controller.response;

import dynamicquad.agilehub.issue.controller.request.IssueType;
import dynamicquad.agilehub.issue.controller.response.IssueResponse.AssigneeDto;
import dynamicquad.agilehub.issue.domain.story.Story;
import dynamicquad.agilehub.member.dto.AssigneeDto;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -15,30 +15,25 @@ public class StoryResponse {
private String title;
private String key;
private String status;
private String label;
private String type;
private String startDate;
private String endDate;
private Long parentId;
private AssigneeDto assignee;
// TODO: 태그 추가 필요

public static StoryResponse fromEntity(Story story, String projectKey, Long parentId) {
public static StoryResponse fromEntity(Story story, String projectKey, Long parentId, AssigneeDto assigneeDto) {
return StoryResponse.builder()
.id(story.getId())
.title(story.getTitle())
.key(projectKey + "-" + story.getNumber())
.status(story.getStatus().toString())
.label(story.getLabel().toString())
.type(IssueType.STORY.toString())
.startDate(story.getStartDate() == null ? "" : story.getStartDate().toString())
.endDate(story.getEndDate() == null ? "" : story.getEndDate().toString())
.parentId(parentId)
.assignee(
story.getAssignee() == null ? new AssigneeDto() :
AssigneeDto.builder()
.id(story.getAssignee().getId())
.name(story.getAssignee().getName())
.build()
)
.assignee(assigneeDto)
.build();
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dynamicquad.agilehub.issue.controller.response;

import dynamicquad.agilehub.issue.controller.request.IssueType;
import dynamicquad.agilehub.issue.controller.response.IssueResponse.AssigneeDto;
import dynamicquad.agilehub.issue.domain.task.Task;
import dynamicquad.agilehub.member.dto.AssigneeDto;
import lombok.Builder;
import lombok.EqualsAndHashCode;
import lombok.Getter;
Expand All @@ -15,28 +15,23 @@ public class TaskResponse {
private String title;
private String key;
private String status;
private String label;
private String type;
private Long parentId;
private AssigneeDto assignee;
// TODO: 태그 추가 필요

public static TaskResponse fromEntity(Task task, String projectKey, Long parentId) {
public static TaskResponse fromEntity(Task task, String projectKey, Long parentId, AssigneeDto assigneeDto) {
return TaskResponse.builder()
.id(task.getId())
.title(task.getTitle())
.key(projectKey + "-" + task.getNumber())
.status(task.getStatus().toString())
.label(task.getLabel().toString())
.type(IssueType.TASK.toString())
.parentId(parentId)
.assignee(
task.getAssignee() == null ? new AssigneeDto() :
AssigneeDto.builder()
.id(task.getAssignee().getId())
.name(task.getAssignee().getName())
.build()
)
.assignee(assigneeDto)
.build();
}


}
10 changes: 8 additions & 2 deletions src/main/java/dynamicquad/agilehub/issue/domain/Issue.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ public abstract class Issue {
@Enumerated(EnumType.STRING)
private IssueStatus status;

@Enumerated(EnumType.STRING)
private IssueLabel label;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "member_id")
private Member assignee;
Expand All @@ -76,20 +79,23 @@ public void setSprint(Sprint newSprint) {
this.sprint = newSprint;
}

protected Issue(String title, String content, int number, IssueStatus status, Member assignee, Project project) {

protected Issue(String title, String content, int number, IssueStatus status, IssueLabel label, Member assignee,
Project project) {
this.title = title;
this.content = content;
this.number = number;
this.status = status;
this.label = label;
this.assignee = assignee;
this.project = project;

}

protected void updateIssue(IssueEditRequest request, Member assignee) {
this.title = request.getTitle();
this.content = request.getContent();
this.status = request.getStatus();
this.label = request.getLabel();
this.assignee = assignee;
}

Expand Down
17 changes: 17 additions & 0 deletions src/main/java/dynamicquad/agilehub/issue/domain/IssueLabel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package dynamicquad.agilehub.issue.domain;

import com.fasterxml.jackson.annotation.JsonCreator;
import java.util.stream.Stream;

public enum IssueLabel {
NONE, PLAN, DESIGN, DEVELOP, TEST, FEEDBACK;

@JsonCreator
public static IssueLabel parsing(String value) {
return Stream.of(IssueLabel.values())
.filter(label -> label.toString().equalsIgnoreCase(value))
.findFirst()
.orElse(NONE);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import dynamicquad.agilehub.issue.controller.request.IssueRequest.IssueEditRequest;
import dynamicquad.agilehub.issue.domain.Issue;
import dynamicquad.agilehub.issue.domain.IssueLabel;
import dynamicquad.agilehub.issue.domain.IssueStatus;
import dynamicquad.agilehub.issue.domain.story.Story;
import dynamicquad.agilehub.member.domain.Member;
Expand Down Expand Up @@ -31,13 +32,13 @@ public class Epic extends Issue {
private List<Story> stories = new ArrayList<>();

@Builder
private Epic(String title, String content, int number, IssueStatus status, Member assignee, Project project,
LocalDate startDate, LocalDate endDate) {
super(title, content, number, status, assignee, project);
private Epic(String title, String content, int number, IssueStatus status, IssueLabel label, Member assignee,
Project project, LocalDate startDate, LocalDate endDate) {
super(title, content, number, status, label, assignee, project);
this.startDate = startDate;
this.endDate = endDate;
}

public void updateEpic(IssueEditRequest request, Member assignee) {
super.updateIssue(request, assignee);
this.startDate = request.getStartDate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import dynamicquad.agilehub.issue.controller.request.IssueRequest.IssueEditRequest;
import dynamicquad.agilehub.issue.domain.Issue;
import dynamicquad.agilehub.issue.domain.IssueLabel;
import dynamicquad.agilehub.issue.domain.IssueStatus;
import dynamicquad.agilehub.issue.domain.epic.Epic;
import dynamicquad.agilehub.issue.domain.task.Task;
Expand Down Expand Up @@ -40,9 +41,10 @@ public class Story extends Issue {
private List<Task> tasks = new ArrayList<>();

@Builder
private Story(String title, String content, int number, IssueStatus status, Member assignee, Project project,
private Story(String title, String content, int number, IssueStatus status, IssueLabel label, Member assignee,
Project project,
int storyPoint, LocalDate startDate, LocalDate endDate, Epic epic) {
super(title, content, number, status, assignee, project);
super(title, content, number, status, label, assignee, project);
this.storyPoint = storyPoint;
this.startDate = startDate;
this.endDate = endDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import dynamicquad.agilehub.issue.controller.request.IssueRequest.IssueEditRequest;
import dynamicquad.agilehub.issue.domain.Issue;
import dynamicquad.agilehub.issue.domain.IssueLabel;
import dynamicquad.agilehub.issue.domain.IssueStatus;
import dynamicquad.agilehub.issue.domain.story.Story;
import dynamicquad.agilehub.member.domain.Member;
Expand All @@ -28,9 +29,10 @@ public class Task extends Issue {
private Story story;

@Builder
private Task(String title, String content, int number, IssueStatus status, Member assignee, Project project,
private Task(String title, String content, int number, IssueStatus status, IssueLabel label, Member assignee,
Project project,
Story story) {
super(title, content, number, status, assignee, project);
super(title, content, number, status, label, assignee, project);
this.story = story;
if (story != null) {
story.getTasks().add(this);
Expand Down
Loading

0 comments on commit af14c00

Please sign in to comment.