-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
209 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
src/main/java/com/tripmate/integration/tourapi/dto/mapper/SpotDeserializer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.tripmate.integration.tourapi.dto.mapper; | ||
|
||
import com.fasterxml.jackson.core.JsonParser; | ||
import com.fasterxml.jackson.databind.DeserializationContext; | ||
import com.fasterxml.jackson.databind.JsonDeserializer; | ||
import com.fasterxml.jackson.databind.JsonNode; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.tripmate.integration.tourapi.dto.response.SpotCommonInfo; | ||
import com.tripmate.integration.tourapi.dto.response.SpotCommonInfoApiResponse; | ||
|
||
import java.io.IOException; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
public class SpotDeserializer extends JsonDeserializer<SpotCommonInfoApiResponse> { | ||
|
||
private final ObjectMapper mapper; | ||
|
||
public SpotDeserializer() { | ||
this.mapper = new ObjectMapper(); | ||
} | ||
|
||
@Override | ||
public SpotCommonInfoApiResponse deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException { | ||
JsonNode node = jp.getCodec().readTree(jp); | ||
JsonNode items = node.findValue("item"); | ||
|
||
List<SpotCommonInfo> spotItems = Arrays.stream(mapper.treeToValue(items, SpotCommonInfo[].class)).toList(); | ||
return new SpotCommonInfoApiResponse(spotItems); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
src/main/java/com/tripmate/integration/tourapi/dto/response/SpotCommonInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package com.tripmate.integration.tourapi.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.tripmate.integration.tourapi.domain.SpotMediumCategory; | ||
import com.tripmate.integration.tourapi.domain.SpotSmallCategory; | ||
import com.tripmate.integration.tourapi.dto.mapper.SpotDeserializer; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public record SpotCommonInfo( | ||
|
||
@JsonProperty("contentId") | ||
String spotId, | ||
|
||
@JsonProperty("contenttypeid") | ||
String contentTypeId, | ||
|
||
@JsonProperty("title") | ||
String title, | ||
|
||
@JsonProperty("tel") | ||
String tel, | ||
|
||
@JsonProperty("telname") | ||
String telName, | ||
|
||
@JsonProperty("overview") | ||
String overview, | ||
|
||
@JsonProperty("cat1") | ||
String cat1, | ||
|
||
@JsonProperty("cat2") | ||
SpotMediumCategory cat2, | ||
|
||
@JsonProperty("cat3") | ||
SpotSmallCategory cat3, | ||
|
||
@JsonProperty("addr1") | ||
String addr1, | ||
|
||
@JsonProperty("addr2") | ||
String addr2, | ||
|
||
@JsonProperty("contentid") | ||
Long contentId, | ||
|
||
@JsonProperty("firstimage") | ||
String firstImage, | ||
|
||
@JsonProperty("firstimage2") | ||
String firstImage2, | ||
|
||
@JsonProperty("mapx") | ||
String mapX, | ||
|
||
@JsonProperty("mapy") | ||
String mapY, | ||
|
||
@JsonProperty("mlevel") | ||
int mLevel, | ||
|
||
@JsonProperty("modifiedtime") | ||
String modifiedTime, | ||
|
||
@JsonProperty("sigungucode") | ||
String siGunGuCode | ||
) { | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/tripmate/integration/tourapi/dto/response/SpotCommonInfoApiResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.tripmate.integration.tourapi.dto.response; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
import com.tripmate.integration.tourapi.dto.mapper.LocationBasedSpotListDeserializer; | ||
import com.tripmate.integration.tourapi.dto.mapper.SpotDeserializer; | ||
|
||
import java.util.List; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
@JsonDeserialize(using = SpotDeserializer.class) | ||
public record SpotCommonInfoApiResponse( | ||
@JsonProperty("item") | ||
List<SpotCommonInfo> spotItems | ||
) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters