-
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.
[BSVR-174] 서버에서 관리하는 RGB를 Hexa Code로 변경 (#92)
* feat: section의 rgb 코드를 헥사 코드로 변경 * fix(Section): 도메인 변경으로 인한 conflict 코드 수정 * fix: data.sql에 section 변경사항 반영 * feat: BaseballTeam의 label rgb -> 헥사로 변경 * fix(BaseballTeam): rgb -> 헥사로 바꾸면서 생긴 conflict 해결 * fix: data.sql에 baseballTeam 변경사항 반영 * feat: 사용하지 않는 Rgb 관련 코드 삭제 * feat: 사용하지 않는 Rgb 관련 코드 삭제 * feat: HexCode 클래스 분리 * feat: Section에 HexCode 적용 및 충돌 코드 수정 * feat: BaseballTeam에 HexCode 적용 및 기존 코드 충돌 수정
- Loading branch information
Showing
32 changed files
with
185 additions
and
228 deletions.
There are no files selected for viewing
26 changes: 0 additions & 26 deletions
26
application/src/main/java/org/depromeet/spot/application/common/dto/RgbCodeRequest.java
This file was deleted.
Oops, something went wrong.
13 changes: 0 additions & 13 deletions
13
application/src/main/java/org/depromeet/spot/application/common/dto/RgbCodeResponse.java
This file was deleted.
Oops, something went wrong.
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
3 changes: 1 addition & 2 deletions
3
...rc/main/java/org/depromeet/spot/application/section/dto/response/SectionInfoResponse.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
17 changes: 5 additions & 12 deletions
17
...c/main/java/org/depromeet/spot/application/stadium/dto/response/HomeTeamInfoResponse.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,20 +1,13 @@ | ||
package org.depromeet.spot.application.stadium.dto.response; | ||
|
||
import org.depromeet.spot.application.common.dto.RgbCodeResponse; | ||
import org.depromeet.spot.domain.common.RgbCode; | ||
import org.depromeet.spot.usecase.port.in.team.ReadStadiumHomeTeamUsecase.HomeTeamInfo; | ||
|
||
public record HomeTeamInfoResponse(Long id, String alias, RgbCodeResponse color) { | ||
public record HomeTeamInfoResponse(Long id, String alias, String color) { | ||
|
||
public static HomeTeamInfoResponse from(HomeTeamInfo homeTeamInfo) { | ||
RgbCode rgbCode = homeTeamInfo.getRgbCode(); | ||
RgbCodeResponse rgbCodeRes = | ||
RgbCodeResponse.builder() | ||
.red(rgbCode.getRed()) | ||
.blue(rgbCode.getBlue()) | ||
.green(rgbCode.getGreen()) | ||
.build(); | ||
|
||
return new HomeTeamInfoResponse(homeTeamInfo.getId(), homeTeamInfo.getAlias(), rgbCodeRes); | ||
return new HomeTeamInfoResponse( | ||
homeTeamInfo.getId(), | ||
homeTeamInfo.getAlias(), | ||
homeTeamInfo.getLabelBackgroundColor()); | ||
} | ||
} |
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
25 changes: 25 additions & 0 deletions
25
domain/src/main/java/org/depromeet/spot/domain/common/HexCode.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,25 @@ | ||
package org.depromeet.spot.domain.common; | ||
|
||
import java.util.regex.Pattern; | ||
|
||
import org.depromeet.spot.common.exception.util.UtilException.InvalidHexCodeException; | ||
|
||
import lombok.Getter; | ||
|
||
@Getter | ||
public class HexCode { | ||
|
||
private static final Pattern HEX_PATTERN = Pattern.compile("^#[0-9A-Fa-f]{6}$"); | ||
private final String value; | ||
|
||
public HexCode(final String input) { | ||
if (!isValid(input)) { | ||
throw new InvalidHexCodeException(); | ||
} | ||
this.value = input; | ||
} | ||
|
||
private boolean isValid(final String input) { | ||
return input != null && HEX_PATTERN.matcher(input).matches(); | ||
} | ||
} |
28 changes: 0 additions & 28 deletions
28
domain/src/main/java/org/depromeet/spot/domain/common/RgbCode.java
This file was deleted.
Oops, something went wrong.
14 changes: 4 additions & 10 deletions
14
domain/src/main/java/org/depromeet/spot/domain/section/Section.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,27 +1,21 @@ | ||
package org.depromeet.spot.domain.section; | ||
|
||
import org.depromeet.spot.domain.common.RgbCode; | ||
import org.depromeet.spot.domain.common.HexCode; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.ToString; | ||
|
||
@ToString | ||
@Getter | ||
@Builder | ||
@AllArgsConstructor | ||
public class Section { | ||
|
||
private final Long id; | ||
private final Long stadiumId; | ||
private final String name; | ||
private final String alias; | ||
private final RgbCode labelRgbCode; | ||
|
||
public Section(Long id, Long stadiumId, String name, String alias, RgbCode labelRgbCode) { | ||
this.id = id; | ||
this.stadiumId = stadiumId; | ||
this.name = name; | ||
this.alias = alias; | ||
this.labelRgbCode = labelRgbCode; | ||
} | ||
private final HexCode labelColor; | ||
} |
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
64 changes: 64 additions & 0 deletions
64
domain/src/test/java/org/depromeet/spot/domain/common/HexCodeTest.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,64 @@ | ||
package org.depromeet.spot.domain.common; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
import static org.junit.jupiter.api.Assertions.assertThrows; | ||
|
||
import org.depromeet.spot.common.exception.util.UtilException.InvalidHexCodeException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class HexCodeTest { | ||
|
||
@Test | ||
public void 유효한_값으로_헥사코드를_생성할_수_있다() { | ||
// given | ||
final String input = "#FFFFFF"; | ||
|
||
// when | ||
HexCode hexCode = new HexCode(input); | ||
|
||
// then | ||
assertNotNull(hexCode); | ||
assertEquals(input, hexCode.getValue()); | ||
} | ||
|
||
@Test | ||
public void 주어진_값이_null이라면_예외를_반환한다() { | ||
// given | ||
// when | ||
// then | ||
assertThrows( | ||
InvalidHexCodeException.class, | ||
() -> { | ||
new HexCode(null); | ||
}); | ||
} | ||
|
||
@Test | ||
public void 주어진_값이_6글자가_아니라면_예외를_반환한다() { | ||
// given | ||
final String input = "#DFDFDFDF"; | ||
|
||
// when | ||
// then | ||
assertThrows( | ||
InvalidHexCodeException.class, | ||
() -> { | ||
new HexCode(input); | ||
}); | ||
} | ||
|
||
@Test | ||
public void 주어진_값이_헥사코드_범위가_아니라면_예외를_반환한다() { | ||
// given | ||
final String input = "123456"; | ||
|
||
// when | ||
// then | ||
assertThrows( | ||
InvalidHexCodeException.class, | ||
() -> { | ||
new HexCode(input); | ||
}); | ||
} | ||
} |
30 changes: 0 additions & 30 deletions
30
domain/src/test/java/org/depromeet/spot/domain/common/RgbCodeTest.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.