Showing
2 changed files
with
137 additions
and
6 deletions
| ... | @@ -12,6 +12,14 @@ const manage = new Router(); | ... | @@ -12,6 +12,14 @@ const manage = new Router(); |
| 12 | manage.get('/doctor', manageCtrl.getDoctorRegReqList); | 12 | manage.get('/doctor', manageCtrl.getDoctorRegReqList); |
| 13 | 13 | ||
| 14 | /** | 14 | /** |
| 15 | + * 의사 회원탈퇴 요청을 한 회원들의 목록을 리턴 | ||
| 16 | + * request parameter : null | ||
| 17 | + * url : http://localhost:4000/api/manage/doctor/sec | ||
| 18 | + * return : doctor request List | ||
| 19 | + */ | ||
| 20 | + manage.get('/doctor/sec', manageCtrl.getDoctorSecReqList); | ||
| 21 | + | ||
| 22 | +/** | ||
| 15 | * 의사 회원가입 요청을 한 특정 회원의 상세정보 확인 | 23 | * 의사 회원가입 요청을 한 특정 회원의 상세정보 확인 |
| 16 | * request parameter : doctor Id | 24 | * request parameter : doctor Id |
| 17 | * url : http://localhost:4000/api/manage/doctor/:doctorId | 25 | * url : http://localhost:4000/api/manage/doctor/:doctorId |
| ... | @@ -25,7 +33,7 @@ manage.get('/doctor/:doctorId', manageCtrl.getDoctorRegReqDetail); | ... | @@ -25,7 +33,7 @@ manage.get('/doctor/:doctorId', manageCtrl.getDoctorRegReqDetail); |
| 25 | * url : http://localhost:4000/api/manage/doctor/accept | 33 | * url : http://localhost:4000/api/manage/doctor/accept |
| 26 | * return : null | 34 | * return : null |
| 27 | */ | 35 | */ |
| 28 | -manage.post('/doctor/accept', manageCtrl.acceptDoctorRegReq); | 36 | +manage.patch('/doctor/accept', manageCtrl.acceptDoctorRegReq); |
| 29 | 37 | ||
| 30 | /** | 38 | /** |
| 31 | * 의사 요청을 한 회원을 거절한다. | 39 | * 의사 요청을 한 회원을 거절한다. |
| ... | @@ -33,7 +41,15 @@ manage.post('/doctor/accept', manageCtrl.acceptDoctorRegReq); | ... | @@ -33,7 +41,15 @@ manage.post('/doctor/accept', manageCtrl.acceptDoctorRegReq); |
| 33 | * url : http://localhost:4000/api/manange/doctor/reject | 41 | * url : http://localhost:4000/api/manange/doctor/reject |
| 34 | * return : null | 42 | * return : null |
| 35 | */ | 43 | */ |
| 36 | -manage.post('/doctor/reject', manageCtrl.rejectDoctorRegReq); | 44 | +manage.patch('/doctor/reject', manageCtrl.rejectDoctorRegReq); |
| 45 | + | ||
| 46 | +/** | ||
| 47 | + * 의사 탈퇴 요청을 수락한다. | ||
| 48 | + * request parameter : doctor Id | ||
| 49 | + * url : http://localhost:4000/api/manange/doctor/secession | ||
| 50 | + * return : null | ||
| 51 | + */ | ||
| 52 | + manage.patch('/doctor/secession', manageCtrl.acceptDoctorSecReq); | ||
| 37 | 53 | ||
| 38 | /** | 54 | /** |
| 39 | * 의사 요청을 한 회원의 자격 번호가 유효한지 검증한다 | 55 | * 의사 요청을 한 회원의 자격 번호가 유효한지 검증한다 | ... | ... |
| ... | @@ -26,13 +26,53 @@ exports.getDoctorRegReqList = async ctx => { | ... | @@ -26,13 +26,53 @@ exports.getDoctorRegReqList = async ctx => { |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | try { | 28 | try { |
| 29 | - const doctorRegReqList = await DoctorInfo.find({ | 29 | + const doctorList = await DoctorInfo.find({ |
| 30 | useYn : 'W', | 30 | useYn : 'W', |
| 31 | }); | 31 | }); |
| 32 | 32 | ||
| 33 | ctx.status = 200; | 33 | ctx.status = 200; |
| 34 | ctx.body = { | 34 | ctx.body = { |
| 35 | - doctorRegReqList | 35 | + doctorList |
| 36 | + }; | ||
| 37 | + | ||
| 38 | + } catch(e) { | ||
| 39 | + ctx.status = 500; | ||
| 40 | + ctx.body = { | ||
| 41 | + error : '알 수 없는 에러가 발생했습니다.', | ||
| 42 | + }; | ||
| 43 | + console.log(e); | ||
| 44 | + } | ||
| 45 | +}; | ||
| 46 | + | ||
| 47 | +/** | ||
| 48 | + * 의사 회원탈퇴를 요청한 회원 리스트를 확인한다. | ||
| 49 | + * http methods : get | ||
| 50 | + * @param {*} ctx | ||
| 51 | + * @returns | ||
| 52 | + */ | ||
| 53 | + exports.getDoctorSecReqList = async ctx => { | ||
| 54 | + const token = ctx.req.headers.authorization; | ||
| 55 | + if (!token || !token.length) { | ||
| 56 | + ctx.status = 401; | ||
| 57 | + return; | ||
| 58 | + } | ||
| 59 | + | ||
| 60 | + // eslint-disable-next-line no-undef | ||
| 61 | + const { userId } = jwt.verify(token, process.env.JWT_SECRET); | ||
| 62 | + const user = await User.findByUserId(userId); | ||
| 63 | + if(!user || user.userTypeCd !== 'MANAGER' || user.useYn !== 'Y') { | ||
| 64 | + ctx.status = 403; | ||
| 65 | + return; | ||
| 66 | + } | ||
| 67 | + | ||
| 68 | + try { | ||
| 69 | + const doctorList = await DoctorInfo.find({ | ||
| 70 | + useYn : 'WS', | ||
| 71 | + }); | ||
| 72 | + | ||
| 73 | + ctx.status = 200; | ||
| 74 | + ctx.body = { | ||
| 75 | + doctorList | ||
| 36 | }; | 76 | }; |
| 37 | 77 | ||
| 38 | } catch(e) { | 78 | } catch(e) { |
| ... | @@ -135,7 +175,7 @@ exports.getDoctorRegReqDetail = async ctx => { | ... | @@ -135,7 +175,7 @@ exports.getDoctorRegReqDetail = async ctx => { |
| 135 | 175 | ||
| 136 | /** | 176 | /** |
| 137 | * 의사 요청이 온 회원을 수락한다. | 177 | * 의사 요청이 온 회원을 수락한다. |
| 138 | - * http methods : post | 178 | + * http methods : patch |
| 139 | * @param {*} ctx | 179 | * @param {*} ctx |
| 140 | * @returns | 180 | * @returns |
| 141 | */ | 181 | */ |
| ... | @@ -226,7 +266,7 @@ exports.acceptDoctorRegReq = async ctx => { | ... | @@ -226,7 +266,7 @@ exports.acceptDoctorRegReq = async ctx => { |
| 226 | 266 | ||
| 227 | /** | 267 | /** |
| 228 | * 의사 요청이 온 회원을 거절한다. | 268 | * 의사 요청이 온 회원을 거절한다. |
| 229 | - * http methods : post | 269 | + * http methods : patch |
| 230 | * @param {*} ctx | 270 | * @param {*} ctx |
| 231 | * @returns | 271 | * @returns |
| 232 | */ | 272 | */ |
| ... | @@ -282,6 +322,80 @@ exports.acceptDoctorRegReq = async ctx => { | ... | @@ -282,6 +322,80 @@ exports.acceptDoctorRegReq = async ctx => { |
| 282 | 322 | ||
| 283 | await doctor.setUseYn('N'); | 323 | await doctor.setUseYn('N'); |
| 284 | await doctor.save(); | 324 | await doctor.save(); |
| 325 | + | ||
| 326 | + await doctorInfo.setUseYn('N'); | ||
| 327 | + await doctorInfo.save(); | ||
| 328 | + | ||
| 329 | + ctx.status = 200; | ||
| 330 | + | ||
| 331 | + } catch(e) { | ||
| 332 | + ctx.status = 500; | ||
| 333 | + ctx.body = { | ||
| 334 | + error : '알 수 없는 에러가 발생했습니다.', | ||
| 335 | + }; | ||
| 336 | + console.log(e); | ||
| 337 | + } | ||
| 338 | +}; | ||
| 339 | + | ||
| 340 | +/** | ||
| 341 | + * 의사 회원탈퇴 요청을 수락한다. | ||
| 342 | + * http methods : patch | ||
| 343 | + * @param {*} ctx | ||
| 344 | + * @returns | ||
| 345 | + */ | ||
| 346 | + exports.acceptDoctorSecReq = async ctx => { | ||
| 347 | + const token = ctx.req.headers.authorization; | ||
| 348 | + if (!token || !token.length) { | ||
| 349 | + ctx.status = 401; | ||
| 350 | + return; | ||
| 351 | + } | ||
| 352 | + | ||
| 353 | + // eslint-disable-next-line no-undef | ||
| 354 | + const { userId } = jwt.verify(token, process.env.JWT_SECRET); | ||
| 355 | + const user = await User.findByUserId(userId); | ||
| 356 | + if(!user || user.userTypeCd !== 'MANAGER' || user.useYn !== 'Y') { | ||
| 357 | + ctx.status = 403; | ||
| 358 | + return; | ||
| 359 | + } | ||
| 360 | + | ||
| 361 | + try { | ||
| 362 | + const { doctorId } = ctx.request.body; | ||
| 363 | + const doctor = await User.findOne({ userId : doctorId }); | ||
| 364 | + if(!doctor) { | ||
| 365 | + ctx.status = 404; | ||
| 366 | + ctx.body = { | ||
| 367 | + error : '존재하지 않는 회원입니다.', | ||
| 368 | + }; | ||
| 369 | + return; | ||
| 370 | + } else if(doctor.useYn === 'N') { | ||
| 371 | + ctx.status = 400; | ||
| 372 | + ctx.body = { | ||
| 373 | + error : '탈퇴된 회원입니다.', | ||
| 374 | + }; | ||
| 375 | + return; | ||
| 376 | + } else if(doctor.useYn === 'Y') { | ||
| 377 | + ctx.status = 400; | ||
| 378 | + ctx.body = { | ||
| 379 | + error : '이미 가입이 완료된 의사입니다.', | ||
| 380 | + }; | ||
| 381 | + return; | ||
| 382 | + } else if(doctor.userTypeCd !== 'DOCTOR') { | ||
| 383 | + ctx.status = 400; | ||
| 384 | + ctx.body = { | ||
| 385 | + error : '의사로 가입된 회원이 아닙니다.', | ||
| 386 | + }; | ||
| 387 | + return; | ||
| 388 | + } | ||
| 389 | + | ||
| 390 | + | ||
| 391 | + const doctorInfo = await DoctorInfo.findOne({ | ||
| 392 | + doctorId, | ||
| 393 | + useYn : 'WS', | ||
| 394 | + }); | ||
| 395 | + | ||
| 396 | + await doctor.setUseYn('N'); | ||
| 397 | + await doctor.save(); | ||
| 398 | + | ||
| 285 | await doctorInfo.setUseYn('N'); | 399 | await doctorInfo.setUseYn('N'); |
| 286 | await doctorInfo.save(); | 400 | await doctorInfo.save(); |
| 287 | 401 | ||
| ... | @@ -296,6 +410,7 @@ exports.acceptDoctorRegReq = async ctx => { | ... | @@ -296,6 +410,7 @@ exports.acceptDoctorRegReq = async ctx => { |
| 296 | } | 410 | } |
| 297 | }; | 411 | }; |
| 298 | 412 | ||
| 413 | + | ||
| 299 | /** | 414 | /** |
| 300 | * 회원가입을 요청한 의사의 유효한 자격 번호인지를 검증한다. | 415 | * 회원가입을 요청한 의사의 유효한 자격 번호인지를 검증한다. |
| 301 | * @param {*} ctx | 416 | * @param {*} ctx | ... | ... |
-
Please register or login to post a comment