-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from lcj1204/develop
[Feat] 도로명 주소 API 호출 기능 생성
- Loading branch information
Showing
14 changed files
with
176 additions
and
37 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
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
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
30 changes: 30 additions & 0 deletions
30
pothole-core/src/main/java/pothole_solution/core/domain/pothole/entity/RoadAddress.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,30 @@ | ||
package pothole_solution.core.domain.pothole.entity; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class RoadAddress { | ||
private String zipcode; | ||
private String text; | ||
private Structure structure; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Structure { | ||
private String level0; | ||
private String level1; | ||
private String level2; | ||
private String level3; | ||
private String level4L; | ||
private String level4LC; | ||
private String level4A; | ||
private String level4AC; | ||
private String level5; | ||
private String detail; | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...c/main/java/pothole_solution/core/domain/pothole/entity/RoadAddressSearchApiResponse.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,33 @@ | ||
package pothole_solution.core.domain.pothole.entity; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class RoadAddressSearchApiResponse { | ||
private Response response; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Response { | ||
private Service service; | ||
private String status; | ||
private List<RoadAddress> result; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Service { | ||
private String name; | ||
private String version; | ||
private String operation; | ||
private String time; | ||
} | ||
} | ||
} |
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
22 changes: 22 additions & 0 deletions
22
...core/src/main/java/pothole_solution/core/domain/pothole/service/RoadAddressSearchApi.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,22 @@ | ||
package pothole_solution.core.domain.pothole.service; | ||
|
||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestParam; | ||
import pothole_solution.core.domain.pothole.entity.RoadAddressSearchApiResponse; | ||
|
||
@FeignClient(value= "search", url = "https://api.vworld.kr") | ||
public interface RoadAddressSearchApi { | ||
|
||
@GetMapping(value = "/req/address",produces = MediaType.APPLICATION_JSON_VALUE) | ||
RoadAddressSearchApiResponse getRoadAddress(@RequestParam("point") String point, | ||
@RequestParam("key") String key, | ||
@RequestParam("service") String service, | ||
@RequestParam("request") String request, | ||
@RequestParam("crs") String crs, | ||
@RequestParam("type") String type, | ||
@RequestParam("simple") boolean simple | ||
); | ||
|
||
} |
33 changes: 33 additions & 0 deletions
33
.../src/main/java/pothole_solution/core/domain/pothole/service/RoadAddressSearchService.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,33 @@ | ||
package pothole_solution.core.domain.pothole.service; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
import pothole_solution.core.domain.pothole.entity.RoadAddress; | ||
import pothole_solution.core.domain.pothole.entity.RoadAddressSearchApiResponse; | ||
|
||
import static pothole_solution.core.global.exception.CustomException.INVALID_PARAMETER; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class RoadAddressSearchService { | ||
private final RoadAddressSearchApi roadAddressSearchApi; | ||
|
||
public RoadAddress getRoadAddress(String point){ | ||
RoadAddressSearchApiResponse response = roadAddressSearchApi.getRoadAddress( | ||
point, | ||
"9BFAD946-FBB2-3B7A-9179-82007C7B8D57", | ||
"address", | ||
"getAddress", | ||
"epsg:4326", | ||
"ROAD", | ||
true | ||
); | ||
|
||
if (response.getResponse().getStatus().equals("ERROR")) { | ||
throw INVALID_PARAMETER; | ||
} | ||
|
||
return response.getResponse().getResult().get(0); | ||
} | ||
|
||
} |
2 changes: 2 additions & 0 deletions
2
pothole-core/src/main/java/pothole_solution/core/global/config/AppConfig.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
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
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