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-10-11 12:40:38 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
8cc448efd117218476bcaf8b9c5ead958068e7a2
8cc448ef
1 parent
dafee180
feat. 탈퇴요청 관리 api 제작
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
137 additions
and
6 deletions
server/src/api/manage/index.js
server/src/api/manage/manage.ctrl.js
server/src/api/manage/index.js
View file @
8cc448e
...
...
@@ -12,6 +12,14 @@ const manage = new Router();
manage
.
get
(
'/doctor'
,
manageCtrl
.
getDoctorRegReqList
);
/**
* 의사 회원탈퇴 요청을 한 회원들의 목록을 리턴
* request parameter : null
* url : http://localhost:4000/api/manage/doctor/sec
* return : doctor request List
*/
manage
.
get
(
'/doctor/sec'
,
manageCtrl
.
getDoctorSecReqList
);
/**
* 의사 회원가입 요청을 한 특정 회원의 상세정보 확인
* request parameter : doctor Id
* url : http://localhost:4000/api/manage/doctor/:doctorId
...
...
@@ -25,7 +33,7 @@ manage.get('/doctor/:doctorId', manageCtrl.getDoctorRegReqDetail);
* url : http://localhost:4000/api/manage/doctor/accept
* return : null
*/
manage
.
p
ost
(
'/doctor/accept'
,
manageCtrl
.
acceptDoctorRegReq
);
manage
.
p
atch
(
'/doctor/accept'
,
manageCtrl
.
acceptDoctorRegReq
);
/**
* 의사 요청을 한 회원을 거절한다.
...
...
@@ -33,7 +41,15 @@ manage.post('/doctor/accept', manageCtrl.acceptDoctorRegReq);
* url : http://localhost:4000/api/manange/doctor/reject
* return : null
*/
manage
.
post
(
'/doctor/reject'
,
manageCtrl
.
rejectDoctorRegReq
);
manage
.
patch
(
'/doctor/reject'
,
manageCtrl
.
rejectDoctorRegReq
);
/**
* 의사 탈퇴 요청을 수락한다.
* request parameter : doctor Id
* url : http://localhost:4000/api/manange/doctor/secession
* return : null
*/
manage
.
patch
(
'/doctor/secession'
,
manageCtrl
.
acceptDoctorSecReq
);
/**
* 의사 요청을 한 회원의 자격 번호가 유효한지 검증한다
...
...
server/src/api/manage/manage.ctrl.js
View file @
8cc448e
...
...
@@ -26,13 +26,53 @@ exports.getDoctorRegReqList = async ctx => {
}
try
{
const
doctor
RegReq
List
=
await
DoctorInfo
.
find
({
const
doctorList
=
await
DoctorInfo
.
find
({
useYn
:
'W'
,
});
ctx
.
status
=
200
;
ctx
.
body
=
{
doctorRegReqList
doctorList
};
}
catch
(
e
)
{
ctx
.
status
=
500
;
ctx
.
body
=
{
error
:
'알 수 없는 에러가 발생했습니다.'
,
};
console
.
log
(
e
);
}
};
/**
* 의사 회원탈퇴를 요청한 회원 리스트를 확인한다.
* http methods : get
* @param {*} ctx
* @returns
*/
exports
.
getDoctorSecReqList
=
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
doctorList
=
await
DoctorInfo
.
find
({
useYn
:
'WS'
,
});
ctx
.
status
=
200
;
ctx
.
body
=
{
doctorList
};
}
catch
(
e
)
{
...
...
@@ -135,7 +175,7 @@ exports.getDoctorRegReqDetail = async ctx => {
/**
* 의사 요청이 온 회원을 수락한다.
* http methods : p
ost
* http methods : p
atch
* @param {*} ctx
* @returns
*/
...
...
@@ -226,7 +266,7 @@ exports.acceptDoctorRegReq = async ctx => {
/**
* 의사 요청이 온 회원을 거절한다.
* http methods : p
ost
* http methods : p
atch
* @param {*} ctx
* @returns
*/
...
...
@@ -282,6 +322,80 @@ exports.acceptDoctorRegReq = async ctx => {
await
doctor
.
setUseYn
(
'N'
);
await
doctor
.
save
();
await
doctorInfo
.
setUseYn
(
'N'
);
await
doctorInfo
.
save
();
ctx
.
status
=
200
;
}
catch
(
e
)
{
ctx
.
status
=
500
;
ctx
.
body
=
{
error
:
'알 수 없는 에러가 발생했습니다.'
,
};
console
.
log
(
e
);
}
};
/**
* 의사 회원탈퇴 요청을 수락한다.
* http methods : patch
* @param {*} ctx
* @returns
*/
exports
.
acceptDoctorSecReq
=
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
;
}
const
doctorInfo
=
await
DoctorInfo
.
findOne
({
doctorId
,
useYn
:
'WS'
,
});
await
doctor
.
setUseYn
(
'N'
);
await
doctor
.
save
();
await
doctorInfo
.
setUseYn
(
'N'
);
await
doctorInfo
.
save
();
...
...
@@ -296,6 +410,7 @@ exports.acceptDoctorRegReq = async ctx => {
}
};
/**
* 회원가입을 요청한 의사의 유효한 자격 번호인지를 검증한다.
* @param {*} ctx
...
...
Please
register
or
login
to post a comment