Showing
2 changed files
with
29 additions
and
4 deletions
... | @@ -155,7 +155,7 @@ exports.acceptDoctorRegReq = async ctx => { | ... | @@ -155,7 +155,7 @@ exports.acceptDoctorRegReq = async ctx => { |
155 | } | 155 | } |
156 | 156 | ||
157 | try { | 157 | try { |
158 | - const { doctorId } = ctx.request.body; | 158 | + const { doctorId, validateDoctorLicense } = ctx.request.body; |
159 | const doctor = await User.findOne({ userId : doctorId }); | 159 | const doctor = await User.findOne({ userId : doctorId }); |
160 | if(!doctor) { | 160 | if(!doctor) { |
161 | ctx.status = 404; | 161 | ctx.status = 404; |
... | @@ -181,8 +181,26 @@ exports.acceptDoctorRegReq = async ctx => { | ... | @@ -181,8 +181,26 @@ exports.acceptDoctorRegReq = async ctx => { |
181 | error : '의사로 가입된 회원이 아닙니다.', | 181 | error : '의사로 가입된 회원이 아닙니다.', |
182 | }; | 182 | }; |
183 | return; | 183 | return; |
184 | + } else if(!validateDoctorLicense) { | ||
185 | + ctx.status = 400; | ||
186 | + ctx.body = { | ||
187 | + error : '유효한 자격 번호가 아닙니다.', | ||
188 | + }; | ||
189 | + return; | ||
184 | } | 190 | } |
185 | 191 | ||
192 | + const existDoctorInfo = await DoctorInfo.findOne({ | ||
193 | + 'info.validateDoctorLicense' : validateDoctorLicense | ||
194 | + }); | ||
195 | + if(existDoctorInfo) { | ||
196 | + ctx.status = 403; | ||
197 | + ctx.body = { | ||
198 | + error : '중복된 자격번호입니다.', | ||
199 | + }; | ||
200 | + return; | ||
201 | + } | ||
202 | + | ||
203 | + | ||
186 | const doctorInfo = await DoctorInfo.findOne({ | 204 | const doctorInfo = await DoctorInfo.findOne({ |
187 | doctorId, | 205 | doctorId, |
188 | useYn : 'W', | 206 | useYn : 'W', |
... | @@ -190,7 +208,9 @@ exports.acceptDoctorRegReq = async ctx => { | ... | @@ -190,7 +208,9 @@ exports.acceptDoctorRegReq = async ctx => { |
190 | 208 | ||
191 | doctor.setUseYn('Y'); | 209 | doctor.setUseYn('Y'); |
192 | doctor.save(); | 210 | doctor.save(); |
211 | + | ||
193 | doctorInfo.setUseYn('Y'); | 212 | doctorInfo.setUseYn('Y'); |
213 | + doctorInfo.setValidateDoctorLicense(validateDoctorLicense); | ||
194 | doctorInfo.save(); | 214 | doctorInfo.save(); |
195 | 215 | ||
196 | ctx.status = 200; | 216 | ctx.status = 200; |
... | @@ -296,12 +316,12 @@ exports.validateDoctorLicense = async ctx => { | ... | @@ -296,12 +316,12 @@ exports.validateDoctorLicense = async ctx => { |
296 | return; | 316 | return; |
297 | } | 317 | } |
298 | 318 | ||
299 | - const { doctorLicense } = ctx.request.body; | 319 | + const { validateDoctorLicense } = ctx.request.body; |
300 | - const doctorInfo = await DoctorInfo.find({ 'info.doctorLicense' : doctorLicense }); | 320 | + const doctorInfo = await DoctorInfo.findOne({ 'info.validateDoctorLicense' : validateDoctorLicense }); |
301 | 321 | ||
302 | ctx.status = 200; | 322 | ctx.status = 200; |
303 | ctx.body = { | 323 | ctx.body = { |
304 | - result : doctorInfo.length > 1 ? false : true, | 324 | + result : doctorInfo ? false : true, |
305 | }; | 325 | }; |
306 | 326 | ||
307 | }; | 327 | }; | ... | ... |
... | @@ -6,6 +6,7 @@ const DoctorInfoSchema = new Schema({ | ... | @@ -6,6 +6,7 @@ const DoctorInfoSchema = new Schema({ |
6 | doctorId : { type : String, required : true, }, | 6 | doctorId : { type : String, required : true, }, |
7 | info : { | 7 | info : { |
8 | doctorLicense : { type : String, required : true, }, | 8 | doctorLicense : { type : String, required : true, }, |
9 | + validateDoctorLicense : { type : String, default : null }, | ||
9 | hospitalNm : { type : String, default : null, }, | 10 | hospitalNm : { type : String, default : null, }, |
10 | hospitalAddr : { type : String, default : null, }, | 11 | hospitalAddr : { type : String, default : null, }, |
11 | contact : { type : String, required : true, }, | 12 | contact : { type : String, required : true, }, |
... | @@ -23,5 +24,9 @@ DoctorInfoSchema.methods.setUseYn = function(useYn) { | ... | @@ -23,5 +24,9 @@ DoctorInfoSchema.methods.setUseYn = function(useYn) { |
23 | this.useYn = useYn; | 24 | this.useYn = useYn; |
24 | }; | 25 | }; |
25 | 26 | ||
27 | +DoctorInfoSchema.methods.setValidateDoctorLicense = function(validateDoctorLicense) { | ||
28 | + this.info.validateDoctorLicense = validateDoctorLicense; | ||
29 | +}; | ||
30 | + | ||
26 | 31 | ||
27 | module.exports = mongoose.model('DoctorInfo', DoctorInfoSchema); | 32 | module.exports = mongoose.model('DoctorInfo', DoctorInfoSchema); | ... | ... |
-
Please register or login to post a comment