Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
94a91ab
feat: 카카오 챗봇 식단 API 구성
Choi-JJunho Apr 29, 2024
5a3b8fd
refactor: adapter 형태로 수정
Choi-JJunho Apr 29, 2024
118bbf2
feat: bus 남은시간 API 구현
Choi-JJunho Apr 29, 2024
ebd7f43
feat: bus 경로 API 구현
Choi-JJunho Apr 29, 2024
a48ea10
refactor: 로깅용 코드 제거
Choi-JJunho Apr 29, 2024
b00525e
refactor: KoinException 구체화
Choi-JJunho Apr 29, 2024
6e99960
refactor: Exception 정리 구체화
Choi-JJunho Apr 29, 2024
340562e
refactor: getFullMessage로 변경
Choi-JJunho Apr 29, 2024
968917a
refactor: slack 알림 dev 이외에도 포함되도록 수정
Choi-JJunho Apr 29, 2024
2063b67
test: 테스트 수정
Choi-JJunho Apr 29, 2024
b5a02b3
Merge branch 'develop' of https://github.com/BCSDLab/KOIN_API_V2 into…
Choi-JJunho Apr 30, 2024
90f5e27
refactor: 미사용 변수 제거
Choi-JJunho Apr 30, 2024
5248d2f
refactor: 메뉴 검증 추가
Choi-JJunho Apr 30, 2024
d5c7dee
fix: 오타수정
Choi-JJunho Apr 30, 2024
46325a4
refactor: magicNumber 상수 추출
Choi-JJunho Apr 30, 2024
5d9361c
refactor: 페이코로 변경
Choi-JJunho Apr 30, 2024
2217068
refactor: 표준예외, 커스텀예외 구분
Choi-JJunho Apr 30, 2024
920034d
style: 라인 포맷팅
Choi-JJunho Apr 30, 2024
e73b6b2
fix: 결과 joiner 참조 수정
Choi-JJunho Apr 30, 2024
1a18017
style: 순서 변경
Choi-JJunho Apr 30, 2024
35b10ab
refactor: from 활용
Choi-JJunho Apr 30, 2024
1f1c4fa
refactor: Enum 활용하도록 수정
Choi-JJunho Apr 30, 2024
61f7e1d
refactor: 변수명 수정
Choi-JJunho Apr 30, 2024
209e8d5
refactor: 자바 기본 예외 래핑
Choi-JJunho Apr 30, 2024
076a630
refactor: 제약조건 수정
Choi-JJunho Apr 30, 2024
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 @@ -23,14 +23,14 @@ public record BusRemainTimeResponse(

public static BusRemainTimeResponse of(BusType busType, List<? extends BusRemainTime> remainTimes, Clock clock) {
return new BusRemainTimeResponse(
busType.name().toLowerCase(),
busType.getName(),
Comment thread
Choi-JJunho marked this conversation as resolved.
InnerBusResponse.of(remainTimes, 0, clock),
InnerBusResponse.of(remainTimes, 1, clock)
);
}

@JsonNaming(SnakeCaseStrategy.class)
private record InnerBusResponse(
public record InnerBusResponse(
@Schema(description = "버스 번호", example = "400", requiredMode = NOT_REQUIRED)
Long busNumber,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,16 @@
public class ApiTypeNotFoundException extends DataNotFoundException {

public static final String DEFAULT_MESSAGE = "존재하지 않는 API 타입입니다.";
private final String detail;

public ApiTypeNotFoundException(String message) {
super(message);
this.detail = null;
}

public ApiTypeNotFoundException(String message, String detail) {
super(message);
this.detail = detail;
super(message, detail);
}

public static ApiTypeNotFoundException withDetail(String detail) {
return new ApiTypeNotFoundException(DEFAULT_MESSAGE, detail);
}

@Override
public String getDetail() {
return DEFAULT_MESSAGE;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,16 @@
public class BusArrivalNodeNotFoundException extends DataNotFoundException {

private static final String DEFAULT_MESSAGE = "버스 경로 상에 해당 노드가 존재하지 않습니다.";
private final String detail;

public BusArrivalNodeNotFoundException(String message) {
super(message);
this.detail = null;
}

public BusArrivalNodeNotFoundException(String message, String detail) {
super(message);
this.detail = detail;
super(message, detail);
}

public static BusArrivalNodeNotFoundException withDetail(String detail) {
return new BusArrivalNodeNotFoundException(DEFAULT_MESSAGE, detail);
}

@Override
public String getDetail() {
return detail;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,16 @@
public class BusCacheNotFoundException extends DataNotFoundException {

private static final String DEFAULT_MESSAGE = "버스 캐시가 존재하지 않습니다.";
private final String detail;

public BusCacheNotFoundException(String message) {
super(message);
this.detail = null;
}

public BusCacheNotFoundException(String message, String detail) {
super(message);
this.detail = detail;
super(message, detail);
}

public static BusCacheNotFoundException withDetail(String detail) {
return new BusCacheNotFoundException(DEFAULT_MESSAGE, detail);
}

@Override
public String getDetail() {
return detail;
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package in.koreatech.koin.domain.bus.exception;

public class BusDirectionNotFoundException extends IllegalArgumentException {
import in.koreatech.koin.global.exception.KoinIllegalArgumentException;

public class BusDirectionNotFoundException extends KoinIllegalArgumentException {

private static final String DEFAULT_MESSAGE = "정상적인 버스 방향이 아닙니다.";

public BusDirectionNotFoundException(String message) {
super(message);
}

public BusDirectionNotFoundException(String message, String detail) {
super(message, detail);
}

public static BusDirectionNotFoundException withDetail(String detail) {
String message = String.format("%s %s", DEFAULT_MESSAGE, detail);
return new BusDirectionNotFoundException(message);
return new BusDirectionNotFoundException(DEFAULT_MESSAGE, detail);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package in.koreatech.koin.domain.bus.exception;

public class BusIllegalArrivalTime extends IllegalArgumentException {
import in.koreatech.koin.global.exception.KoinIllegalArgumentException;

public class BusIllegalArrivalTime extends KoinIllegalArgumentException {

private static final String DEFAULT_MESSAGE = "버스 도착 시각이 잘못되었습니다.";

public BusIllegalArrivalTime(String message) {
super(message);
}

public BusIllegalArrivalTime(String message, String detail) {
super(message, detail);
}

public static BusIllegalArrivalTime withDetail(String detail) {
String message = String.format("%s %s", DEFAULT_MESSAGE, detail);
return new BusIllegalArrivalTime(message);
return new BusIllegalArrivalTime(DEFAULT_MESSAGE, detail);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package in.koreatech.koin.domain.bus.exception;

public class BusIllegalStationException extends IllegalArgumentException {
import in.koreatech.koin.global.exception.KoinIllegalArgumentException;

public class BusIllegalStationException extends KoinIllegalArgumentException {

private static final String DEFAULT_MESSAGE = "버스 정류장이 잘못되었습니다.";

public BusIllegalStationException(String message) {
super(message);
}

public BusIllegalStationException(String message, String detail) {
super(message, detail);
}

public static BusIllegalStationException withDetail(String detail) {
String message = String.format("%s %s", DEFAULT_MESSAGE, detail);
return new BusIllegalStationException(message);
return new BusIllegalStationException(DEFAULT_MESSAGE, detail);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,16 @@
public class BusNotFoundException extends DataNotFoundException {

private static final String DEFAULT_MESSAGE = "버스가 존재하지 않습니다.";
private final String detail;

public BusNotFoundException(String message) {
super(message);
this.detail = null;
}

public BusNotFoundException(String message, String detail) {
super(message);
this.detail = detail;
super(message, detail);
}

public static BusNotFoundException withDetail(String detail) {
return new BusNotFoundException(DEFAULT_MESSAGE, detail);
}

@Override
public String getDetail() {
return detail;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,16 @@
public class BusOpenApiException extends ExternalServiceException {

private static final String DEFAULT_MESSAGE = "버스 Open API 응답이 정상적이지 않습니다.";
private final String detail;

public BusOpenApiException(String message) {
super(message);
this.detail = null;
}

public BusOpenApiException(String message, String detail) {
super(message);
this.detail = detail;
super(message, detail);
}

public static BusOpenApiException withDetail(String detail) {
return new BusOpenApiException(DEFAULT_MESSAGE, detail);
}

@Override
public String getDetail() {
return detail;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,16 @@
public class BusStationNotFoundException extends DataNotFoundException {

private static final String DEFAULT_MESSAGE = "버스 정류장이 존재하지 않습니다.";
private final String detail;

public BusStationNotFoundException(String message) {
super(message);
this.detail = null;
}

public BusStationNotFoundException(String message, String detail) {
super(message);
this.detail = detail;
super(message, detail);
}

public static BusStationNotFoundException withDetail(String detail) {
return new BusStationNotFoundException(DEFAULT_MESSAGE, detail);
}

@Override
public String getDetail() {
return detail;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,16 @@
public class BusTypeNotFoundException extends DataNotFoundException {

private static final String DEFAULT_MESSAGE = "버스 타입이 존재하지 않습니다.";
private final String detail;

public BusTypeNotFoundException(String message) {
super(message);
this.detail = null;
}

public BusTypeNotFoundException(String message, String detail) {
super(message);
this.detail = detail;
super(message, detail);
}

public static BusTypeNotFoundException withDetail(String detail) {
return new BusTypeNotFoundException(DEFAULT_MESSAGE, detail);
}

@Override
public String getDetail() {
return detail;
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,20 @@
package in.koreatech.koin.domain.bus.exception;

public class BusTypeNotSupportException extends IllegalArgumentException {
import in.koreatech.koin.global.exception.KoinIllegalArgumentException;

public class BusTypeNotSupportException extends KoinIllegalArgumentException {

private static final String DEFAULT_MESSAGE = "해당 버스타입에는 지원하지 않는 기능입니다.";

public BusTypeNotSupportException(String message) {
super(message);
}

public BusTypeNotSupportException(String message, String detail) {
super(message, detail);
}

public static BusTypeNotSupportException withDetail(String detail) {
String message = String.format("%s %s", DEFAULT_MESSAGE, detail);
return new BusTypeNotSupportException(message);
return new BusTypeNotSupportException(DEFAULT_MESSAGE, detail);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

@Getter
public enum BusStation {
KOREATECH(List.of("학교", "한기대"), BusStationNode.KOREATECH),
KOREATECH(List.of("학교", "한기대", "코리아텍"), BusStationNode.KOREATECH),
STATION(List.of("천안역", "천안역(학화호두과자)"), BusStationNode.STATION),
TERMINAL(List.of("터미널", "터미널(신세계 앞 횡단보도)"), BusStationNode.TERMINAL),
TERMINAL(List.of("터미널", "터미널(신세계 앞 횡단보도)", "야우리"), BusStationNode.TERMINAL),
;

private final List<String> displayNames;
Expand All @@ -26,7 +26,10 @@ public enum BusStation {
@JsonCreator
public static BusStation from(String busStationName) {
return Arrays.stream(values())
.filter(busStation -> busStation.name().equalsIgnoreCase(busStationName))
.filter(
busStation -> busStation.name().equalsIgnoreCase(busStationName) ||
busStation.displayNames.contains(busStationName)
)
.findAny()
.orElseThrow(() -> BusStationNotFoundException.withDetail("busStation: " + busStationName));
}
Expand All @@ -41,4 +44,8 @@ public static BusDirection getDirection(BusStation depart, BusStation arrival) {
public String getNodeId(BusDirection direction) {
return node.getId(direction);
}

public String getName() {
return this.name().toLowerCase();
}
Comment thread
Choi-JJunho marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,27 @@

@Getter
public enum BusType {
CITY,
EXPRESS,
SHUTTLE,
COMMUTING,
CITY("시내버스"),
EXPRESS("대성고속"),
SHUTTLE("셔틀버스"),
COMMUTING("통학버스"),
;

private final String label;

BusType(String label) {
this.label = label;
}

@JsonCreator
public static BusType from(String busTypeName) {
return Arrays.stream(values())
.filter(busType -> busType.name().equalsIgnoreCase(busTypeName))
.findAny()
.orElseThrow(() -> BusTypeNotFoundException.withDetail("busType: " + busTypeName));
}

public String getName() {
Comment thread
Choi-JJunho marked this conversation as resolved.
return this.name().toLowerCase();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.util.Arrays;

import in.koreatech.koin.domain.bus.exception.BusStationNotFoundException;
import in.koreatech.koin.domain.bus.model.enums.BusStation;
import lombok.Getter;

/**
Expand All @@ -11,20 +12,22 @@
*/
@Getter
public enum ExpressBusStationNode {
KOREATECH("NAI3125301"), // 코리아텍
TERMINAL("NAI3112001"), // 종합터미널
KOREATECH(BusStation.KOREATECH, "NAI3125301"), // 코리아텍
TERMINAL(BusStation.TERMINAL, "NAI3112001"), // 종합터미널
;

private final BusStation busStation;
private final String stationId;

ExpressBusStationNode(String stationId) {
ExpressBusStationNode(BusStation busStation, String stationId) {
this.busStation = busStation;
this.stationId = stationId;
}

public static ExpressBusStationNode from(String stationName) {
return Arrays.stream(values()).
filter(it -> it.name().equalsIgnoreCase(stationName))
public static ExpressBusStationNode from(BusStation busStation) {
return Arrays.stream(values())
.filter(it -> it.busStation.equals(busStation))
.findAny()
.orElseThrow(() -> BusStationNotFoundException.withDetail("stationName: " + stationName));
.orElseThrow(() -> BusStationNotFoundException.withDetail("busStation: " + busStation));
}
}
Loading