Skip to content

Commit

Permalink
Merge pull request #69 from KUSITMS-30th-TEAM-A/feature/#68/add-field
Browse files Browse the repository at this point in the history
[feat] : 이미지 URL & 소개 문구 & 색상 필드를 추가한다
  • Loading branch information
bbbang105 authored Nov 10, 2024
2 parents 93c8307 + fb4c60f commit 3041554
Show file tree
Hide file tree
Showing 17 changed files with 496 additions and 332 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ public <T extends Enum<T> & StadiumStatusType> SaveTopRankedZoneResponseDto save
.imgUrl(recommendedProfile.getImgUrl())
.nickname(recommendedProfile.getNickName())
.type(recommendedProfile.getType())
.explanation(recommendedProfile.getExplanation())
.hashTags(recommendedProfile.getHashTags())
.build();
profileRepository.save(profile);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/kusitms/backend/result/common/Reference.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@
@Getter
public class Reference {

private String title;
private String content;
private final String title;
private final String[] contents;

@JsonCreator
public Reference(
@JsonProperty("title") String title,
@JsonProperty("content") String content
@JsonProperty("contents") String[] contents
) {
this.title = title;
this.content = content;
this.contents = contents;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ public class Profile extends BaseTimeEntity {
@Column(nullable = false)
private String type;

@Column(nullable = false)
private String explanation;

@Lob
@Convert(converter = StringListConverter.class)
private List<String> hashTags;
Expand All @@ -47,7 +44,6 @@ public Profile(Result result, String imgUrl, String nickname, String type, Strin
this.imgUrl = imgUrl;
this.nickname = nickname;
this.type = type;
this.explanation = explanation;
this.hashTags = hashTags;
}
}

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public enum ProfileStatusType {
EATING("https://kr.object.ncloudstorage.com/hitzone-bucket/hitzone/recommendation/eating.svg",
"이러다 공까지 먹어버러",
"야구가 참 맛있고 음식이 재밌어요",
"야구장에서 먹는 재미까지 놓치지 않는 당신!\n야구장을 두 배로 재밌게 즐기는군요?",
List.of("#먹으러왔는데야구도한다?", "#그래서여기구장맛있는거뭐라고?"),
List.of("#야구장미식가", "#먹으러왔는데야구도한다?"),
List.of("나 혼자", "같은 팀 팬과", "다른 팀 팬과"),
List.of("음식 먹기 편한", "경기장 한 눈에 보기", "삼겹살 구워먹기 가능", "빠른 퇴장 가능", "편리한 화장실 이용"),
List.of(),
Expand All @@ -22,8 +21,7 @@ public enum ProfileStatusType {
LIFE("https://kr.object.ncloudstorage.com/hitzone-bucket/hitzone/recommendation/life.svg",
"주6일 야구장 출퇴근러",
"야구가 나의 삶이고, 야구가 나의 숨",
"야구장에서 열정적인 응원을 보여주는 당신!\n당신의 응원 덕에 선수들이 더 행복해 질 거예요!",
List.of("#월요일은심심해", "#18시를공기로안다"),
List.of("#비공식응원단장", "#오늘도야구장출석완료"),
List.of("나 혼자", "같은 팀 팬과"),
List.of("열정적인 응원", "선수들 가까이"),
List.of(),
Expand All @@ -32,8 +30,7 @@ public enum ProfileStatusType {
ANGRY("https://kr.object.ncloudstorage.com/hitzone-bucket/hitzone/recommendation/angry.svg",
"마운드 직진러",
"나와. 이럴 거면 내가 경기 뛸게",
"야구를 통해 희노애락을 다 느끼는 당신!\n몰입하며 보는 야구가 얼마나 재밌는 지 아시는군요?",
List.of("#오늘부터내가야구선수", "#우리팀승리기원n일차"),
List.of("#야구와인생동행", "#일희일비야구중독자"),
List.of("나 혼자", "같은 팀 팬과"),
List.of("열정적인 응원", "선수들 가까이"),
List.of(),
Expand All @@ -42,8 +39,7 @@ public enum ProfileStatusType {
CALM("https://kr.object.ncloudstorage.com/hitzone-bucket/hitzone/recommendation/calm.svg",
"뜨거운 열기 속 침착러",
"야구란 자고로 그라운드의 열기 속에서 고요함을 느끼는 것",
"경기를 조용하게 관람하는걸 좋아하는 당신!\n경기를 음미하는 것을 좋아하시는군요?",
List.of("#나는나의갈길을간다", "#진짜는조용한법"),
List.of("#야구는천천히음미하는것", "#디테일에빠지다"),
List.of("나 혼자", "같은 팀 팬과", "다른 팀 팬과"),
List.of("경기장 한 눈에 보기", "빠른 퇴장 가능", "편리한 화장실 이용"),
List.of(),
Expand All @@ -52,8 +48,7 @@ public enum ProfileStatusType {
TRAVEL("https://kr.object.ncloudstorage.com/hitzone-bucket/hitzone/recommendation/travel.svg",
"베이스 낭만 여행러",
"야구장에서 한 페이지가 될 수 있게",
"나의 소중한 직관 메이트와 추억을 쌓는 것이 좋은 당신!\n야구장에서의 추억이 행복하길 바라요~",
List.of("#너와함께하는9이닝", "#우리다음에또갈까?"),
List.of("#너와함께하는9이닝", "#야구는추억을남긴다"),
List.of("같은 팀 팬과", "다른 팀 팬과"),
List.of("빠른 퇴장 가능", "편리한 화장실 이용"),
List.of(),
Expand All @@ -63,7 +58,6 @@ public enum ProfileStatusType {
private final String imgUrl;
private final String nickName;
private final String type;
private final String explanation;
private final List<String> hashTags;
private final List<String> page1Keywords;
private final List<String> page2Keywords;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,16 @@ public interface StadiumStatusType {
String getZoneColor();
String getOneLineDescription();
List<String> getExplanations();
String getFirstBaseSide();
String getThirdBaseSide();
String getTip();
List<ReferencesGroup> getReferencesGroup();
List<String> getPage1Keywords();
List<String> getPage2Keywords();
List<String> getPage3Keywords();
List<String> getForbiddenKeywords();
String getEntrance();
String getStepSpacing();
String getSeatSpacing();
String getUsageInformation();
String[] getEntrance();
String[] getStepSpacing();
String[] getSeatSpacing();
String[] getUsageInformation();
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ public record GetProfileResponseDto(
String imgUrl,
String nickname,
String type,
String explanation,
List<String> hashTags
) {
public static GetProfileResponseDto from(Profile profile) {
Expand All @@ -18,7 +17,6 @@ public static GetProfileResponseDto from(Profile profile) {
profile.getImgUrl(),
profile.getNickname(),
profile.getType(),
profile.getExplanation(),
profile.getHashTags()
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
import kusitms.backend.result.domain.enums.JamsilStadiumStatusType;
import kusitms.backend.result.domain.enums.KtWizStadiumStatusType;
import kusitms.backend.result.domain.enums.StadiumStatusType;
import kusitms.backend.stadium.domain.enums.StadiumInfo;
import kusitms.backend.stadium.dto.response.GetStadiumInfosResponseDto;
import kusitms.backend.stadium.dto.response.GetZoneGuideResponseDto;
import kusitms.backend.stadium.dto.response.GetZonesNameResponseDto;
import kusitms.backend.stadium.status.StadiumErrorStatus;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
Expand All @@ -19,13 +20,27 @@
public class StadiumService {

@Transactional(readOnly = true)
public GetZonesNameResponseDto getZonesName(String stadiumName) {
List<String> zoneNames = switch (stadiumName) {
case "잠실종합운동장 (잠실)" -> getZoneNamesFromStadium(JamsilStadiumStatusType.values());
case "수원KT위즈파크" -> getZoneNamesFromStadium(KtWizStadiumStatusType.values());
public GetStadiumInfosResponseDto getStadiumInfos(String stadiumName) {
StadiumInfo stadiumInfo = getStadiumInfoByName(stadiumName);
List<GetStadiumInfosResponseDto.ZoneInfo> zoneInfos = getZonesNameAndColorFromStadium(getStatusTypesByName(stadiumName));

return GetStadiumInfosResponseDto.of(stadiumInfo.getImgUrl(), stadiumInfo.getIntroduction(), stadiumInfo.getFirstBaseSide(), stadiumInfo.getThirdBaseSide(), zoneInfos);
}

private StadiumInfo getStadiumInfoByName(String stadiumName) {
return switch (stadiumName) {
case "잠실종합운동장 (잠실)" -> StadiumInfo.LG_HOME;
case "수원KT위즈파크" -> StadiumInfo.KT_HOME;
default -> throw new CustomException(StadiumErrorStatus._NOT_FOUND_STADIUM);
};
}

private StadiumStatusType[] getStatusTypesByName(String stadiumName) {
return switch (stadiumName) {
case "잠실종합운동장 (잠실)" -> JamsilStadiumStatusType.values();
case "수원KT위즈파크" -> KtWizStadiumStatusType.values();
default -> throw new CustomException(StadiumErrorStatus._NOT_FOUND_STADIUM);
};
return GetZonesNameResponseDto.of(zoneNames);
}

@Transactional(readOnly = true)
Expand All @@ -38,9 +53,9 @@ public GetZoneGuideResponseDto getZoneGuide(String stadiumName, String zoneName)
return GetZoneGuideResponseDto.from(zoneType);
}

private List<String> getZoneNamesFromStadium(StadiumStatusType[] statusTypes) {
private List<GetStadiumInfosResponseDto.ZoneInfo> getZonesNameAndColorFromStadium(StadiumStatusType[] statusTypes) {
return Arrays.stream(statusTypes)
.map(StadiumStatusType::getZoneName)
.map(status -> GetStadiumInfosResponseDto.ZoneInfo.of(status.getZoneName(), status.getZoneColor()))
.toList();
}

Expand All @@ -50,4 +65,4 @@ private StadiumStatusType findZoneInStadium(StadiumStatusType[] statusTypes, Str
.findFirst()
.orElseThrow(() -> new CustomException(StadiumErrorStatus._NOT_FOUND_ZONE));
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package kusitms.backend.stadium.domain.enums;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public enum StadiumInfo {

LG_HOME("https://kr.object.ncloudstorage.com/hitzone-bucket/hitzone/guide/lg/guide_home_lg.png",
"서울의 자존심, LG 트윈스 / 미라클 두산, 두산 베어스",
"두산베어스, LG 트윈스",
"상대팀"
),
KT_HOME("https://kr.object.ncloudstorage.com/hitzone-bucket/hitzone/guide/kt/guide_home_kt.png",
"한국 프로 야구의 10번째 심장 KT wiz",
"KT WIZ",
"상대팀"
)
;

private final String imgUrl;
private final String introduction;
private final String firstBaseSide;
private final String thirdBaseSide;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package kusitms.backend.stadium.dto.response;

import java.util.List;

public record GetStadiumInfosResponseDto(
String imgUrl,
String introduction,
String firstBaseSide,
String thirdBaseSide,
List<ZoneInfo> zones
) {
public static GetStadiumInfosResponseDto of(String imgUrl, String introduction, String firstBaseSide, String thirdBaseSideList, List<ZoneInfo> zoneInfos) {
return new GetStadiumInfosResponseDto(imgUrl, introduction, firstBaseSide, thirdBaseSideList, zoneInfos);
}

public record ZoneInfo(
String zoneName,
String zoneColor
) {
public static ZoneInfo of(String zoneName, String zoneColor) {
return new ZoneInfo(zoneName, zoneColor);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@ public record GetZoneGuideResponseDto(
String zoneName,
String zoneColor,
String explanation,
String entrance,
String stepSpacing,
String seatSpacing,
String usageInformation,
String firstBaseSide,
String thirdBaseSide,
String[] entrance,
String[] stepSpacing,
String[] seatSpacing,
String[] usageInformation,
String tip,
List<ReferencesGroup> referencesGroup
) {
Expand All @@ -24,6 +26,8 @@ public static GetZoneGuideResponseDto from(StadiumStatusType zone) {
zone.getZoneName(),
zone.getZoneColor(),
zone.getOneLineDescription(),
zone.getFirstBaseSide(),
zone.getThirdBaseSide(),
zone.getEntrance(),
zone.getStepSpacing(),
zone.getSeatSpacing(),
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import jakarta.validation.constraints.NotBlank;
import kusitms.backend.global.dto.ApiResponse;
import kusitms.backend.stadium.application.StadiumService;
import kusitms.backend.stadium.dto.response.GetStadiumInfosResponseDto;
import kusitms.backend.stadium.dto.response.GetZoneGuideResponseDto;
import kusitms.backend.stadium.dto.response.GetZonesNameResponseDto;
import kusitms.backend.stadium.status.StadiumSuccessStatus;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
Expand All @@ -23,14 +23,14 @@ public class StadiumController {
private final StadiumService stadiumService;

/**
* 해당 스타디움의 구역 이름들을 조회한다.
* @return 구역 이름들 리스트
* 해당 스타디움의 홈 이미지, 소개 문구, 구역 이름 & 색상 리스트를 조회한다.
* @return 홈 이미지, 소개 문구, 구역 이름 & 색상 리스트
*/
@GetMapping("/stadium/zones")
public ResponseEntity<ApiResponse<GetZonesNameResponseDto>> getZonesName(
public ResponseEntity<ApiResponse<GetStadiumInfosResponseDto>> getStadiumInfos(
@RequestParam @NotBlank String stadiumName
) {
return ApiResponse.onSuccess(StadiumSuccessStatus._OK_GET_ZONES_NAME, stadiumService.getZonesName(stadiumName));
return ApiResponse.onSuccess(StadiumSuccessStatus._OK_GET_ZONE_INFOS, stadiumService.getStadiumInfos(stadiumName));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@Getter
@AllArgsConstructor
public enum StadiumSuccessStatus implements BaseCode {
_OK_GET_ZONES_NAME(HttpStatus.OK, "200", "해당 스타디움의 구역 이름들이 조회되었습니다."),
_OK_GET_ZONE_INFOS(HttpStatus.OK, "200", "해당 스타디움의 정보가 조회되었습니다."),
_OK_GET_ZONE_GUIDE(HttpStatus.OK, "200", "해당 구역에 대한 가이드 정보가 조회되었습니다.");

private final HttpStatus httpStatus;
Expand Down
Loading

0 comments on commit 3041554

Please sign in to comment.