Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
reservation-service
Commits
98431c1e
Commit
98431c1e
authored
Oct 30, 2020
by
Ha YeaJin
Browse files
Merge remote-tracking branch 'origin/rkyoung7' into hyj
parents
e991eb08
662b4c70
Changes
11
Hide whitespace changes
Inline
Side-by-side
server/app.js
View file @
98431c1e
...
@@ -7,8 +7,9 @@ const logger = require('morgan');
...
@@ -7,8 +7,9 @@ const logger = require('morgan');
const
indexRouter
=
require
(
'
./routes/index
'
);
const
indexRouter
=
require
(
'
./routes/index
'
);
const
usersRouter
=
require
(
'
./routes/users
'
);
const
usersRouter
=
require
(
'
./routes/users
'
);
const
loginRouter
=
require
(
'
./routes/login
'
);
const
loginRouter
=
require
(
'
./routes/login
'
);
const
reserveRouter
=
require
(
'
./routes/reserves
'
);
const
reserve
s
Router
=
require
(
'
./routes/reserves
'
);
const
noticeRouter
=
require
(
'
./routes/notices
'
);
const
noticeRouter
=
require
(
'
./routes/notices
'
);
const
connect
=
require
(
'
./schemas
'
);
const
connect
=
require
(
'
./schemas
'
);
const
app
=
express
();
const
app
=
express
();
...
@@ -31,11 +32,12 @@ app.use(cookieParser());
...
@@ -31,11 +32,12 @@ app.use(cookieParser());
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
'
public
'
)));
app
.
use
(
express
.
static
(
path
.
join
(
__dirname
,
'
public
'
)));
app
.
use
(
'
/
'
,
indexRouter
);
app
.
use
(
'
/
'
,
indexRouter
);
app
.
use
(
'
/users
'
,
usersRouter
);
app
.
use
(
'
/users
'
,
usersRouter
,
reservesRouter
);
app
.
use
(
'
/login
'
,
loginRouter
);
app
.
use
(
'
/login
'
,
loginRouter
);
app
.
use
(
'
/reserves
'
,
reserveRouter
);
app
.
use
(
'
/reserves
'
,
reserve
s
Router
);
app
.
use
(
'
/notices
'
,
noticeRouter
);
app
.
use
(
'
/notices
'
,
noticeRouter
);
// catch 404 and forward to error handler
// catch 404 and forward to error handler
app
.
use
(
function
(
req
,
res
,
next
)
{
app
.
use
(
function
(
req
,
res
,
next
)
{
next
(
createError
(
404
));
next
(
createError
(
404
));
...
...
server/client/src/Components/List.js
deleted
100644 → 0
View file @
e991eb08
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
{
Field
,
Formik
}
from
'
formik
'
;
import
axios
from
'
axios
'
;
import
{
render
}
from
'
react-dom
'
;
import
{
Link
,
Redirect
}
from
'
react-router-dom
'
;
import
styled
from
'
styled-components
'
;
function
List
(
props
)
{
function
remove
()
{
console
.
log
(
props
.
_id
)
axios
.
delete
(
`/reserves/
${
props
.
_id
}
`
,
{
data
:
{
_id
:
props
.
_id
,
}})
.
then
(
res
=>
{
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
alert
(
"
신청이 완료되었습니다!
"
)
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
});
};
return
(
<
div
>
<
div
>
날짜
:
{
props
.
date
}
<
/div
>
<
div
>
이름
:
{
props
.
name
}
<
/div
>
<
div
>
강의실
:
{
props
.
room
}
<
/div
>
<
div
>
시간
:
{
props
.
time
}
<
/div
>
<
div
>
사용인원
:
{
props
.
num
}
<
/div
>
<
div
>
{
props
.
_id
}
<
/div
>
<
form
onSubmit
=
{
remove
}
className
=
"
col-sm-3
"
>
<
button
type
=
"
submit
"
className
=
"
btn btn-dark
"
>
신청
취소
<
/button
>
<
/form
>
<
/div
>
)
}
export
default
List
;
\ No newline at end of file
server/client/src/Components/Menu.js
View file @
98431c1e
...
@@ -39,11 +39,13 @@ function Menu() {
...
@@ -39,11 +39,13 @@ function Menu() {
<
Link
to
=
"
/notice
"
className
=
"
nav-link
"
>
공지사항
<
/Link
>
<
Link
to
=
"
/notice
"
className
=
"
nav-link
"
>
공지사항
<
/Link
>
<
/li
>
<
/li
>
<
li
className
=
"
nav-item
"
>
<
li
className
=
"
nav-item
"
>
{
console
.
log
(
name
)}
<
Link
to
=
"
/home
"
className
=
"
nav-link
"
>
대관
현황
<
/Link
>
<
Link
to
=
"
/home
"
className
=
"
nav-link
"
>
대관
현황
<
/Link
>
<
/li
>
<
/li
>
<
li
className
=
"
nav-item
"
>
<
li
className
=
"
nav-item
"
>
<
Link
to
=
"
/apply
"
className
=
"
nav-link
"
>
대관
신청
<
/Link
>
<
Link
to
=
{{
pathname
:
`/apply/
${
localStorage
.
getItem
(
'
_id
'
)}
`
,
state
:
{
id
:
localStorage
.
getItem
(
'
_id
'
)
},
}}
className
=
"
nav-link
"
>
대관
신청
<
/Link
>
<
/li
>
<
/li
>
<
li
className
=
"
nav-item
"
>
<
li
className
=
"
nav-item
"
>
<
Link
to
=
{{
<
Link
to
=
{{
...
@@ -52,6 +54,13 @@ function Menu() {
...
@@ -52,6 +54,13 @@ function Menu() {
}}
className
=
"
nav-link
"
>
}}
className
=
"
nav-link
"
>
대관
확인
/
취소
<
/Link
>
대관
확인
/
취소
<
/Link
>
<
/li
>
<
/li
>
<
li
className
=
"
nav-item
"
>
<
Link
to
=
{{
pathname
:
`/acheck/
${
localStorage
.
getItem
(
'
_id
'
)}
`
,
state
:
{
id
:
localStorage
.
getItem
(
'
_id
'
)
},
}}
className
=
"
nav-link
"
>
대관
확인
/
취소
(
관리자
)
<
/Link
>
<
/li
>
<
/ul
>
<
/ul
>
<
div
className
=
"
h-100 mr-3
"
>
<
div
className
=
"
h-100 mr-3
"
>
<
div
className
=
"
text-white text-right font-weight-light
"
><
small
>
{
name
}
님
안녕하세요
<
/small></
div
>
<
div
className
=
"
text-white text-right font-weight-light
"
><
small
>
{
name
}
님
안녕하세요
<
/small></
div
>
...
...
server/client/src/Pages/ACheckPage.js
0 → 100644
View file @
98431c1e
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
Menu
from
'
../Components/Menu
'
;
import
axios
from
'
axios
'
;
import
{
Link
,
Redirect
}
from
'
react-router-dom
'
;
import
'
bootstrap/dist/css/bootstrap.css
'
;
function
ACheck
(
props
)
{
const
[
state
,
setState
]
=
useState
()
const
[
reserve
,
setReserve
]
=
useState
([]);
useEffect
(()
=>
{
getReserve
();
},
[])
function
getReserve
()
{
axios
.
get
(
`/users/admin/
${
props
.
match
.
params
.
id
}
`
,
{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
})
.
then
(
res
=>
{
if
(
res
.
status
===
404
)
{
alert
(
res
.
data
.
error
)
setState
(
true
);
}
console
.
log
(
res
.
data
);
setReserve
(
res
.
data
);
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
});
}
if
(
state
)
return
<
Redirect
to
=
"
/home
"
/>
;
function
remove
(
index
)
{
axios
.
delete
(
`/reserves/
${
reserve
[
index
].
_id
}
`
)
.
then
(
res
=>
{
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
alert
(
"
삭제되었습니다!
"
);
getReserve
();
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
});
};
function
admit
(
index
)
{
axios
.
put
(
`/reserves/
${
reserve
[
index
].
_id
}
`
)
.
then
(
res
=>
{
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
alert
(
"
승인되었습니다!
"
);
getReserve
();
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
});
};
return
(
<
div
>
<
Menu
/>
<
div
className
=
""
>
<
table
className
=
"
table
"
>
<
thead
>
<
tr
>
<
th
>
대표자
<
/th
>
<
th
>
날짜
<
/th
>
<
th
>
시간
<
/th
>
<
th
>
강의실
<
/th
>
<
th
>
사용인원
<
/th
>
<
th
>
승인여부
<
/th
>
<
/tr
>
<
/thead
>
<
tbody
>
{
reserve
.
map
((
reserve
,
index
)
=>
{
return
(
<
tr
key
=
{
index
}
>
<
td
>
{
reserve
.
user
.
name
}
<
/td
>
<
td
>
{
reserve
.
date
}
<
/td
>
<
td
>
{
reserve
.
time
}
<
/td
>
<
td
>
{
reserve
.
room
}
<
/td
>
<
td
>
{
reserve
.
num
}
<
/td
>
<
td
>
<
button
onClick
=
{()
=>
admit
(
index
)}
className
=
"
btn btn-primary
"
>
승인
<
/button
>
<
button
onClick
=
{()
=>
remove
(
index
)}
className
=
"
btn btn-danger
"
>
거절
<
/button
>
<
/td
>
<
/tr
>
)
})}
<
/tbody
>
<
/table
>
<
/div
>
<
/div
>
)
}
export
default
ACheck
\ No newline at end of file
server/client/src/Pages/ApplyPage.js
View file @
98431c1e
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
{
Formik
}
from
'
formik
'
;
import
{
Formik
,
Field
,
ErrorMessage
,
FieldArray
}
from
'
formik
'
;
import
Menu
from
'
../Components/Menu
'
;
import
Menu
from
'
../Components/Menu
'
;
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
'
bootstrap/dist/css/bootstrap.css
'
;
import
*
as
Yup
from
'
yup
'
;
import
{
Redirect
}
from
'
react-router-dom
'
;
function
Apply
(
props
)
{
const
[
state
,
setState
]
=
useState
();
const
[
user
,
setUser
]
=
useState
({
name
:
""
});
useEffect
(()
=>
{
getUser
();
},
[])
if
(
state
)
{
return
<
Redirect
to
=
{{
pathname
:
`/check/
${
props
.
match
.
params
.
id
}
`
,
state
:
{
id
:
props
.
match
.
params
.
id
},
}}
/>
;
}
function
time
(
starttime
)
{
console
.
log
(
starttime
)
if
(
starttime
==
21
)
{
return
(
<
Field
as
=
"
select
"
name
=
"
usetime
"
>
<
option
value
=
""
>
이용시간을
선택하세요
<
/option
>
<
option
value
=
"
1
"
>
1
시간
<
/option
>
<
/Field>
)
}
if
(
starttime
==
20
)
{
return
(
<
Field
as
=
"
select
"
name
=
"
usetime
"
>
<
option
value
=
""
>
이용시간을
선택하세요
<
/option
>
<
option
value
=
"
1
"
>
1
시간
<
/option
>
<
option
value
=
"
2
"
>
2
시간
<
/option
>
<
/Field>
)
}
return
(
<
Field
as
=
"
select
"
name
=
"
usetime
"
>
<
option
value
=
""
>
이용시간을
선택하세요
<
/option
>
<
option
value
=
"
1
"
>
1
시간
<
/option
>
<
option
value
=
"
2
"
>
2
시간
<
/option
>
<
option
value
=
"
3
"
>
3
시간
<
/option
>
<
/Field>
)
}
function
getUser
()
{
axios
.
get
(
`/users/
${
props
.
match
.
params
.
id
}
`
,
{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
})
.
then
(
res
=>
{
if
(
res
.
status
!==
201
)
{
alert
(
res
.
data
.
error
);
}
console
.
log
(
res
.
data
);
setUser
(
res
.
data
);
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
});
}
function
Apply
()
{
return
(
return
(
<
div
>
<
div
>
<
Menu
/>
<
Menu
/>
<
div
className
=
"
container
"
>
apply
<
Formik
<
Formik
initialValues
=
{{
initialValues
=
{{
date
:
"
20201003
"
,
_id
:
`
${
props
.
match
.
params
.
id
}
`
,
time
:
"
시간
"
,
date
:
''
,
room
:
"
9-116
"
,
starttime
:
''
,
name
:
"
종윤
"
,
usetime
:
''
,
_id
:
"
5f6fa20001988e5604603870
"
,
room
:
''
,
reason
:
"
study hard
"
,
reason
:
''
,
member
:
"
jinju rkyoung
"
,
students
:
[
approve
:
false
,
{
num
:
5
,
member
:
''
,
}}
},
onSubmit
=
{(
values
,
{
setSubmitting
})
=>
{
],
axios
({
}}
method
:
'
post
'
,
validationSchema
=
{
Yup
.
object
({
url
:
'
/reserves
'
,
date
:
Yup
.
string
()
data
:
values
,
.
required
(
'
날짜를 입력해주세요.
'
),
}).
then
(
res
=>
{
room
:
Yup
.
string
()
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
.
required
(
'
강의실 번호를 입력해주세요.
'
),
alert
(
"
신청이 완료되었습니다!
"
)
reason
:
Yup
.
string
()
.
required
(
'
대관목적을 입력해주세요.
'
),
})
})}
.
catch
(
err
=>
{
onSubmit
=
{(
values
,
{
setSubmitting
})
=>
{
alert
(
err
.
error
)
console
.
log
(
values
)
});
axios
({
method
:
'
post
'
,
setTimeout
(()
=>
{
url
:
'
/reserves
'
,
setSubmitting
(
false
);
data
:
values
},
400
);
// finish the cycle in handler
}).
then
(
res
=>
{
}}
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
>
alert
(
"
신청이 완료되었습니다!
"
);
{({
setState
(
true
);
handleSubmit
,
})
isSubmitting
,
.
catch
(
err
=>
{
})
=>
(
alert
(
err
.
error
)
<
div
className
=
"
row justify-content-center align-items-center
"
>
});
<
form
onSubmit
=
{
handleSubmit
}
className
=
"
col-sm-3
"
>
<
button
type
=
"
submit
"
className
=
"
btn btn-dark
"
disabled
=
{
isSubmitting
}
>
// setTimeout(() => {
Sign
Up
// setSubmitting(false);
// }, 400); // finish the cycle in handler
}}
>
{({
errors
,
touched
,
values
,
handleSubmit
,
getFieldProps
,
isSubmitting
,
})
=>
(
<
div
className
=
"
row justify-content-center align-items-center
"
>
<
form
onSubmit
=
{
handleSubmit
}
className
=
"
col-sm-3
"
>
<
div
className
=
"
form-group mb-4
"
>
<
label
>
대표자
<
/label
>
<
div
>
{
user
.
name
}
<
/div
>
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
label
>
신청날짜
<
/label
>
<
input
className
=
{(
touched
.
date
&&
errors
.
date
?
'
form-control is-invalid
'
:
"
form-control
"
)}
type
=
"
text
"
name
=
"
date
"
{...
getFieldProps
(
'
date
'
)}
placeholder
=
"
yyyy-mm-dd
"
/>
{
touched
.
date
&&
errors
.
date
?
(
<
div
className
=
"
invalid-feedback text-left
"
>
{
errors
.
date
}
<
/div
>
)
:
null
}
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
label
>
이용시작시간
<
/label
>
<
Field
as
=
"
select
"
name
=
"
starttime
"
>
<
option
value
=
""
>
이용시작시간
<
/option
>
<
option
value
=
"
9
"
>
9
시
<
/option
>
<
option
value
=
"
10
"
>
10
시
<
/option
>
<
option
value
=
"
11
"
>
11
시
<
/option
>
<
option
value
=
"
12
"
>
12
시
<
/option
>
<
option
value
=
"
13
"
>
13
시
<
/option
>
<
option
value
=
"
14
"
>
14
시
<
/option
>
<
option
value
=
"
15
"
>
15
시
<
/option
>
<
option
value
=
"
16
"
>
16
시
<
/option
>
<
option
value
=
"
17
"
>
17
시
<
/option
>
<
option
value
=
"
18
"
>
18
시
<
/option
>
<
option
value
=
"
19
"
>
19
시
<
/option
>
<
option
value
=
"
20
"
>
20
시
<
/option
>
<
option
value
=
"
21
"
>
21
시
<
/option
>
<
/Field
>
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
label
>
이용시간
<
/label
>
{
time
(
values
.
starttime
)}
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
label
>
강의실
<
/label
>
<
input
className
=
{(
touched
.
room
&&
errors
.
room
?
'
form-control is-invalid
'
:
"
form-control
"
)}
type
=
"
text
"
name
=
"
room
"
{...
getFieldProps
(
'
room
'
)}
placeholder
=
"
bn-nnn
"
/>
{
touched
.
room
&&
errors
.
room
?
(
<
div
className
=
"
invalid-feedback text-left
"
>
{
errors
.
room
}
<
/div
>
)
:
null
}
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
label
>
대관목적
<
/label
>
<
input
className
=
{(
touched
.
reason
&&
errors
.
reason
?
'
form-control is-invalid
'
:
"
form-control
"
)}
type
=
"
text
"
name
=
"
reason
"
{...
getFieldProps
(
'
reason
'
)}
placeholder
=
"
대관목적을 입력해 주세요.
"
/>
{
touched
.
reason
&&
errors
.
reason
?
(
<
div
className
=
"
invalid-feedback text-left
"
>
{
errors
.
reason
}
<
/div
>
)
:
null
}
<
/div
>
<
div
className
=
"
form-group mb-4
"
>
<
FieldArray
name
=
"
students
"
>
{({
insert
,
remove
,
push
})
=>
(
<
div
>
<
label
>
이용자
<
/label
>
{
values
.
students
.
map
((
student
,
index
)
=>
(
<
div
className
=
"
row
"
key
=
{
index
}
>
<
div
className
=
"
col
"
>
<
Field
name
=
{
`students.
${
index
}
.member`
}
placeholder
=
"
이용자 성함을 입력하세요.
"
type
=
"
text
"
/>
<
ErrorMessage
name
=
{
`friends.
${
index
}
.name`
}
component
=
"
div
"
className
=
"
field-error
"
/>
<
button
type
=
"
button
"
className
=
"
secondary
"
onClick
=
{()
=>
remove
(
index
)}
>
X
<
/button
>
<
/div
>
<
/div
>
))}
<
button
type
=
"
button
"
className
=
"
btn btn-primary
"
onClick
=
{()
=>
push
({
member
:
''
})}
>
추가
<
/button
>
<
/div
>
)}
<
/FieldArray
>
<
/div
>
<
button
type
=
"
submit
"
className
=
"
btn btn-dark
"
disabled
=
{
isSubmitting
}
>
신청하기
<
/button
>
<
/button
>
<
/form
>
<
/form
>
<
/div
>
<
/div
>
)}
)}
<
/Formik
>
<
/Formik
>
<
/div
>
<
/div
>
<
/div
>
)
)
}
}
...
...
server/client/src/Pages/CheckPage.js
View file @
98431c1e
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
Menu
from
'
../Components/Menu
'
;
import
Menu
from
'
../Components/Menu
'
;
import
List
from
'
../Components/List
'
;
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
'
bootstrap/dist/css/bootstrap.css
'
;
function
Check
(
props
)
{
function
Check
(
props
)
{
const
[
reserve
,
setReserve
]
=
useState
([]);
useEffect
(()
=>
{
getReserve
();
},
[])
function
getReserve
()
{
function
getReserve
()
{
axios
.
get
(
`/reserves/
${
props
.
match
.
params
.
id
}
`
,
{
axios
.
get
(
`/reserves/
${
props
.
match
.
params
.
id
}
`
,
{
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
headers
:
{
authorization
:
localStorage
.
getItem
(
'
token
'
)
},
...
@@ -19,21 +24,56 @@ function Check(props) {
...
@@ -19,21 +24,56 @@ function Check(props) {
alert
(
err
.
error
)
alert
(
err
.
error
)
});
});
}
}
function
remove
(
index
)
{
axios
.
delete
(
`/reserves/
${
reserve
[
index
].
_id
}
`
)
.
then
(
res
=>
{
if
(
res
.
status
===
404
)
return
alert
(
res
.
data
.
error
)
alert
(
"
삭제되었습니다!
"
);
getReserve
();
})
.
catch
(
err
=>
{
alert
(
err
.
error
)
});
};
const
[
reserve
,
setReserve
]
=
useState
([]);
useEffect
(()
=>
{
getReserve
();
},
[])
return
(
return
(
<
div
>
<
div
>
<
Menu
/>
<
Menu
/>
<
div
className
=
"
container
"
>
check
<
div
className
=
""
>
{
reserve
.
map
((
reserve
,
index
)
=>
<
table
className
=
"
table
"
>
<
List
id
=
{
props
.
match
.
params
.
id
}
index
=
{
index
}
date
=
{
reserve
.
date
}
name
=
{
reserve
.
name
}
room
=
{
reserve
.
room
}
time
=
{
reserve
.
time
}
num
=
{
reserve
.
num
}
_id
=
{
reserve
.
_id
}
/
>
<
thead
>
)}
<
tr
>
<
th
>
날짜
<
/th
>
<
th
>
시간
<
/th
>
<
th
>
강의실
<
/th
>
<
th
>
사용인원
<
/th
>
<
th
>
승인여부
<
/th
>
<
th
>
예약취소
<
/th
>
<
/tr
>
<
/thead
>
<
tbody
>
{
reserve
.
map
((
reserve
,
index
)
=>
{
return
(
<
tr
key
=
{
index
}
>
<
td
>
{
reserve
.
date
}
<
/td
>
<
td
>
{
reserve
.
starttime
}
시
~
{(
Number
(
reserve
.
starttime
)
+
reserve
.
usetime
)}
시
<
/td
>
<
td
>
{
reserve
.
room
}
<
/td
>
<
td
>
{
reserve
.
num
}
<
/td
>
<
td
>
{
reserve
.
approve
?
"
승인
"
:
"
미승인
"
}
<
/td
>
<
td
>
<
button
onClick
=
{()
=>
remove
(
index
)}
className
=
"
btn btn-danger
"
>
취소
<
/button
>
<
/td
>
<
/tr
>
)
})}
<
/tbody
>
<
/table
>
<
/div
>
<
/div
>
<
/div
>
<
/div
>
)
)
}
}
export
default
Check
export
default
Check
\ No newline at end of file
server/client/src/index.js
View file @
98431c1e
...
@@ -15,6 +15,7 @@ import Change from './Pages/ChangePage';
...
@@ -15,6 +15,7 @@ import Change from './Pages/ChangePage';
import
Apply
from
'
./Pages/ApplyPage
'
;
import
Apply
from
'
./Pages/ApplyPage
'
;
import
Check
from
'
./Pages/CheckPage
'
;
import
Check
from
'
./Pages/CheckPage
'
;
import
Notice
from
'
./Pages/NoticePage
'
;
import
Notice
from
'
./Pages/NoticePage
'
;
import
ACheck
from
'
./Pages/ACheckPage
'
;
axios
.
defaults
.
validateStatus
=
function
(
status
)
{
axios
.
defaults
.
validateStatus
=
function
(
status
)
{
return
status
<
500
;
// default
return
status
<
500
;
// default
...
@@ -29,9 +30,10 @@ ReactDOM.render(
...
@@ -29,9 +30,10 @@ ReactDOM.render(
<
Route
path
=
"
/signup
"
component
=
{
Signup
}
/
>
<
Route
path
=
"
/signup
"
component
=
{
Signup
}
/
>
<
Route
path
=
"
/find
"
component
=
{
Find
}
/
>
<
Route
path
=
"
/find
"
component
=
{
Find
}
/
>
<
Route
path
=
"
/change
"
component
=
{
Change
}
/
>
<
Route
path
=
"
/change
"
component
=
{
Change
}
/
>
<
Route
path
=
"
/apply
"
component
=
{
Apply
}
/
>
<
Route
path
=
"
/apply
/:id
"
component
=
{
Apply
}
/
>
<
Route
path
=
"
/check/:id
"
component
=
{
Check
}
/
>
<
Route
path
=
"
/check/:id
"
component
=
{
Check
}
/
>
<
Route
path
=
"
/notice
"
component
=
{
Notice
}
/
>
<
Route
path
=
"
/notice
"
component
=
{
Notice
}
/
>
<
Route
path
=
"
/acheck/:id
"
component
=
{
ACheck
}
/
>
<
Redirect
path
=
"
/
"
to
=
"
/
"
/>
<
Redirect
path
=
"
/
"
to
=
"
/
"
/>
<
Redirect
path
=
"
/home
"
to
=
"
/
"
/>
<
Redirect
path
=
"
/home
"
to
=
"
/
"
/>
<
Redirect
path
=
"
/change/:id
"
to
=
"
/change
"
/>
<
Redirect
path
=
"
/change/:id
"
to
=
"
/change
"
/>
...
...
server/routes/reserves.js
View file @
98431c1e
const
express
=
require
(
'
express
'
);
const
express
=
require
(
'
express
'
);
const
User
=
require
(
'
../schemas/user
'
);
const
Reserve
=
require
(
'
../schemas/reserve
'
);
const
Reserve
=
require
(
'
../schemas/reserve
'
);
const
{
verifyToken
}
=
require
(
'
./middlewares
'
);
const
{
verifyToken
}
=
require
(
'
./middlewares
'
);
...
@@ -8,15 +9,17 @@ router.post('/', function (req, res, next) {
...
@@ -8,15 +9,17 @@ router.post('/', function (req, res, next) {
console
.
log
(
'
/reserve post req.body
'
,
req
.
body
)
console
.
log
(
'
/reserve post req.body
'
,
req
.
body
)
const
reserve
=
new
Reserve
({
const
reserve
=
new
Reserve
({
user
:
req
.
body
.
_id
,
date
:
req
.
body
.
date
,
date
:
req
.
body
.
date
,
time
:
req
.
body
.
time
,
starttime
:
Number
(
req
.
body
.
starttime
),
usetime
:
Number
(
req
.
body
.
usetime
),
start
:
`
${
req
.
body
.
date
}
T`
+
`
${
req
.
body
.
starttime
}
:00:00`
,
end
:
`
${
req
.
body
.
date
}
T`
+
`
${
Number
(
req
.
body
.
starttime
)
+
Number
(
req
.
body
.
usetime
)}
:00:00`
,
room
:
req
.
body
.
room
,
room
:
req
.
body
.
room
,
name
:
req
.
body
.
name
,
id
:
req
.
body
.
_id
,
reason
:
req
.
body
.
reason
,
reason
:
req
.
body
.
reason
,
member
:
req
.
body
.
member
,
students
:
req
.
body
.
students
,
approve
:
req
.
body
.
approve
,
approve
:
req
.
body
.
approve
,
num
:
req
.
body
.
num
,
num
:
req
.
body
.
students
.
length
+
1
,
});
});
reserve
.
save
()
reserve
.
save
()
...
@@ -33,19 +36,29 @@ router.post('/', function (req, res, next) {
...
@@ -33,19 +36,29 @@ router.post('/', function (req, res, next) {
// router.get('/:_id', verifyToken, function (req, res, next) {
// router.get('/:_id', verifyToken, function (req, res, next) {
router
.
get
(
'
/:_id
'
,
function
(
req
,
res
,
next
)
{
router
.
get
(
'
/:_id
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/reserves get req.params
'
,
req
.
params
)
console
.
log
(
'
/reserves get req.params
'
,
req
.
params
)
Reserve
.
find
({
id
:
req
.
params
.
_id
},
function
(
err
,
reserve
)
{
Reserve
.
find
({
user
:
req
.
params
.
_id
},
function
(
err
,
reserve
)
{
console
.
log
(
'
id.name
'
,
reserve
)
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
console
.
log
(
'
reserve list
'
,
reserve
)
console
.
log
(
'
reserve list
'
,
reserve
)
res
.
status
(
201
).
json
(
reserve
);
res
.
status
(
201
).
json
(
reserve
);
})
})
});
});
router
.
get
(
'
/admin/:_id
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/reserves/admin get req.params
'
,
req
.
params
)
Reserve
.
find
({
approve
:
false
}).
populate
(
'
user
'
).
exec
(
function
(
err
,
reserve
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
console
.
log
(
'
reserve list
'
,
reserve
)
res
.
status
(
201
).
json
(
reserve
);
})
});
router
.
delete
(
'
/:_id
'
,
function
(
req
,
res
,
next
)
{
router
.
delete
(
'
/:_id
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/reserves delete req.params
'
,
req
.
params
)
console
.
log
(
'
/reserves delete req.params
'
,
req
.
params
)
Reserve
.
findOne
({
_id
:
req
.
params
.
_id
},
function
(
err
,
reserve
)
{
Reserve
.
findOne
({
_id
:
req
.
params
.
_id
},
function
(
err
,
reserve
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
reserve
.
remove
()
reserve
.
remove
()
.
then
(()
=>
{
.
then
(()
=>
{
console
.
log
();
console
.
log
();
...
@@ -58,4 +71,21 @@ router.delete('/:_id', function (req, res, next) {
...
@@ -58,4 +71,21 @@ router.delete('/:_id', function (req, res, next) {
})
})
});
});
router
.
put
(
'
/:id
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/reserves put req.body
'
,
req
.
params
)
Reserve
.
findOne
({
_id
:
req
.
params
.
id
},
'
approve
'
,
function
(
err
,
reserve
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
reserve
.
approve
=
true
;
reserve
.
save
()
.
then
((
result
)
=>
{
console
.
log
(
result
);
res
.
status
(
201
).
json
(
result
);
})
.
catch
((
err
)
=>
{
console
.
error
(
err
);
next
(
err
);
});
});
});
module
.
exports
=
router
;
module
.
exports
=
router
;
server/routes/users.js
View file @
98431c1e
...
@@ -34,6 +34,25 @@ router.post('/', function (req, res, next) {
...
@@ -34,6 +34,25 @@ router.post('/', function (req, res, next) {
})
})
});
});
router
.
get
(
'
/:_id
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/users get req.params
'
,
req
.
params
)
User
.
findOne
({
_id
:
req
.
params
.
_id
},
function
(
err
,
user
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
res
.
status
(
201
).
json
(
user
);
})
});
router
.
get
(
'
/admin/:_id
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/admin get req.params
'
,
req
.
params
)
User
.
findOne
({
_id
:
req
.
params
.
_id
},
'
role
'
,
function
(
err
,
user
)
{
if
(
err
)
return
res
.
status
(
500
).
json
({
error
:
err
});
if
(
user
.
role
==
'
admin
'
)
{
next
();
}
else
return
res
.
status
(
404
).
json
({
error
:
'
권한이 없습니다.
'
})
})
});
router
.
put
(
'
/change/:id
'
,
function
(
req
,
res
,
next
)
{
router
.
put
(
'
/change/:id
'
,
function
(
req
,
res
,
next
)
{
console
.
log
(
'
/change put req.body
'
,
req
.
params
)
console
.
log
(
'
/change put req.body
'
,
req
.
params
)
User
.
findOne
({
_id
:
req
.
params
.
id
},
'
password
'
,
function
(
err
,
user
)
{
User
.
findOne
({
_id
:
req
.
params
.
id
},
'
password
'
,
function
(
err
,
user
)
{
...
...
server/schemas/index.js
View file @
98431c1e
...
@@ -5,7 +5,7 @@ module.exports = () => {
...
@@ -5,7 +5,7 @@ module.exports = () => {
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
if
(
process
.
env
.
NODE_ENV
!==
'
production
'
)
{
mongoose
.
set
(
'
debug
'
,
true
);
mongoose
.
set
(
'
debug
'
,
true
);
}
}
mongoose
.
connect
(
'
mongodb://
hyj:hyj365
7@localhost:27017/admin
'
,
{
mongoose
.
connect
(
'
mongodb://
rkyoung7:rkdud12
7@localhost:27017/admin
'
,
{
dbName
:
'
ku_rental
'
,
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
,
dbName
:
'
ku_rental
'
,
useNewUrlParser
:
true
,
useUnifiedTopology
:
true
,
},
(
error
)
=>
{
},
(
error
)
=>
{
if
(
error
)
{
if
(
error
)
{
...
...
server/schemas/reserve.js
View file @
98431c1e
...
@@ -3,7 +3,7 @@ const mongoose = require('mongoose');
...
@@ -3,7 +3,7 @@ const mongoose = require('mongoose');
const
{
Schema
}
=
mongoose
;
const
{
Schema
}
=
mongoose
;
const
{
Types
:
{
ObjectId
}
}
=
Schema
;
const
{
Types
:
{
ObjectId
}
}
=
Schema
;
const
reserveSchema
=
new
Schema
({
const
reserveSchema
=
new
Schema
({
id
:
{
user
:
{
type
:
ObjectId
,
type
:
ObjectId
,
required
:
true
,
required
:
true
,
ref
:
'
User
'
,
ref
:
'
User
'
,
...
@@ -11,15 +11,20 @@ const reserveSchema = new Schema({
...
@@ -11,15 +11,20 @@ const reserveSchema = new Schema({
date
:
{
date
:
{
type
:
String
,
type
:
String
,
},
},
time
:
{
starttime
:
{
type
:
Number
,
},
usetime
:
{
type
:
Number
,
},
start
:
{
type
:
String
,
type
:
String
,
},
},
room
:
{
end
:
{
type
:
String
,
type
:
String
,
},
},
name
:
{
//대표자 이름
room
:
{
type
:
String
,
type
:
String
,
},
},
...
@@ -27,8 +32,8 @@ const reserveSchema = new Schema({
...
@@ -27,8 +32,8 @@ const reserveSchema = new Schema({
type
:
String
,
type
:
String
,
},
},
member
:
{
students
:
{
type
:
String
,
type
:
Array
,
},
},
approve
:
{
approve
:
{
...
@@ -39,8 +44,6 @@ const reserveSchema = new Schema({
...
@@ -39,8 +44,6 @@ const reserveSchema = new Schema({
num
:
{
num
:
{
type
:
Number
,
type
:
Number
,
},
},
});
});
module
.
exports
=
mongoose
.
model
(
'
Reserve
'
,
reserveSchema
);
module
.
exports
=
mongoose
.
model
(
'
Reserve
'
,
reserveSchema
);
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment