Skip to content

Commit

Permalink
[ARV-13] feat: facilityCode와 host 필드 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
tnals2384 committed Nov 20, 2024
1 parent 007b9f9 commit 17825ae
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ public void fetchDailyConcertInfoList() {
.doOnNext(concert -> {
if (concert != null) {
// 해당 concertCode가 있는지 확인
boolean isExist = concertRepository.existsByConcertcd(concert.getConcertcd());
boolean isExist = concertRepository.existsByconcertCode(concert.getConcertcd());

if (isExist) {
// 해당 concertCode가 있으면 정보 업데이트
Concert existingConcert = concertRepository.findByConcertcd(concert.getConcertcd());
Concert existingConcert = concertRepository.findByconcertCode(concert.getConcertcd());
existingConcert.updateFrom(concert); // 엔티티에서 정보를 업데이트하는 메소드
concertRepository.save(existingConcert); // 업데이트된 정보를 저장
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@
@AllArgsConstructor
public class KopisConcertResponse {
private String concertcd; //공연 code
private String fcltycd; //공연시설 kopis code
private String prfnm; //공연명
private String prfpdfrom; //시작 날짜
private String prfpdto; //종료 날짜
private String hallId; //공연장소 kopis code
private String hallcd; //공연장소 kopis code
private String poster; //포스터
private String pcseguidance; //가격
private String prfstate; //공연상태
private String dtguidance; //공연 타임테이블
private String entrpsnmH; //주최
private List<String> styurls; //소개이미지 list
private List<Relate> relates; //판매처 list

Expand All @@ -35,8 +37,9 @@ public static Concert toEntity(final KopisConcertResponse response) {
.poster(toIntroduceImage(response.poster))
.detailImages(toDetailImages(response.styurls))
.sellers(toSellers(response.relates))
.concertcd(response.concertcd)
.hallId(response.hallId)
.concertCode(response.concertcd)
.facilityCode(response.fcltycd)
.hallCode(response.hallcd)
.build();
}

Expand All @@ -48,6 +51,7 @@ public static ConcertInfo toConcertInfo(final KopisConcertResponse response) {
.eddate(DataConverter.convertToLocalDate(response.prfpdto))
.prfstate(ConcertStatus.convertToConcertStatus(response.prfstate))
.timeTable(response.dtguidance)
.host(response.entrpsnmH)
.build();
}

Expand All @@ -61,6 +65,7 @@ public static Seller toSeller(final Relate relate) {
public static List<Seller> toSellers(final List<Relate> relates) {
return relates.stream().map(KopisConcertResponse::toSeller).toList();
}

public static IntroduceImage toIntroduceImage(final String image) {
return new IntroduceImage(image);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ public class Concert extends BaseEntity {
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;

private String hallId;
private String concertCode;

private String concertcd;
private String hallCode;

private String facilityCode;

@Embedded
private ConcertInfo concertInfo;
Expand All @@ -48,8 +50,8 @@ public class Concert extends BaseEntity {

public void updateFrom(KopisConcertResponse response) {
this.concertInfo = KopisConcertResponse.toConcertInfo(response);
this.concertcd = response.getConcertcd();
this.hallId = response.getHallId();
this.concertCode = response.getConcertcd();
this.hallCode = response.getHallcd();
this.detailImages = KopisConcertResponse.toDetailImages(response.getStyurls());
this.sellers = KopisConcertResponse.toSellers(response.getRelates());
this.poster = KopisConcertResponse.toIntroduceImage(response.getPoster());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

@Repository
public interface ConcertRepository extends JpaRepository<Concert, Long> {
boolean existsByConcertcd(String concertcd);
Concert findByConcertcd(String concertcd);
boolean existsByconcertCode(String concertCode);
Concert findByconcertCode(String concertCode);
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.backend.allreva.concert.command.domain.value;

import jakarta.persistence.*;
import jakarta.persistence.Column;
import jakarta.persistence.Embeddable;
import jakarta.persistence.EnumType;
import jakarta.persistence.Enumerated;
import lombok.*;

import java.time.LocalDate;
Expand All @@ -19,7 +22,11 @@ public class ConcertInfo {
private LocalDate stdate;
@Column(name = "concert_eddate")
private LocalDate eddate;
@Column(name = "concert_prfstate")
@Enumerated(EnumType.STRING)
private ConcertStatus prfstate;
@Column(name = "concert_timeTable")
private String timeTable;
@Column(name = "concert_host")
private String host;
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public KopisConcertServiceImpl(WebClient.Builder webClientBuilder) {
}

@Override
public Mono<List<String>> fetchConcertCodes(String hallId, boolean isDaily) {
public Mono<List<String>> fetchConcertCodes(final String hallId, final boolean isDaily) {
return webClient.get()
.uri(buildConcertUri(hallId, isDaily))
.retrieve()
Expand Down Expand Up @@ -73,7 +73,7 @@ public Mono<List<String>> fetchConcertCodes(String hallId, boolean isDaily) {
});
}

private String buildConcertUri(String hallId, boolean isDaily) {
private String buildConcertUri(final String hallId, final boolean isDaily) {
UriComponentsBuilder uriBuilder = UriComponentsBuilder.fromUriString(findConcertIdUrl)
.queryParam("prfplccd", hallId);

Expand All @@ -87,7 +87,7 @@ private String buildConcertUri(String hallId, boolean isDaily) {
}

@Override
public Mono<KopisConcertResponse> fetchConcertDetail(String hallId, String concertcd) {
public Mono<KopisConcertResponse> fetchConcertDetail(final String hallId, final String concertcd) {
return webClient.get()
.uri(UriComponentsBuilder.fromUriString(ConcertUrl)
.buildAndExpand(concertcd)
Expand All @@ -111,7 +111,7 @@ public Mono<KopisConcertResponse> fetchConcertDetail(String hallId, String conce
});
}

private KopisConcertResponse toKopisConcertResponse(JsonNode node, String concertHallId) {
private KopisConcertResponse toKopisConcertResponse(final JsonNode node, final String hallId) {
String concertcd = node.get("mt20id").asText();
String prfnm = node.get("prfnm").asText();
String prfpdfrom = node.get("prfpdfrom").asText();
Expand All @@ -120,14 +120,20 @@ private KopisConcertResponse toKopisConcertResponse(JsonNode node, String concer
String pcseguidance = node.get("pcseguidance").asText();
String dtguidance = node.get("dtguidance").asText();
String poster = node.get("poster").asText();
String entrpsnmH = node.get("entrpsnmH").asText();
List<String> styurl = getStyurls(node);
List<Relate> relate = getRelates(node);

return new KopisConcertResponse(concertcd, prfnm, prfpdfrom, prfpdto, concertHallId, poster,
pcseguidance, prfstate, dtguidance, styurl, relate);
return new KopisConcertResponse(concertcd, getFacilityId(hallId), prfnm, prfpdfrom, prfpdto, hallId, poster,
pcseguidance, prfstate, dtguidance, entrpsnmH, styurl, relate);
}

private List<Relate> getRelates(JsonNode node) {
private String getFacilityId(final String hallId) {
return hallId.split("-")[0];
}


private List<Relate> getRelates(final JsonNode node) {
List<Relate> relates = new ArrayList<>();
JsonNode relatesNode = node.get("relates").get("relate");

Expand All @@ -147,7 +153,7 @@ private List<Relate> getRelates(JsonNode node) {
return relates;
}

private List<String> getStyurls(JsonNode node) {
private List<String> getStyurls(final JsonNode node) {
JsonNode styurlsNode = node.get("styurls");
if (styurlsNode == null) return new ArrayList<>();
List<String> styurlList = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
@AllArgsConstructor
public class KopisHallResponse {
private String fcltynm; //공연시설명
private String fcltycd; //공연시설코드
private String prfplcnm; //공연장명
private String seatscale; //좌석수
private String mt13id; //공연장코드
Expand All @@ -34,6 +35,7 @@ public static ConcertHall toEntity(final KopisHallResponse response) {
.hallInfo(toConcertHallInfo(response.fcltynm, response.prfplcnm, response.seatscale))
.convenienceInfo(toConvenienceInfo(response))
.location(toLocation(response.lo,response.la, response.adres))
.facilityCode(response.fcltycd)
.build();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public class ConcertHall {

private Double star;

private String facilityCode;

@Embedded
private ConcertHallInfo hallInfo;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public KopisHallServiceImpl(WebClient.Builder webClientBuilder) {
}

@Override
public Mono<KopisHallResponse> fetchConcertHallDetail(String hallId) {
public Mono<KopisHallResponse> fetchConcertHallDetail(final String hallId) {
return webClient.get()
.uri(UriComponentsBuilder.fromUriString(ConcertHallUrl)
.buildAndExpand(getFacilityId(hallId))
Expand All @@ -48,11 +48,11 @@ public Mono<KopisHallResponse> fetchConcertHallDetail(String hallId) {
}


private String getFacilityId(String hallId) {
private String getFacilityId(final String hallId) {
return hallId.split("-")[0];
}

private KopisHallResponse toKopisConcertHallResponse(String hallId, JsonNode node) {
private KopisHallResponse toKopisConcertHallResponse(final String hallId, final JsonNode node) {

String fcltynm = node.get("fcltynm").asText();
String adres = node.get("adres").asText();
Expand All @@ -70,12 +70,12 @@ private KopisHallResponse toKopisConcertHallResponse(String hallId, JsonNode nod
JsonNode mt13 = node.get("mt13s").get("mt13");
Pfmplc prfplc = getPfmplc(mt13, hallId);

return new KopisHallResponse(fcltynm, prfplc.getPrfplcnm(), prfplc.getSeatscale(), prfplc.getMt13id(),
return new KopisHallResponse(fcltynm, getFacilityId(hallId), prfplc.getPrfplcnm(), prfplc.getSeatscale(), prfplc.getMt13id(),
adres, la, lo, restaurant, cafe, store, parkinglot, parkbarrier, restbarrier, runwbarrier, elevbarrier);

}

private Pfmplc getPfmplc(JsonNode mt13, String hallId) {
private Pfmplc getPfmplc(final JsonNode mt13, final String hallId) {
if (mt13.isArray()) {
for (JsonNode one : mt13) {
if (one.path("mt13id").asText().equals(hallId)) {
Expand Down

0 comments on commit 17825ae

Please sign in to comment.