Skip to content

Commit

Permalink
[BE/#17] Modify : hex_code 컬럼을 background_color, color로 변경한 다음 data.s…
Browse files Browse the repository at this point in the history
…ql과 domain, vo, dao, service 코드 변경
  • Loading branch information
hanurii committed Jun 18, 2020
1 parent 0b5120d commit 35c3ade
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@ public List<Label> findAllLabels() {
Label.of(rs.getInt("id"),
rs.getString("name"),
rs.getString("description"),
rs.getString("hex_code"))
rs.getString("background_color"),
rs.getString("color"))
);
}

public List<LabelSummary> findLabelSummaryByIssueId(Long issueId) {
return jdbcTemplate.query(
"SELECT label.id, label.name, label.hex_code FROM label " +
"SELECT label.id, label.name, label.background_color, label.color FROM label " +
"JOIN issue_has_label ON label.id = issue_has_label.label_id " +
"WHERE issue_has_label.issue_id = ?",
(rs, rowNum) ->
LabelSummary.of(rs.getInt("id"),
rs.getString("name"),
rs.getString("hex_code"))
rs.getString("background_color"),
rs.getString("color"))
, issueId);
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.codesquad.issuetracker.hamill.domain;

import java.time.LocalDateTime;

public class Label {

private Integer id;
Expand All @@ -10,21 +8,25 @@ public class Label {

private String description;

private String hexCode;
private String backgroundColor;

private String color;

private Label(Integer id, String name, String description, String hexCode) {
private Label(Integer id, String name, String description, String backgroundColor, String color) {
this.id = id;
this.name = name;
this.description = description;
this.hexCode = hexCode;
this.backgroundColor = backgroundColor;
this.color = color;
}

public static Label of(Integer id, String name, String description, String hexCode) {
public static Label of(Integer id, String name, String description, String backgroundColor, String color) {
return new Builder()
.id(id)
.name(name)
.description(description)
.hexCode(hexCode)
.backgroundColor(backgroundColor)
.color(color)
.build();
}

Expand All @@ -40,15 +42,20 @@ public String getDescription() {
return description;
}

public String getHexCode() {
return hexCode;
public String getBackgroundColor() {
return backgroundColor;
}

public String getColor() {
return color;
}

private static class Builder {
private Integer id;
private String name;
private String description;
private String hexCode;
private String backgroundColor;
private String color;

private Builder() {}

Expand All @@ -67,13 +74,18 @@ private Builder description(String description) {
return this;
}

private Builder hexCode(String hexCode) {
this.hexCode = hexCode;
private Builder backgroundColor(String backgroundColor) {
this.backgroundColor = backgroundColor;
return this;
}

private Builder color(String color) {
this.color = color;
return this;
}

private Label build() {
return new Label(id, name, description, hexCode);
return new Label(id, name, description, backgroundColor, color);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public LabelInformation findLabelInformation() {

// 함수형 프로그래밍
List<LabelSummary> labelSummaries = labels.stream()
.map(label -> of(label.getId(), label.getName(), label.getHexCode()))
.map(label -> of(label.getId(), label.getName(), label.getBackgroundColor(), label.getColor()))
.collect(Collectors.toList());

return LabelInformation.of(labels.size(), labelSummaries);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ public class LabelSummary {

private String labelName;

private String hexCode;
private String backgroundColor;

private LabelSummary(Integer labelId, String labelName, String hexCode) {
private String color;

private LabelSummary(Integer labelId, String labelName, String backgroundColor, String color) {
this.labelId = labelId;
this.labelName = labelName;
this.hexCode = hexCode;
this.backgroundColor = backgroundColor;
this.color = color;
}

public static LabelSummary of(Integer labelId, String labelName, String hexCode) {
return new LabelSummary(labelId, labelName, hexCode);
public static LabelSummary of(Integer labelId, String labelName, String backgroundColor, String color) {
return new LabelSummary(labelId, labelName, backgroundColor, color);
}

public Integer getLabelId() {
Expand All @@ -26,7 +29,11 @@ public String getLabelName() {
return labelName;
}

public String getHexCode() {
return hexCode;
public String getBackgroundColor() {
return backgroundColor;
}

public String getColor() {
return color;
}
}
12 changes: 6 additions & 6 deletions BE/src/main/resources/data.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ INSERT INTO milestone (title, description, due_date, created_date_time, updated_
INSERT INTO milestone (title, description, due_date, created_date_time, updated_date_time) VALUES ('마일스톤3', '마일스톤3입니다.', '2020-06-20', '2020-06-11 01:22:32', '2020-06-11 01:22:32');
INSERT INTO milestone (title, description, due_date, created_date_time, updated_date_time) VALUES ('마일스톤4', '마일스톤4입니다.', '2020-06-21', '2020-06-11 01:22:32', '2020-06-11 01:22:32');

INSERT INTO label (name, description, hex_code) VALUES ('레이블1', '레이블1입니다.', '#aaaaaa');
INSERT INTO label (name, description, hex_code) VALUES ('레이블2', '레이블2입니다.', '#bbbbbb');
INSERT INTO label (name, description, hex_code) VALUES ('레이블3', '레이블3입니다.', '#cccccc');
INSERT INTO label (name, description, hex_code) VALUES ('레이블4', '레이블4입니다.', '#dddddd');
INSERT INTO label (name, description, hex_code) VALUES ('레이블5', '레이블5입니다.', '#eeeeee');
INSERT INTO label (name, description, hex_code) VALUES ('레이블6', '레이블6입니다.', '#ffffff');
INSERT INTO label (name, description, background_color, color) VALUES ('레이블1', '레이블1입니다.', '#aaaaaa', '#hhhhhh');
INSERT INTO label (name, description, background_color, color) VALUES ('레이블2', '레이블2입니다.', '#bbbbbb', '#jjjjjj');
INSERT INTO label (name, description, background_color, color) VALUES ('레이블3', '레이블3입니다.', '#cccccc', '#kkkkkk');
INSERT INTO label (name, description, background_color, color) VALUES ('레이블4', '레이블4입니다.', '#dddddd', '#mmmmmm');
INSERT INTO label (name, description, background_color, color) VALUES ('레이블5', '레이블5입니다.', '#eeeeee', '#nnnnnn');
INSERT INTO label (name, description, background_color, color) VALUES ('레이블6', '레이블6입니다.', '#ffffff', '#oooooo');

INSERT INTO issue (id, title, created_date_time, is_opened, user_id, milestone_id) VALUES (1, '이슈제목1', '2020-06-11 01:28:30', true, 1, 1);
INSERT INTO issue (id, title, created_date_time, is_opened, user_id, milestone_id) VALUES (2, '이슈제목2', '2020-06-11 01:28:30', true, 2, 1);
Expand Down

0 comments on commit 35c3ade

Please sign in to comment.