diff --git a/server/src/main/java/com/talkka/server/bookmark/dto/BookmarkDetailReqDto.java b/server/src/main/java/com/talkka/server/bookmark/dto/BookmarkDetailReqDto.java index 5bf2e7ee..52c04a08 100644 --- a/server/src/main/java/com/talkka/server/bookmark/dto/BookmarkDetailReqDto.java +++ b/server/src/main/java/com/talkka/server/bookmark/dto/BookmarkDetailReqDto.java @@ -7,7 +7,7 @@ public record BookmarkDetailReqDto( Integer seq, - TransportType type, + String type, Long subwayStationId, Updown subwayUpdown, Long busRouteStationId @@ -18,7 +18,7 @@ public BookmarkDetailEntity toEntity( return BookmarkDetailEntity.builder() .seq(seq) .bookmark(bookmark) - .type(type) + .type(TransportType.valueOf(type)) .subwayStationId(subwayStationId) .subwayUpdown(subwayUpdown) .busRouteStationId(busRouteStationId) diff --git a/server/src/main/java/com/talkka/server/bookmark/dto/BookmarkDetailRespDto.java b/server/src/main/java/com/talkka/server/bookmark/dto/BookmarkDetailRespDto.java index 285b0d23..92394719 100644 --- a/server/src/main/java/com/talkka/server/bookmark/dto/BookmarkDetailRespDto.java +++ b/server/src/main/java/com/talkka/server/bookmark/dto/BookmarkDetailRespDto.java @@ -1,12 +1,11 @@ package com.talkka.server.bookmark.dto; import com.talkka.server.bookmark.dao.BookmarkDetailEntity; -import com.talkka.server.bookmark.enums.TransportType; import com.talkka.server.subway.enums.Updown; public record BookmarkDetailRespDto( Integer seq, - TransportType type, + String type, Long subwayStationId, Updown subwayUpdown, Long busRouteStationId @@ -14,7 +13,7 @@ public record BookmarkDetailRespDto( public static BookmarkDetailRespDto of(BookmarkDetailEntity entity) { return new BookmarkDetailRespDto( entity.getSeq(), - entity.getType(), + entity.getType().getType(), entity.getSubwayStationId(), entity.getSubwayUpdown(), entity.getBusRouteStationId() diff --git a/server/src/main/java/com/talkka/server/bookmark/enums/TransportType.java b/server/src/main/java/com/talkka/server/bookmark/enums/TransportType.java index 6303a8c8..456cdb99 100644 --- a/server/src/main/java/com/talkka/server/bookmark/enums/TransportType.java +++ b/server/src/main/java/com/talkka/server/bookmark/enums/TransportType.java @@ -1,5 +1,24 @@ package com.talkka.server.bookmark.enums; +import com.talkka.server.bookmark.exception.enums.InvalidTransportTypeEnumException; + +import lombok.Getter; + +@Getter public enum TransportType { - BUS, SUBWAY + BUS("bus"), SUBWAY("subway"); + + private final String type; + + TransportType(String type) { + this.type = type; + } + + public static TransportType valueOfEnumString(String enumValue) { + try { + return TransportType.valueOf(enumValue); + } catch (IllegalArgumentException exception) { + throw new InvalidTransportTypeEnumException(); + } + } } diff --git a/server/src/main/java/com/talkka/server/bookmark/exception/enums/InvalidTransportTypeEnumException.java b/server/src/main/java/com/talkka/server/bookmark/exception/enums/InvalidTransportTypeEnumException.java new file mode 100644 index 00000000..b78850e5 --- /dev/null +++ b/server/src/main/java/com/talkka/server/bookmark/exception/enums/InvalidTransportTypeEnumException.java @@ -0,0 +1,11 @@ +package com.talkka.server.bookmark.exception.enums; + +import com.talkka.server.common.exception.InvalidTypeException; + +public class InvalidTransportTypeEnumException extends InvalidTypeException { + private static final String MESSAGE = "잘못된 교통수단 구분입니다."; + + public InvalidTransportTypeEnumException() { + super(MESSAGE); + } +}