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
Today KU
Commits
fd8277ba
Commit
fd8277ba
authored
Nov 04, 2021
by
Choi Ga Young
Browse files
subject관련
parent
2eb32b90
Changes
5
Hide whitespace changes
Inline
Side-by-side
client/src/apis/subject.api.js
View file @
fd8277ba
...
...
@@ -2,31 +2,41 @@ import axios from "axios";
import
baseUrl
from
"
../utils/baseUrl.js
"
;
const
addsubject
=
async
(
info
,
userId
)
=>
{
console
.
log
(
'
subject check
'
,
userId
)
// info.user = userId;
const
url
=
`
${
baseUrl
}
/api/subject/addsubject`
;
const
{
data
}
=
await
axios
.
post
(
url
,
{
info
,
userId
});
return
data
}
const
allSubject
=
async
(
info
)
=>
{
const
url
=
`
${
baseUrl
}
/api/subject/all/
${
info
}
`
const
{
data
}
=
await
axios
.
get
(
url
);
return
data
}
const
editSubject
=
async
(
info
,
id
)
=>
{
console
.
log
(
"
editSubject check
"
,
info
,
'
,
'
,
id
)
const
url
=
`
${
baseUrl
}
/api/subject/editsubject`
const
{
data
}
=
await
axios
.
post
(
url
,
{
info
,
id
})
const
url
=
`
${
baseUrl
}
/api/subject/
${
id
}
`
const
{
data
}
=
await
axios
.
put
(
url
,
info
)
return
data
}
const
getSubInfo
=
async
(
info
)
=>
{
console
.
log
(
'
info
'
,
info
)
const
url
=
`
${
baseUrl
}
/api/subject/
${
info
}
`
const
{
data
}
=
await
axios
.
get
(
url
);
return
data
}
const
subjectTitle
=
async
(
info
)
=>
{
const
url
=
`
${
baseUrl
}
/api/subject/title/
${
info
}
`
const
{
data
}
=
await
axios
.
get
(
url
);
return
data
}
const
subjectApi
=
{
addsubject
,
getSubInfo
,
editSubject
editSubject
,
allSubject
,
subjectTitle
};
export
default
subjectApi
\ No newline at end of file
client/src/components/Buttons/EditBtn.js
View file @
fd8277ba
...
...
@@ -3,10 +3,7 @@ import styles from "./buttons.module.scss";
const
EditBtn
=
({
pathname
})
=>
{
return
(
<
Link
className
=
"
me-2 mb-1
"
to
=
{{
pathname
:
"
/
"
+
pathname
,
state
:
{}
}}
>
<
Link
className
=
"
me-2 mb-1
"
to
=
{
"
/
"
+
pathname
}
>
<
i
className
=
{
`bi bi-plus-circle
${
styles
.
icon
}
`
}
><
/i
>
<
/Link
>
)
...
...
client/src/components/Form/SubjectForm.js
View file @
fd8277ba
...
...
@@ -49,7 +49,7 @@ const SubjectForm = () => {
})
}
async
function
handleSubmit
(
e
)
{
async
function
handleSubmit
(
e
)
{
e
.
preventDefault
();
try
{
setError
(
""
)
...
...
server/controllers/subject.controller.js
View file @
fd8277ba
...
...
@@ -11,7 +11,7 @@ const addsubject = async (req, res) => {
await
Subject
.
create
({
name
:
info
.
lectureName
,
prof
:
info
.
prof
,
room
:
info
.
classRoom
,
room
:
info
.
classRoom
,
userId
:
userId
})
...
...
@@ -22,7 +22,7 @@ const addsubject = async (req, res) => {
}
const
getSubInfo
=
async
(
req
,
res
)
=>
{
console
.
log
(
'
server/getSubInfo req.
body
'
,
req
.
params
)
console
.
log
(
'
server/getSubInfo req.
params
'
,
req
.
params
)
try
{
const
{
subjectId
}
=
req
.
params
;
const
findSubInfo
=
await
Subject
.
findOne
({
where
:
{
id
:
subjectId
}
})
...
...
@@ -61,8 +61,56 @@ const editSubject = async (req, res) => {
}
}
const
allSubject
=
async
(
req
,
res
)
=>
{
console
.
log
(
'
server/allSubject req.params
'
,
req
.
params
)
try
{
const
{
userId
}
=
req
.
params
;
const
findAllInfo
=
await
Subject
.
findAll
({
where
:
{
userId
:
userId
}
})
const
sublist
=
findAllInfo
.
map
(
info
=>
{
const
newList
=
{
id
:
info
.
id
,
name
:
info
.
name
,
prof
:
info
.
prof
,
room
:
info
.
room
,
time
:
info
.
updatedAt
}
return
newList
})
// const addplanlist = sublist.map(async(info)=>{
// const resplan = await Plan
// })
}
catch
(
error
)
{
console
.
log
(
error
)
return
res
.
status
(
500
).
send
(
error
.
message
||
"
전체과목 조회 에러
"
)
}
}
const
subjectTitle
=
async
(
req
,
res
)
=>
{
console
.
log
(
'
server/subjectTitle req.params
'
,
req
.
params
)
try
{
const
{
userId
}
=
req
.
params
const
findAllTitle
=
await
Subject
.
findAll
({
where
:
{
userId
:
userId
}
})
const
sublist
=
findAllTitle
.
map
(
info
=>
{
const
newList
=
{
id
:
info
.
id
,
name
:
info
.
name
,
}
return
newList
})
res
.
json
(
sublist
)
}
catch
(
error
)
{
console
.
log
(
error
)
return
res
.
status
(
500
).
send
(
error
.
message
||
"
과목명 조회 에러
"
)
}
}
export
default
{
addsubject
,
getSubInfo
,
editSubject
editSubject
,
allSubject
,
subjectTitle
}
\ No newline at end of file
server/routes/subject.route.js
View file @
fd8277ba
...
...
@@ -8,12 +8,16 @@ router
.
post
(
subjectCtrl
.
addsubject
)
router
.
route
(
"
/:subjectId
"
)
.
get
(
subjectCtrl
.
getSubInfo
)
.
route
(
"
/all/:userId
"
)
.
get
(
subjectCtrl
.
allSubject
)
router
.
route
(
"
/title/:userId
"
)
.
get
(
subjectCtrl
.
subjectTitle
)
router
.
route
(
"
/editsubject
"
)
.
post
(
subjectCtrl
.
editSubject
)
.
route
(
"
/:subjectId
"
)
.
put
(
subjectCtrl
.
editSubject
)
.
get
(
subjectCtrl
.
getSubInfo
)
export
default
router
;
\ No newline at end of file
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