Skip to content

Commit

Permalink
feat : TransportType 관련 exception 추가 및 dto에서 String타입으로 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
Gyaak committed Aug 17, 2024
1 parent a54a299 commit ade08b0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

public record BookmarkDetailReqDto(
Integer seq,
TransportType type,
String type,
Long subwayStationId,
Updown subwayUpdown,
Long busRouteStationId
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
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
) {
public static BookmarkDetailRespDto of(BookmarkDetailEntity entity) {
return new BookmarkDetailRespDto(
entity.getSeq(),
entity.getType(),
entity.getType().getType(),
entity.getSubwayStationId(),
entity.getSubwayUpdown(),
entity.getBusRouteStationId()
Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}

0 comments on commit ade08b0

Please sign in to comment.