-
Notifications
You must be signed in to change notification settings - Fork 1
Feign client 이용하여 tour API 호출 #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pingu9
wants to merge
6
commits into
main
Choose a base branch
from
feat-dj-tour-API-job
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
6e9ac7e
chore: Spring cloud, batch, feign 세팅
227b245
chore: datasource 설정 추가
7844ec4
feat: feign client 이용하여 tour API 호출 추가(임시)
0b50aab
Merge branch 'main' into feat-dj-tour-API-job
60c07e8
feat: feign client에 Response converter 적용
ec37ae9
feat: feign call에 config 적용
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
14 changes: 14 additions & 0 deletions
14
src/main/java/com/catcher/batch/external/TourApiServiceExternalCallService.java
This file contains hidden or 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,14 @@ | ||
package com.catcher.batch.external; | ||
|
||
import com.catcher.batch.external.vo.request.TourApiRequest; | ||
import com.catcher.batch.external.vo.response.TourApiResponse; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.cloud.openfeign.SpringQueryMap; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
|
||
@FeignClient(name = "TOUR-API-SERVICE", url = "http://apis.data.go.kr/${your_app_key}/KorService1") | ||
public interface TourApiServiceExternalCallService { | ||
|
||
@GetMapping("/searchFestival1") | ||
TourApiResponse callTourList(@SpringQueryMap TourApiRequest request); | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/com/catcher/batch/external/vo/request/TourApiRequest.java
This file contains hidden or 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,27 @@ | ||
package com.catcher.batch.external.vo.request; | ||
|
||
import lombok.Getter; | ||
|
||
/* TODO: 하드코딩된 값 바꾸기 */ | ||
|
||
@Getter | ||
public class TourApiRequest { | ||
|
||
private Integer numOfRows = 100; | ||
|
||
private Integer pageNo = 1; | ||
|
||
private String MobileOS = "ETC"; | ||
|
||
private String MobileApp = "AppTest"; | ||
|
||
private String _type = "json"; | ||
|
||
private String listYN = "Y"; | ||
|
||
private String arrange = "A"; | ||
|
||
private String eventStartDate = "20230901"; | ||
|
||
private String serviceKey = "your_service_key"; | ||
} |
66 changes: 66 additions & 0 deletions
66
src/main/java/com/catcher/batch/external/vo/response/TourApiResponse.java
This file contains hidden or 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,66 @@ | ||
package com.catcher.batch.external.vo.response; | ||
|
||
import lombok.Getter; | ||
|
||
import java.util.List; | ||
|
||
@Getter | ||
public class TourApiResponse { | ||
|
||
private InnerTourAPiResponse response; | ||
|
||
@Getter | ||
public static class InnerTourAPiResponse { | ||
|
||
private TourApiHeader header; | ||
|
||
private TourApiBody body; | ||
} | ||
|
||
@Getter | ||
public static class TourApiHeader { | ||
private String resultCode; | ||
private String resultMsg; | ||
} | ||
|
||
@Getter | ||
public static class TourApiBody { | ||
|
||
private TourApiItems items; | ||
private Integer numOfRows; | ||
private Integer pageNo; | ||
private Integer totalCount; | ||
} | ||
|
||
@Getter | ||
public static class TourApiItems { | ||
private List<TourApiItem> item; | ||
} | ||
|
||
/* TODO: JsonProperty 어노테이션 이용하여 적당한 변수명으로 바꾸기 */ | ||
@Getter | ||
public static class TourApiItem { | ||
private String addr1; | ||
private String addr2; | ||
private String booktour; | ||
private String cat1; | ||
private String cat2; | ||
private String cat3; | ||
private String contentid; | ||
private String contenttypeid; | ||
private String createdtime; | ||
private String eventstartdate; | ||
private String eventenddate; | ||
private String firstimage; | ||
private String firstimage2; | ||
private String cpyrhtDivCd; | ||
private String mapx; | ||
private String mapy; | ||
private String mlevel; | ||
private String modifiedtime; | ||
private String areacode; | ||
private String sigungucode; | ||
private String tel; | ||
private String title; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/catcher/batch/job/config/CommonJobConfig.java
This file contains hidden or 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,10 @@ | ||
package com.catcher.batch.job.config; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.batch.core.launch.JobLauncher; | ||
|
||
@RequiredArgsConstructor | ||
public class CommonJobConfig { | ||
|
||
protected final JobLauncher jobLauncher; | ||
} |
22 changes: 22 additions & 0 deletions
22
src/main/java/com/catcher/batch/job/config/TourApiJob.java
This file contains hidden or 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 com.catcher.batch.job.config; | ||
|
||
import com.catcher.batch.external.TourApiServiceExternalCallService; | ||
import com.catcher.batch.external.vo.request.TourApiRequest; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.scheduling.annotation.Scheduled; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@RequiredArgsConstructor | ||
public class TourApiJob { | ||
|
||
private final TourApiServiceExternalCallService tourApiServiceExternalCallService; | ||
|
||
/* TODO: Spring batch 이용하도록 변경? */ | ||
@Scheduled(fixedDelay = 1000000) //TODO: 시간대 정해서 하루에 1번으로 변경 | ||
public void tourApiJob() { | ||
|
||
final var response = tourApiServiceExternalCallService.callTourList(new TourApiRequest()); | ||
} | ||
|
||
} |
This file contains hidden or 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,27 @@ | ||
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver | ||
|
||
## spring datasource | ||
spring.datasource.url=${DATASOURCE_URL} | ||
spring.datasource.username=${DATASOURCE_USERNAME} | ||
spring.datasource.password=${DATASOURCE_PASSWORD} | ||
|
||
|
||
## ssh | ||
ssh.host=${SSH_HOST} | ||
ssh.port=${SSH_PORT} | ||
ssh.username=${SSH_USERNAME} | ||
ssh.password=${SSH_PASSWORD} | ||
ssh.local-port=${SSH_LOCAL_PORT} | ||
ssh.datasource.origin=${SSH_DATASOURCE_ORIGIN} | ||
|
||
#update the schema with the given values. | ||
spring.jpa.hibernate.ddl-auto=update | ||
#To beautify or pretty print the SQL | ||
spring.jpa.properties.hibernate.format_sql=true | ||
#show sql | ||
spring.jpa.properties.hibernate.show-sql=true | ||
#show parameter binding | ||
logging.level.org.hibernate.type.descriptor.sql=DEBUG | ||
|
||
logging.level.org.hibernate.SQL=DEBUG | ||
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MariaDBDialect |
This file contains hidden or 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,27 @@ | ||
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver | ||
|
||
## spring datasource | ||
spring.datasource.url=${DATASOURCE_URL} | ||
spring.datasource.username=${DATASOURCE_USERNAME} | ||
spring.datasource.password=${DATASOURCE_PASSWORD} | ||
|
||
|
||
## ssh | ||
ssh.host=${SSH_HOST} | ||
ssh.port=${SSH_PORT} | ||
ssh.username=${SSH_USERNAME} | ||
ssh.password=${SSH_PASSWORD} | ||
ssh.local-port=${SSH_LOCAL_PORT} | ||
ssh.datasource.origin=${SSH_DATASOURCE_ORIGIN} | ||
|
||
#update the schema with the given values. | ||
spring.jpa.hibernate.ddl-auto=update | ||
#To beautify or pretty print the SQL | ||
spring.jpa.properties.hibernate.format_sql=true | ||
#show sql | ||
spring.jpa.properties.hibernate.show-sql=true | ||
#show parameter binding | ||
logging.level.org.hibernate.type.descriptor.sql=DEBUG | ||
|
||
logging.level.org.hibernate.SQL=DEBUG | ||
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MariaDBDialect |
This file contains hidden or 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,27 @@ | ||
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver | ||
|
||
## spring datasource | ||
spring.datasource.url=${DATASOURCE_URL} | ||
spring.datasource.username=${DATASOURCE_USERNAME} | ||
spring.datasource.password=${DATASOURCE_PASSWORD} | ||
|
||
|
||
## ssh | ||
ssh.host=${SSH_HOST} | ||
ssh.port=${SSH_PORT} | ||
ssh.username=${SSH_USERNAME} | ||
ssh.password=${SSH_PASSWORD} | ||
ssh.local-port=${SSH_LOCAL_PORT} | ||
ssh.datasource.origin=${SSH_DATASOURCE_ORIGIN} | ||
|
||
#update the schema with the given values. | ||
spring.jpa.hibernate.ddl-auto=update | ||
#To beautify or pretty print the SQL | ||
spring.jpa.properties.hibernate.format_sql=true | ||
#show sql | ||
spring.jpa.properties.hibernate.show-sql=true | ||
#show parameter binding | ||
logging.level.org.hibernate.type.descriptor.sql=DEBUG | ||
|
||
logging.level.org.hibernate.SQL=DEBUG | ||
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MariaDBDialect |
This file contains hidden or 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 |
---|---|---|
@@ -1 +1,27 @@ | ||
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver | ||
|
||
## spring datasource | ||
spring.datasource.url=${DATASOURCE_URL} | ||
spring.datasource.username=${DATASOURCE_USERNAME} | ||
spring.datasource.password=${DATASOURCE_PASSWORD} | ||
|
||
|
||
## ssh | ||
ssh.host=${SSH_HOST} | ||
ssh.port=${SSH_PORT} | ||
ssh.username=${SSH_USERNAME} | ||
ssh.password=${SSH_PASSWORD} | ||
ssh.local-port=${SSH_LOCAL_PORT} | ||
ssh.datasource.origin=${SSH_DATASOURCE_ORIGIN} | ||
|
||
#update the schema with the given values. | ||
spring.jpa.hibernate.ddl-auto=update | ||
#To beautify or pretty print the SQL | ||
spring.jpa.properties.hibernate.format_sql=true | ||
#show sql | ||
spring.jpa.properties.hibernate.show-sql=true | ||
#show parameter binding | ||
logging.level.org.hibernate.type.descriptor.sql=DEBUG | ||
|
||
logging.level.org.hibernate.SQL=DEBUG | ||
spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MariaDBDialect |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.