박권수

Merge branch 'server' into web

...@@ -512,45 +512,28 @@ exports.secession = async ctx => { ...@@ -512,45 +512,28 @@ exports.secession = async ctx => {
512 } 512 }
513 513
514 if(user.userTypeCd === 'NORMAL') { 514 if(user.userTypeCd === 'NORMAL') {
515 - const profile = await Profile.findOne({ userId });
516 -
517 //프로필 삭제 515 //프로필 삭제
518 - await profile.setUseYn('N'); 516 + await Profile.updateOne({ userId }, { useYn : 'N' });
519 - await profile.save();
520 517
521 //유저에 등록된 허브, 약병, 약병정보 전부 삭제 518 //유저에 등록된 허브, 약병, 약병정보 전부 삭제
522 const hubList = await Hub.find({ userId }); 519 const hubList = await Hub.find({ userId });
523 await Promise.all(hubList.map(async hub => { 520 await Promise.all(hubList.map(async hub => {
524 - const bottleList = await Bottle.find({ hubId : hub.hubId });
525 - await Promise.all(bottleList.map(async bottle => {
526 - const bottleMedicine = await BottleMedicine.findOne({ bottleId : bottle.bottleId });
527 - await bottleMedicine.setUseYn('N');
528 - await bottleMedicine.save();
529 - }));
530 -
531 await Bottle.deleteMany({ hubId : hub.hubId }); 521 await Bottle.deleteMany({ hubId : hub.hubId });
532 })); 522 }));
533 523
534 await Hub.deleteMany({ userId }); 524 await Hub.deleteMany({ userId });
535 525
536 -
537 //환자 정보 삭제 526 //환자 정보 삭제
538 - const patientInfoList = await PatientInfo.find({ patientId : userId, useYn : 'Y' }); 527 + await PatientInfo.updateMany({ patientId : userId, useYn : 'Y'}, { useYn : 'N' });
539 - await Promise.all(patientInfoList.map(async patientInfo => {
540 - await patientInfo.setUseYn('N');
541 - await patientInfo.save();
542 - }));
543 -
544 528
545 //유저 삭제 529 //유저 삭제
546 await user.setUseYn('N'); 530 await user.setUseYn('N');
547 await user.save(); 531 await user.save();
548 532
549 } else if (user.userTypeCd === 'DOCTOR') { 533 } else if (user.userTypeCd === 'DOCTOR') {
550 - const doctorInfo = await DoctorInfo.findOne({ doctorId : userId }); 534 + //의사 정보 및 환자 정보 삭제
551 - 535 + await DoctorInfo.updateOne({ doctorId : userId }, { useYn : 'WS' });
552 - await doctorInfo.setUseYn('WS'); 536 + await PatientInfo.updateMany({ doctorId : userId }, { useYn : 'WS' });
553 - await doctorInfo.save();
554 537
555 await user.setUseYn('WS'); 538 await user.setUseYn('WS');
556 await user.save(); 539 await user.save();
......
1 const User = require('../../models/user'); 1 const User = require('../../models/user');
2 const DoctorInfo = require('../../models/doctorInfo'); 2 const DoctorInfo = require('../../models/doctorInfo');
3 +const PatientInfo = require('../../models/patientInfo');
3 const jwt = require('jsonwebtoken'); 4 const jwt = require('jsonwebtoken');
4 const { viewDoctorLicense } = require('../../util/GoogleCloudStorage'); 5 const { viewDoctorLicense } = require('../../util/GoogleCloudStorage');
5 6
...@@ -314,18 +315,11 @@ exports.acceptDoctorRegReq = async ctx => { ...@@ -314,18 +315,11 @@ exports.acceptDoctorRegReq = async ctx => {
314 return; 315 return;
315 } 316 }
316 317
317 - 318 + await DoctorInfo.updateOne({ doctorId, useYn : 'W' }, { useYn : 'N' });
318 - const doctorInfo = await DoctorInfo.findOne({
319 - doctorId,
320 - useYn : 'W',
321 - });
322 319
323 await doctor.setUseYn('N'); 320 await doctor.setUseYn('N');
324 await doctor.save(); 321 await doctor.save();
325 322
326 - await doctorInfo.setUseYn('N');
327 - await doctorInfo.save();
328 -
329 ctx.status = 200; 323 ctx.status = 200;
330 324
331 } catch(e) { 325 } catch(e) {
...@@ -388,17 +382,12 @@ exports.acceptDoctorRegReq = async ctx => { ...@@ -388,17 +382,12 @@ exports.acceptDoctorRegReq = async ctx => {
388 } 382 }
389 383
390 384
391 - const doctorInfo = await DoctorInfo.findOne({ 385 + await DoctorInfo.updateOne({ doctorId, useYn : 'WS' }, { useYn : 'N' });
392 - doctorId, 386 + await PatientInfo.updateMany({ doctorId : userId, useYn : 'WS' }, { useYn : 'N' });
393 - useYn : 'WS',
394 - });
395 387
396 await doctor.setUseYn('N'); 388 await doctor.setUseYn('N');
397 await doctor.save(); 389 await doctor.save();
398 390
399 - await doctorInfo.setUseYn('N');
400 - await doctorInfo.save();
401 -
402 ctx.status = 200; 391 ctx.status = 200;
403 392
404 } catch(e) { 393 } catch(e) {
......
...@@ -168,7 +168,10 @@ exports.viewAllDoctorRegisterReq = async ctx => { ...@@ -168,7 +168,10 @@ exports.viewAllDoctorRegisterReq = async ctx => {
168 }) 168 })
169 169
170 const doctorReqList = await Promise.all(patientInfoList.map(async patientInfo => { 170 const doctorReqList = await Promise.all(patientInfoList.map(async patientInfo => {
171 - const doctor = await DoctorInfo.findOne({ doctorId : patientInfo.doctorId }); 171 + const doctor = await DoctorInfo.findOne({
172 + doctorId : patientInfo.doctorId,
173 + useYn : 'Y',
174 + });
172 return { 175 return {
173 patientId : patientInfo.patientId, 176 patientId : patientInfo.patientId,
174 doctorId : patientInfo.doctorId, 177 doctorId : patientInfo.doctorId,
......