박권수

feat. 병원 검색 api

......@@ -5,6 +5,7 @@ const Profile = require('../../models/profile');
const DoctorInfo = require('../../models/doctorInfo');
const Joi = require('joi');
const jwt = require('jsonwebtoken');
const axios = require('axios');
exports.register = async(ctx) => {
......@@ -66,6 +67,26 @@ exports.register = async(ctx) => {
};
exports.searchHospital = async ctx => {
const {
hospitalNm,
page,
} = ctx.query;
const url = 'http://apis.data.go.kr/B551182/hospInfoService1/getHospBasisList1';
let queryParams = '?' + encodeURIComponent('ServiceKey') + '=' + process.env.SERVICE_KEY;
queryParams += '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent(page);
queryParams += '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent(10);
queryParams += '&' + encodeURIComponent('yadmNm') + '=' + encodeURIComponent(hospitalNm);
const result = await axios.get(url + queryParams);
ctx.status = 200;
ctx.body = {
hospitalList : result.data.response.body.items.item,
};
};
exports.doctorRegister = async ctx => {
const {
userId,
......
......@@ -12,6 +12,14 @@ const auth = new Router()
auth.post('/register', authCtrl.register)
/**
* 병원 검색
* url : http://localhost:4000/api/auth/hospital
* request parameter : hospitalNm
* return : xml type data
*/
auth.get('/hospital', authCtrl.searchHospital);
/**
* 회원가입 (email type) : 의사 회원가입
* url : http://localhost:4000/api/auth/register/doctor
* request parameter : userId, password, passwordCheck, doctorInfo
......
......@@ -11,6 +11,7 @@ exports.updateMedicineInfo = async() => {
//queryUrl을 return하는 함수 : 한 페이지에 100개의 item씩 요청할 수 있다.
const getQueryURL = (i) => {
const url = 'http://apis.data.go.kr/1471000/DrbEasyDrugInfoService/getDrbEasyDrugList';
// eslint-disable-next-line no-undef
const queryParams = '?' + encodeURIComponent('ServiceKey') + '=' + process.env.SERVICE_KEY;
const pageNum = '&' + encodeURIComponent('pageNo') + '=' + encodeURIComponent(i);
const numOfItem = '&' + encodeURIComponent('numOfRows') + '=' + encodeURIComponent(100);
......@@ -24,6 +25,7 @@ const getItemsList = async(queryUrl) => {
let i = 1, getItem = null, items = null;
const result = [];
// eslint-disable-next-line no-constant-condition
while(true) {
getItem = await axios.get(queryUrl(i));
items = getItem.data.body.items;
......
module.exports = {
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended"
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaFeatures": {
"jsx": true
},
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"react",
"@typescript-eslint"
],
"rules": {
}
};
This diff could not be displayed because it is too large.