-
Notifications
You must be signed in to change notification settings - Fork 1
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
[#3] 약국 및 병원 데이터 가져오기 #4
Conversation
JHwan96
commented
Aug 26, 2024
- 공공데이터인 약국 정보 서비스, 병원 정보 서비스 가져오기 [건강보험심사평가원]
- 의료기관별 상세 정보 [건강보험심사평가원]
- 데이터 내부 문제로 처리 방법을 다시 생각해볼 예정
- spring boot starter web 추가 - AppTest 내용 임시 삭제
- 컨트롤러 생성을 위해 더미데이터 추가
- 임시 확인을 위해 main문 추가 (차후 main문 삭제 후 component로 변경할 예정) - 값이 없는 경우는 null로 대체 - 서비스 키 제거 후 commit - 차후 코드 리팩토링 및 DrugstoreDto 반환하도록 변경할 예정
- 임시 확인을 위해 main문 추가 (차후 main문 삭제 후 component로 변경할 예정) - 값이 없는 경우는 null로 대체
- 특정 개수만큼 읽을 때, 전체 페이지 개수 반환하는 메서드 추가 - 예외 처리는 차후에 작업할 예정
- Application-secret.yml에 Api key 저장
@Component | ||
public class DrugstoreApi { | ||
@Autowired | ||
KeyInfo keyInfo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Autowired대신 Contructor injection을 사용해 주세요.
private final int rowSize = 1000; //한 페이지 결과 수 | ||
private String url; | ||
|
||
@PostConstruct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PostContruct말고 다른 방식으로 변수를 초기화 하면 좋을 것 같습니다.
public List<DrugstoreDto> getDrugstoreInfo(int pageNo) throws IOException, ParserConfigurationException, SAXException { | ||
List<DrugstoreDto> drugstoreDtoList = new ArrayList<>(); | ||
String realUrl = url + page + pageNo; | ||
System.out.println(keyInfo.getServerKey()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logger를 적용해주세요.
Node node = nodeList.item(i); | ||
if (node.getNodeType() == Node.ELEMENT_NODE) { | ||
Element element = (Element) node; | ||
DrugstoreDto drugstoreDto = DrugstoreDto.builder() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기는 빌더가 유리한 판단인가요?