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
Show whitespace changes
Inline
Side-by-side
client/src/apis/subject.api.js
View file @
fd8277ba
...
@@ -2,31 +2,41 @@ import axios from "axios";
...
@@ -2,31 +2,41 @@ import axios from "axios";
import
baseUrl
from
"
../utils/baseUrl.js
"
;
import
baseUrl
from
"
../utils/baseUrl.js
"
;
const
addsubject
=
async
(
info
,
userId
)
=>
{
const
addsubject
=
async
(
info
,
userId
)
=>
{
console
.
log
(
'
subject check
'
,
userId
)
// info.user = userId;
const
url
=
`
${
baseUrl
}
/api/subject/addsubject`
;
const
url
=
`
${
baseUrl
}
/api/subject/addsubject`
;
const
{
data
}
=
await
axios
.
post
(
url
,
{
info
,
userId
});
const
{
data
}
=
await
axios
.
post
(
url
,
{
info
,
userId
});
return
data
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
)
=>
{
const
editSubject
=
async
(
info
,
id
)
=>
{
console
.
log
(
"
editSubject check
"
,
info
,
'
,
'
,
id
)
const
url
=
`
${
baseUrl
}
/api/subject/
${
id
}
`
const
url
=
`
${
baseUrl
}
/api/subject/editsubject`
const
{
data
}
=
await
axios
.
put
(
url
,
info
)
const
{
data
}
=
await
axios
.
post
(
url
,
{
info
,
id
})
return
data
return
data
}
}
const
getSubInfo
=
async
(
info
)
=>
{
const
getSubInfo
=
async
(
info
)
=>
{
console
.
log
(
'
info
'
,
info
)
const
url
=
`
${
baseUrl
}
/api/subject/
${
info
}
`
const
url
=
`
${
baseUrl
}
/api/subject/
${
info
}
`
const
{
data
}
=
await
axios
.
get
(
url
);
const
{
data
}
=
await
axios
.
get
(
url
);
return
data
return
data
}
}
const
subjectTitle
=
async
(
info
)
=>
{
const
url
=
`
${
baseUrl
}
/api/subject/title/
${
info
}
`
const
{
data
}
=
await
axios
.
get
(
url
);
return
data
}
const
subjectApi
=
{
const
subjectApi
=
{
addsubject
,
addsubject
,
getSubInfo
,
getSubInfo
,
editSubject
editSubject
,
allSubject
,
subjectTitle
};
};
export
default
subjectApi
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";
...
@@ -3,10 +3,7 @@ import styles from "./buttons.module.scss";
const
EditBtn
=
({
pathname
})
=>
{
const
EditBtn
=
({
pathname
})
=>
{
return
(
return
(
<
Link
className
=
"
me-2 mb-1
"
to
=
{{
<
Link
className
=
"
me-2 mb-1
"
to
=
{
"
/
"
+
pathname
}
>
pathname
:
"
/
"
+
pathname
,
state
:
{}
}}
>
<
i
className
=
{
`bi bi-plus-circle
${
styles
.
icon
}
`
}
><
/i
>
<
i
className
=
{
`bi bi-plus-circle
${
styles
.
icon
}
`
}
><
/i
>
<
/Link
>
<
/Link
>
)
)
...
...
client/src/components/Form/SubjectForm.js
View file @
fd8277ba
server/controllers/subject.controller.js
View file @
fd8277ba
...
@@ -22,7 +22,7 @@ const addsubject = async (req, res) => {
...
@@ -22,7 +22,7 @@ const addsubject = async (req, res) => {
}
}
const
getSubInfo
=
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
{
try
{
const
{
subjectId
}
=
req
.
params
;
const
{
subjectId
}
=
req
.
params
;
const
findSubInfo
=
await
Subject
.
findOne
({
where
:
{
id
:
subjectId
}
})
const
findSubInfo
=
await
Subject
.
findOne
({
where
:
{
id
:
subjectId
}
})
...
@@ -61,8 +61,56 @@ const editSubject = async (req, res) => {
...
@@ -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
{
export
default
{
addsubject
,
addsubject
,
getSubInfo
,
getSubInfo
,
editSubject
editSubject
,
allSubject
,
subjectTitle
}
}
\ No newline at end of file
server/routes/subject.route.js
View file @
fd8277ba
...
@@ -8,12 +8,16 @@ router
...
@@ -8,12 +8,16 @@ router
.
post
(
subjectCtrl
.
addsubject
)
.
post
(
subjectCtrl
.
addsubject
)
router
router
.
route
(
"
/
:subject
Id
"
)
.
route
(
"
/
all/:user
Id
"
)
.
get
(
subjectCtrl
.
getSubInfo
)
.
get
(
subjectCtrl
.
allSubject
)
router
router
.
route
(
"
/
editsubject
"
)
.
route
(
"
/
title/:userId
"
)
.
pos
t
(
subjectCtrl
.
editS
ubject
)
.
ge
t
(
subjectCtrl
.
s
ubject
Title
)
router
.
route
(
"
/:subjectId
"
)
.
put
(
subjectCtrl
.
editSubject
)
.
get
(
subjectCtrl
.
getSubInfo
)
export
default
router
;
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