Skip to content

Commit c82c786

Browse files
authored
Merge pull request #89 from KUSITMS-30th-TEAM-A/fix/#88/duplicate-zone
[fix] : 스타디움 구역 정보 중복 & 구역 추천(KT) 문제를 해결한다
2 parents c949bc6 + 80bf507 commit c82c786

File tree

2 files changed

+67
-21
lines changed

2 files changed

+67
-21
lines changed

src/main/java/kusitms/backend/result/domain/enums/KtWizStadiumStatusType.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
@RequiredArgsConstructor
1212
public enum KtWizStadiumStatusType implements StadiumStatusType{
1313

14-
//특징 확인 필요
1514
CENTER("https://kr.object.ncloudstorage.com/hitzone-bucket/hitzone/guide/kt/center.svg",
1615
"중앙지정석",
1716
"#5E346E",
@@ -126,10 +125,10 @@ public enum KtWizStadiumStatusType implements StadiumStatusType{
126125
)
127126
)
128127
),
129-
List.of("나 혼자", "같은 팀 팬과"),
130-
List.of("열정적인 응원"),
131128
List.of(),
132-
List.of("다른 팀 팬과", "큰 소리 싫어요", "음식 먹기 편한", "삼겹살 구워먹기 가능"),
129+
List.of(),
130+
List.of(),
131+
List.of(),
133132
new String[]{"데이터 추가 입력 예정"},
134133
new String[]{"[1루] 약 27~32cm [3루] 약 27~32cm"},
135134
new String[]{"[1루] 약 28cm [3루] 약 26~33cm"},

src/main/java/kusitms/backend/stadium/application/StadiumService.java

Lines changed: 64 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,19 @@
1515
import java.util.Arrays;
1616
import java.util.List;
1717

18+
import static kusitms.backend.result.domain.enums.KtWizStadiumStatusType.CHEERING_DUMMY;
19+
1820
@Service
1921
@RequiredArgsConstructor
2022
public class StadiumService {
2123

24+
/**
25+
* 주어진 경기장 이름에 대한 정보를 조회.
26+
*
27+
* @param stadiumName 경기장 이름
28+
* @return 경기장 정보와 구역 정보 리스트를 포함하는 DTO
29+
* @throws CustomException 유효하지 않은 경기장 이름이 주어진 경우
30+
*/
2231
@Transactional(readOnly = true)
2332
public GetStadiumInfosResponseDto getStadiumInfos(String stadiumName) {
2433
StadiumInfo stadiumInfo = getStadiumInfoByName(stadiumName);
@@ -27,22 +36,14 @@ public GetStadiumInfosResponseDto getStadiumInfos(String stadiumName) {
2736
return GetStadiumInfosResponseDto.of(stadiumInfo.getImgUrl(), stadiumInfo.getFirstBaseSide(), stadiumInfo.getThirdBaseSide(), zoneInfos);
2837
}
2938

30-
private StadiumInfo getStadiumInfoByName(String stadiumName) {
31-
return switch (stadiumName) {
32-
case "잠실종합운동장 (잠실)" -> StadiumInfo.LG_HOME;
33-
case "수원KT위즈파크" -> StadiumInfo.KT_HOME;
34-
default -> throw new CustomException(StadiumErrorStatus._NOT_FOUND_STADIUM);
35-
};
36-
}
37-
38-
private StadiumStatusType[] getStatusTypesByName(String stadiumName) {
39-
return switch (stadiumName) {
40-
case "잠실종합운동장 (잠실)" -> JamsilStadiumStatusType.values();
41-
case "수원KT위즈파크" -> KtWizStadiumStatusType.values();
42-
default -> throw new CustomException(StadiumErrorStatus._NOT_FOUND_STADIUM);
43-
};
44-
}
45-
39+
/**
40+
* 주어진 경기장 이름에 해당하는 구역 정보를 조회.
41+
*
42+
* @param stadiumName 경기장 이름
43+
* @param zoneName 구역 이름
44+
* @return 구역 정보 DTO
45+
* @throws CustomException 유효하지 않은 경기장 이름이나 구역 이름이 주어진 경우
46+
*/
4647
@Transactional(readOnly = true)
4748
public GetZoneGuideResponseDto getZoneGuide(String stadiumName, String zoneName) {
4849
StadiumStatusType zoneType = switch (stadiumName) {
@@ -53,16 +54,62 @@ public GetZoneGuideResponseDto getZoneGuide(String stadiumName, String zoneName)
5354
return GetZoneGuideResponseDto.from(zoneType);
5455
}
5556

57+
/**
58+
* 주어진 상태 타입 배열에서 특정 구역의 이름과 색상을 조회.
59+
* CHEERING_DUMMY 구역은 제외됩니다.
60+
*
61+
* @param statusTypes 상태 타입 배열
62+
* @return 구역 이름과 색상 정보를 담은 리스트
63+
*/
5664
private List<GetStadiumInfosResponseDto.ZoneInfo> getZonesNameAndColorFromStadium(StadiumStatusType[] statusTypes) {
5765
return Arrays.stream(statusTypes)
66+
.filter(status -> status != CHEERING_DUMMY)
5867
.map(status -> GetStadiumInfosResponseDto.ZoneInfo.of(status.getZoneName(), status.getZoneColor()))
5968
.toList();
6069
}
6170

71+
/**
72+
* 주어진 상태 타입 배열에서 특정 구역 이름과 일치하는 구역 정보를 조회.
73+
*
74+
* @param statusTypes 상태 타입 배열
75+
* @param zoneName 구역 이름
76+
* @return 일치하는 구역 정보
77+
* @throws CustomException 일치하는 구역을 찾을 수 없는 경우
78+
*/
6279
private StadiumStatusType findZoneInStadium(StadiumStatusType[] statusTypes, String zoneName) {
6380
return Arrays.stream(statusTypes)
6481
.filter(status -> status.getZoneName().equals(zoneName))
6582
.findFirst()
6683
.orElseThrow(() -> new CustomException(StadiumErrorStatus._NOT_FOUND_ZONE));
6784
}
68-
}
85+
86+
/**
87+
* 주어진 경기장 이름에 대한 기본 정보를 조회.
88+
*
89+
* @param stadiumName 경기장 이름
90+
* @return 경기장 기본 정보
91+
* @throws CustomException 유효하지 않은 경기장 이름이 주어진 경우
92+
*/
93+
private StadiumInfo getStadiumInfoByName(String stadiumName) {
94+
return switch (stadiumName) {
95+
case "잠실종합운동장 (잠실)" -> StadiumInfo.LG_HOME;
96+
case "수원KT위즈파크" -> StadiumInfo.KT_HOME;
97+
default -> throw new CustomException(StadiumErrorStatus._NOT_FOUND_STADIUM);
98+
};
99+
}
100+
101+
/**
102+
* 주어진 경기장 이름에 대한 상태 타입 배열을 조회.
103+
*
104+
* @param stadiumName 경기장 이름
105+
* @return 경기장 상태 타입 배열
106+
* @throws CustomException 유효하지 않은 경기장 이름이 주어진 경우
107+
*/
108+
private StadiumStatusType[] getStatusTypesByName(String stadiumName) {
109+
return switch (stadiumName) {
110+
case "잠실종합운동장 (잠실)" -> JamsilStadiumStatusType.values();
111+
case "수원KT위즈파크" -> KtWizStadiumStatusType.values();
112+
default -> throw new CustomException(StadiumErrorStatus._NOT_FOUND_STADIUM);
113+
};
114+
}
115+
}

0 commit comments

Comments
 (0)