Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2021-1-capstone-design1
/
RIT_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
박권수
2021-08-17 00:58:54 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
f555b3fb902b3fcc7f6873f6ad4130dc719a2b6f
f555b3fb
2 parents
db36a2be
41cea7f3
Merge branch 'server' into web
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
281 additions
and
0 deletions
server/src/api/manage/index.js
server/src/api/manage/manage.ctrl.js
server/src/api/manage/index.js
View file @
f555b3f
const
Router
=
require
(
'koa-router'
);
const
manageCtrl
=
require
(
'./manage.ctrl'
);
const
manage
=
new
Router
();
/**
* 의사 회원가입 요청을 한 회원들의 목록을 리턴
* request parameter : null
* url : http://localhost:4000/api/manage/doctor
* return : doctor request List
*/
manage
.
get
(
'/doctor'
,
manageCtrl
.
getDoctorRegReqList
);
/**
* 의사 회원가입 요청을 한 특정 회원의 상세정보 확인
* request parameter : doctor Id
* url : http://localhost:4000/api/manage/doctor/:doctorId
* return : doctor Info
*/
manage
.
get
(
'/doctor/:doctorId'
,
manageCtrl
.
getDoctorRegReqDetail
);
/**
* 의사 요청을 한 회원을 수락한다
* request parameter : doctor Id
* url : http://localhost:4000/api/manage/doctor/accept
* return : null
*/
manage
.
post
(
'/doctor/accept'
,
manageCtrl
.
acceptDoctorRegReq
);
/**
* 의사 요청을 한 회원을 거절한다.
* request parameter : doctor Id
* url : http://localhost:4000/api/manange/doctor/reject
* return : null
*/
manage
.
post
(
'/doctor/reject'
,
manageCtrl
.
rejectDoctorRegReq
);
module
.
exports
=
manage
;
\ No newline at end of file
...
...
server/src/api/manage/manage.ctrl.js
0 → 100644
View file @
f555b3f
const
User
=
require
(
'../../models/user'
);
const
DoctorInfo
=
require
(
'../../models/doctorInfo'
);
const
Profile
=
require
(
'../../models/profile'
);
/**
* 의사 회원가입을 요청한 회원 리스트를 확인한다.
* http methods : get
* @param {*} ctx
* @returns
*/
exports
.
getDoctorRegReqList
=
async
ctx
=>
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
// eslint-disable-next-line no-undef
const
{
userId
}
=
jwt
.
verify
(
token
,
process
.
env
.
JWT_SECRET
);
const
user
=
await
User
.
findByUserId
(
userId
);
if
(
!
user
||
user
.
userTypeCd
!==
'MANAGER'
||
user
.
useYn
!==
'Y'
)
{
ctx
.
status
=
403
;
return
;
}
try
{
const
doctorRegReqList
=
await
User
.
find
({
userTypeCd
:
'DOCTOR'
,
useYn
:
'W'
,
});
ctx
.
status
=
200
;
ctx
.
body
=
doctorRegReqList
;
}
catch
(
e
)
{
ctx
.
status
=
500
;
ctx
.
body
=
{
error
:
'알 수 없는 에러가 발생했습니다.'
,
};
console
.
log
(
e
);
}
};
/**
* 의사 신청을 한 회원을 상세 조회한다.
* http methods : get
* @param {*} ctx
* @returns
*/
exports
.
getDoctorRegReqDetail
=
async
ctx
=>
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
// eslint-disable-next-line no-undef
const
{
userId
}
=
jwt
.
verify
(
token
,
process
.
env
.
JWT_SECRET
);
const
user
=
await
User
.
findByUserId
(
userId
);
if
(
!
user
||
user
.
userTypeCd
!==
'MANAGER'
||
user
.
useYn
!==
'Y'
)
{
ctx
.
status
=
403
;
return
;
}
try
{
const
{
doctorId
}
=
ctx
.
params
;
const
doctor
=
await
User
.
findOne
({
userId
:
doctorId
});
if
(
!
doctor
)
{
ctx
.
status
=
404
;
ctx
.
body
=
{
error
:
'존재하지 않는 회원입니다.'
,
};
return
;
}
else
if
(
doctor
.
userTypeCd
!==
'DOCTOR'
)
{
ctx
.
status
=
400
;
ctx
.
body
=
{
error
:
'의사로 가입된 회원이 아닙니다.'
,
};
return
;
}
else
if
(
doctor
.
useYn
!==
'W'
)
{
ctx
.
status
=
400
;
ctx
.
body
=
{
error
:
'이미 의사로 가입된 회원입니다.'
,
};
return
;
}
const
doctorInfo
=
await
DoctorInfo
.
findOne
({
doctorId
});
if
(
!
doctorInfo
)
{
ctx
.
status
=
404
;
ctx
.
body
=
{
error
:
'의사 자격이 증명되지 않은 회원입니다.'
,
};
return
;
}
else
if
(
doctorInfo
.
useYn
===
'Y'
)
{
ctx
.
status
=
400
;
ctx
.
body
=
{
error
:
'이미 의사 인증이 완료된 회원입니다.'
};
1
return
;
}
else
if
(
doctorInfo
.
useYn
===
'N'
)
{
ctx
.
status
=
400
;
ctx
.
body
=
{
error
:
'의사 인증이 거절된 회원입니다.'
,
};
return
;
}
ctx
.
status
=
200
;
ctx
.
body
=
doctorInfo
;
}
catch
(
e
)
{
ctx
.
status
=
500
;
ctx
.
body
=
{
error
:
'알 수 없는 에러가 발생했습니다.'
,
};
console
.
log
(
e
);
}
};
/**
* 의사 요청이 온 회원을 수락한다.
* http methods : post
* @param {*} ctx
* @returns
*/
exports
.
acceptDoctorRegReq
=
async
ctx
=>
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
// eslint-disable-next-line no-undef
const
{
userId
}
=
jwt
.
verify
(
token
,
process
.
env
.
JWT_SECRET
);
const
user
=
await
User
.
findByUserId
(
userId
);
if
(
!
user
||
user
.
userTypeCd
!==
'MANAGER'
||
user
.
useYn
!==
'Y'
)
{
ctx
.
status
=
403
;
return
;
}
try
{
const
{
doctorId
}
=
ctx
.
request
.
body
;
const
doctor
=
await
User
.
findOne
({
userId
:
doctorId
});
if
(
!
doctor
)
{
ctx
.
status
=
404
;
ctx
.
body
=
{
error
:
'존재하지 않는 회원입니다.'
,
};
return
;
}
else
if
(
doctor
.
useYn
===
'N'
)
{
ctx
.
status
=
400
;
ctx
.
body
=
{
error
:
'탈퇴된 회원입니다.'
,
};
return
;
}
else
if
(
doctor
.
useYn
===
'Y'
)
{
ctx
.
status
=
400
;
ctx
.
body
=
{
error
:
'이미 가입이 완료된 의사입니다.'
,
};
return
;
}
else
if
(
doctor
.
userTypeCd
!==
'DOCTOR'
)
{
ctx
.
status
=
400
;
ctx
.
body
=
{
error
:
'의사로 가입된 회원이 아닙니다.'
,
};
return
;
}
doctor
.
setUseYn
(
'Y'
);
doctor
.
save
();
ctx
.
status
=
200
;
}
catch
(
e
)
{
ctx
.
status
=
500
;
ctx
.
body
=
{
error
:
'알 수 없는 에러가 발생했습니다.'
,
};
console
.
log
(
e
);
}
};
/**
* 의사 요청이 온 회원을 거절한다.
* http methods : post
* @param {*} ctx
* @returns
*/
exports
.
rejectDoctorRegReq
=
async
ctx
=>
{
const
token
=
ctx
.
req
.
headers
.
authorization
;
if
(
!
token
||
!
token
.
length
)
{
ctx
.
status
=
401
;
return
;
}
// eslint-disable-next-line no-undef
const
{
userId
}
=
jwt
.
verify
(
token
,
process
.
env
.
JWT_SECRET
);
const
user
=
await
User
.
findByUserId
(
userId
);
if
(
!
user
||
user
.
userTypeCd
!==
'MANAGER'
||
user
.
useYn
!==
'Y'
)
{
ctx
.
status
=
403
;
return
;
}
try
{
const
{
doctorId
}
=
ctx
.
request
.
body
;
const
doctor
=
await
User
.
findOne
({
userId
:
doctorId
});
if
(
!
doctor
)
{
ctx
.
status
=
404
;
ctx
.
body
=
{
error
:
'존재하지 않는 회원입니다.'
,
};
return
;
}
else
if
(
doctor
.
useYn
===
'N'
)
{
ctx
.
status
=
400
;
ctx
.
body
=
{
error
:
'탈퇴된 회원입니다.'
,
};
return
;
}
else
if
(
doctor
.
useYn
===
'Y'
)
{
ctx
.
status
=
400
;
ctx
.
body
=
{
error
:
'이미 가입이 완료된 의사입니다.'
,
};
return
;
}
else
if
(
doctor
.
userTypeCd
!==
'DOCTOR'
)
{
ctx
.
status
=
400
;
ctx
.
body
=
{
error
:
'의사로 가입된 회원이 아닙니다.'
,
};
return
;
}
doctor
.
setUseYn
(
'N'
);
doctor
.
save
();
ctx
.
status
=
200
;
}
catch
(
e
)
{
ctx
.
status
=
500
;
ctx
.
body
=
{
error
:
'알 수 없는 에러가 발생했습니다.'
,
};
console
.
log
(
e
);
}
};
Please
register
or
login
to post a comment