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
229f8a70
Commit
229f8a70
authored
Nov 01, 2021
by
Kim, Subin
Browse files
Merge remote-tracking branch 'origin/rkyoung7'
parents
54044c94
7176f8e0
Changes
15
Hide whitespace changes
Inline
Side-by-side
client/src/App.js
View file @
229f8a70
...
...
@@ -28,6 +28,7 @@ function App() {
<
Route
path
=
"
/studyplan/edit
"
component
=
{
StudyPlanEditPage
}
/
>
<
Route
path
=
"
/studyplan/:
"
component
=
{
StudyPlanPage
}
/
>
<
Route
path
=
"
/studyplan
"
component
=
{
StudyPlanListPage
}
/
>
<
Route
path
=
"
/subject/edit/:subjectId
"
component
=
{
SubjectEditPage
}
/
>
<
Route
path
=
"
/subject/edit
"
component
=
{
SubjectEditPage
}
/
>
<
Route
path
=
"
/admin/edit
"
component
=
{
ScheduleEditPage
}
/
>
<
Route
path
=
"
/admin
"
component
=
{
AdminPage
}
/
>
...
...
client/src/apis/subject.api.js
0 → 100644
View file @
229f8a70
import
axios
from
"
axios
"
;
const
addsubject
=
async
(
info
)
=>
{
console
.
log
(
'
info확인
'
,
info
)
const
url
=
`/api/subject/addsubject`
;
const
{
data
,
status
}
=
await
axios
.
post
(
url
,
info
);
console
.
log
(
'
data status
'
,
data
,
'
|
'
,
status
)
return
{
data
,
status
}
}
const
subjectApi
=
{
addsubject
};
export
default
subjectApi
\ No newline at end of file
client/src/components/Buttons/BtnGroup.js
View file @
229f8a70
import
{
useHistory
}
from
"
react-router-dom
"
;
import
styles
from
"
./buttons.module.scss
"
;
const
BtnGroup
=
({
disabled
})
=>
{
const
BtnGroup
=
({
disabled
,
handleSubmit
})
=>
{
const
history
=
useHistory
();
return
(
<
div
className
=
"
d-flex justify-content-around my-4
"
>
<
button
className
=
"
btn btn-white col-5 shadow-none border-dark
"
type
=
"
button
"
onClick
=
{()
=>
history
.
goBack
()}
>
취소
<
/button
>
<
button
className
=
{
`btn btn-crimson col-5
${
styles
.
disabledBtn
}
`
}
type
=
"
s
ubmit
"
disabled
=
{
disabled
}
>
등록
<
/button
>
<
button
className
=
{
`btn btn-crimson col-5
${
styles
.
disabledBtn
}
`
}
type
=
"
button
"
onClick
=
{
handleS
ubmit
}
disabled
=
{
disabled
}
>
등록
<
/button
>
<
/div
>
)
}
...
...
client/src/components/Form/SubjectForm.js
View file @
229f8a70
import
{
useState
,
useEffect
}
from
'
react
'
;
import
BtnGroup
from
"
../Buttons/BtnGroup
"
;
import
styles
from
"
./form.module.scss
"
;
import
{
useParams
}
from
'
react-router-dom
'
;
import
subjectApi
from
'
../../apis/subject.api
'
;
import
catchErrors
from
'
../../utils/catchErrors.js
'
;
const
SubjectForm
=
()
=>
{
const
{
subjectId
}
=
useParams
();
const
[
error
,
setError
]
=
useState
(
""
);
const
[
subject
,
setSubject
]
=
useState
({
lectureName
:
""
,
prof
:
""
,
...
...
@@ -28,6 +33,22 @@ const SubjectForm = () => {
setSubject
({
...
subject
,
[
name
]:
value
})
}
async
function
handleSubmit
(
e
)
{
e
.
preventDefault
();
try
{
if
(
subjectId
)
{
//수정함수 실행
}
else
{
await
subjectApi
.
addsubject
(
subject
)
}
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
}
}
return
(
<>
<
div
className
=
"
position-absolute top-50 start-50 translate-middle
"
style
=
{{
width
:
"
80%
"
}}
>
...
...
@@ -46,7 +67,7 @@ const SubjectForm = () => {
<
/div
>
<
/div
>
<
div
className
=
"
pt-2
"
>
<
BtnGroup
disabled
=
{
disabled
}
/
>
<
BtnGroup
disabled
=
{
disabled
}
handleSubmit
=
{
handleSubmit
}
/
>
<
/div
>
<
/div
>
<
/
>
...
...
client/src/components/StudyPlanList.js
View file @
229f8a70
...
...
@@ -12,7 +12,7 @@ const StudyPlanList = () => {
<
div
className
=
"
card
"
>
<
div
className
=
"
card-body d-flex flex-column bg-secondary bg-opacity-25
"
>
<
div
>
<
i
class
=
"
bi bi-plus-lg d-flex justify-content-center fs-3
"
><
/i
>
<
i
class
Name
=
"
bi bi-plus-lg d-flex justify-content-center fs-3
"
><
/i
>
<
p
className
=
"
card-text mt-2 text-center
"
>
새로운
과목
추가하기
<
/p
>
<
/div
>
<
/div
>
...
...
client/src/utils/context.js
0 → 100644
View file @
229f8a70
server/controllers/subject.controller.js
0 → 100644
View file @
229f8a70
import
{
Subject
}
from
'
../db/index.js
'
;
const
addsubject
=
async
(
req
,
res
)
=>
{
console
.
log
(
'
server/addsubject req.body
'
,
req
.
body
)
const
{
lectureName
,
prof
,
classRoom
}
=
req
.
body
;
try
{
const
findName
=
await
Subject
.
findOne
({
where
:
{
name
:
lectureName
}
});
if
(
findName
)
{
throw
new
Error
(
"
이미 있는 과목입니다.
"
)
}
await
Subject
.
create
({
name
:
lectureName
,
prof
:
prof
,
room
:
classRoom
,
})
}
catch
(
error
)
{
console
.
log
(
error
)
return
res
.
status
(
500
).
send
(
error
.
message
||
"
과목저장 에러발생
"
)
}
}
export
default
{
addsubject
}
\ No newline at end of file
server/controllers/todo.controller.js
0 → 100644
View file @
229f8a70
import
{
Todo
}
from
'
../db/index.js
'
;
const
AddTodo
=
async
(
req
,
res
)
=>
{
}
export
default
{
AddTodo
,
}
\ No newline at end of file
server/controllers/user.controller.js
View file @
229f8a70
...
...
@@ -14,7 +14,8 @@ const signup = async (req, res) => {
userID
:
userId
,
password
:
password
,
userName
:
userName
,
studNum
:
userStudNum
studNum
:
userStudNum
,
role
:
"
user
"
});
res
.
status
(
201
).
json
(
"
success
"
)
}
catch
(
error
)
{
...
...
server/db/index.js
View file @
229f8a70
import
{
Sequelize
}
from
"
sequelize
"
import
dbConfig
from
"
../config/db.config.js
"
import
UserModel
from
"
../models/user.model.js
"
;
import
TodoModel
from
"
../models/todo.model.js
"
;
import
SubjectModel
from
"
../models/subject.model.js
"
;
const
sequelize
=
new
Sequelize
(
String
(
dbConfig
.
database
),
...
...
@@ -19,8 +21,14 @@ const sequelize = new Sequelize(
);
const
User
=
UserModel
(
sequelize
)
const
Todo
=
TodoModel
(
sequelize
)
const
Subject
=
SubjectModel
(
sequelize
)
Subject
.
belongsTo
(
User
)
export
{
sequelize
,
User
,
Todo
,
Subject
}
\ No newline at end of file
server/models/subject.model.js
0 → 100644
View file @
229f8a70
import
Sequelize
from
"
sequelize
"
;
const
{
DataTypes
}
=
Sequelize
;
const
SubjectModel
=
(
sequelize
)
=>
{
const
Subject
=
sequelize
.
define
(
"
subject
"
,
{
id
:
{
type
:
DataTypes
.
UUID
,
defaultValue
:
DataTypes
.
UUIDV4
,
primaryKey
:
true
},
name
:
{
type
:
DataTypes
.
STRING
},
prof
:
{
type
:
DataTypes
.
STRING
},
room
:
{
type
:
DataTypes
.
STRING
}
},
{
timestamps
:
true
,
freezeTableName
:
true
,
tableName
:
"
subjects
"
,
}
);
return
Subject
};
export
default
SubjectModel
;
\ No newline at end of file
server/models/todo.model.js
0 → 100644
View file @
229f8a70
import
Sequelize
from
"
sequelize
"
;
const
{
DataTypes
}
=
Sequelize
;
const
TodoModel
=
(
sequelize
)
=>
{
const
Todo
=
sequelize
.
define
(
"
todo
"
,
{
id
:
{
type
:
DataTypes
.
UUID
,
defaultValue
:
DataTypes
.
UUIDV4
,
primaryKey
:
true
},
title
:
{
type
:
DataTypes
.
STRING
},
date
:
{
type
:
DataTypes
.
STRING
},
done
:
{
type
:
DataTypes
.
BOOLEAN
,
defaultValue
:
false
}
},
{
timestamps
:
true
,
freezeTableName
:
true
,
tableName
:
"
todos
"
,
}
);
return
Todo
};
export
default
TodoModel
;
\ No newline at end of file
server/models/user.model.js
View file @
229f8a70
...
...
@@ -7,6 +7,11 @@ const UserModel = (sequelize) => {
const
User
=
sequelize
.
define
(
"
user
"
,
{
id
:
{
type
:
DataTypes
.
UUID
,
defaultValue
:
DataTypes
.
UUIDV4
,
primaryKey
:
true
},
userID
:
{
type
:
DataTypes
.
STRING
},
...
...
@@ -18,6 +23,9 @@ const UserModel = (sequelize) => {
},
studNum
:
{
type
:
DataTypes
.
STRING
},
role
:
{
type
:
DataTypes
.
STRING
}
},
{
...
...
server/routes/index.js
View file @
229f8a70
import
express
from
"
express
"
;
import
userRouter
from
'
./user.route.js
'
;
import
subjectRouter
from
'
./subject.route.js
'
;
const
router
=
express
.
Router
();
router
.
use
(
'
/auth
'
,
userRouter
)
router
.
use
(
'
/subject
'
,
subjectRouter
)
export
default
router
;
\ No newline at end of file
server/routes/subject.route.js
0 → 100644
View file @
229f8a70
import
express
from
'
express
'
;
import
subjectCtrl
from
'
../controllers/subject.controller.js
'
;
const
router
=
express
.
Router
();
router
.
route
(
"
/addsubject
"
)
.
post
(
subjectCtrl
.
addsubject
)
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