Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ public ResponseEntity<SuccessResponse<TagCreateResponse>> createTag(
@RequestBody final TagCreateRequest request
) {
Tag tag = tagCreateUseCase.create(
new TagCreateCommand(
TagCreateCommand.createWithHexColor(
authorizationUser.memberId(),
request.color(),
request.hexCode(),
request.name()
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
public record TagCreateRequest(
@Schema(description = "태그 이름")
String name,
@Schema(description = "태그 색상")
TagColor color
@Schema(description = "태그 색상 헥스코드")
String hexCode
) {
}
12 changes: 12 additions & 0 deletions src/main/java/com/official/memento/tag/domain/enums/TagColor.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
package com.official.memento.tag.domain.enums;

import com.official.memento.global.exception.ErrorCode;
import com.official.memento.global.exception.InvalidRequestBodyException;

public enum TagColor {

GRAY05("#A9ADBB"),
Expand All @@ -22,4 +25,13 @@ public enum TagColor {
public String getHexCode() {
return hexCode;
}

public static TagColor fromHex(String hexCode) {
for (TagColor color : values()) {
if (color.getHexCode().equalsIgnoreCase(hexCode)) {
return color;
}
}
throw new InvalidRequestBodyException(ErrorCode.INVALID_REQUEST_BODY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ public record TagCreateCommand(
TagColor color,
String name
) {
public static TagCreateCommand of(
Long memberId,
TagColor color,
String name
) {
public static TagCreateCommand createWithHexColor(Long memberId, String colorHex, String name) {
return new TagCreateCommand(memberId, TagColor.fromHex(colorHex), name);
}

public static TagCreateCommand of(Long memberId, TagColor color, String name) {
return new TagCreateCommand(memberId, color, name);
}

}