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
443851bc
Commit
443851bc
authored
Nov 12, 2021
by
Yoon, Daeki
😅
Browse files
Merge remote-tracking branch 'origin/master' into master-up-merge-master
parents
155b7e3c
b3127999
Changes
33
Hide whitespace changes
Inline
Side-by-side
client/src/components/StudyPlan/studyplan.module.scss
View file @
443851bc
.list
{
.list
{
height
:
7
0
vh
;
height
:
7
5
vh
;
overflow-y
:
auto
;
overflow-y
:
auto
;
}
}
.inCard
{
overflow
:
scroll
;
}
.checkBox
{
.checkBox
{
border-color
:
black
;
border-color
:
black
;
...
...
client/src/components/TodoList.js
View file @
443851bc
...
@@ -13,7 +13,8 @@ const TodoList = () => {
...
@@ -13,7 +13,8 @@ const TodoList = () => {
const
{
date
}
=
useParams
()
const
{
date
}
=
useParams
()
const
[
todoList
,
setTodoList
]
=
useState
([])
const
[
todoList
,
setTodoList
]
=
useState
([])
const
[
selectTodo
,
setSelectTodo
]
=
useState
(
null
)
const
[
selectTodo
,
setSelectTodo
]
=
useState
(
null
)
const
[
error
,
setError
]
=
useState
(
""
);
const
[
clicked
,
setClicked
]
=
useState
(
false
)
const
[
error
,
setError
]
=
useState
(
""
)
useEffect
(()
=>
{
useEffect
(()
=>
{
getAll
()
getAll
()
...
@@ -29,12 +30,26 @@ const TodoList = () => {
...
@@ -29,12 +30,26 @@ const TodoList = () => {
}
}
}
}
async
function
checkFn
(
e
,
todoId
)
{
try
{
setError
(
""
)
const
check_v
=
e
.
target
.
value
===
"
true
"
?
true
:
false
await
todoApi
.
edit
({
id
:
todoId
,
done
:
check_v
},
user
.
id
)
alert
(
"
해당 변경사항이 정상적으로 저장되었습니다.
"
)
window
.
location
.
reload
()
// getAll()
// getTodoList()
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
}
}
async
function
delayTodo
()
{
async
function
delayTodo
()
{
try
{
try
{
setError
(
""
)
setError
(
""
)
const
nextDate
=
moment
(
date
).
add
(
1
,
'
day
'
).
format
(
"
YYYY-MM-DD
"
)
const
nextDate
=
moment
(
date
).
add
(
1
,
'
day
'
).
format
(
"
YYYY-MM-DD
"
)
await
todoApi
.
edit
({
id
:
selectTodo
.
id
,
todoDate
:
nextDate
},
user
.
id
)
await
todoApi
.
edit
({
id
:
selectTodo
.
id
,
todoDate
:
nextDate
},
user
.
id
)
getAll
()
window
.
location
.
reload
()
}
catch
(
error
)
{
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
catchErrors
(
error
,
setError
)
}
}
...
@@ -45,28 +60,32 @@ const TodoList = () => {
...
@@ -45,28 +60,32 @@ const TodoList = () => {
setError
(
""
)
setError
(
""
)
await
todoApi
.
remove
(
todoId
,
user
.
id
)
await
todoApi
.
remove
(
todoId
,
user
.
id
)
alert
(
"
해당 할일이 성공적으로 삭제되었습니다.
"
)
alert
(
"
해당 할일이 성공적으로 삭제되었습니다.
"
)
getAll
()
window
.
location
.
reload
()
}
catch
(
error
)
{
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
catchErrors
(
error
,
setError
)
}
}
}
}
return
(
return
(
<
div
className
=
{
"
mt-3
"
+
(
todoList
.
length
?
"
d-flex
"
:
"
d-block
"
)}
>
<
div
className
=
{
`mt-3
${
styles
.
list
}
`
}
>
{
todoList
.
length
!==
0
?
<
div
className
=
{
todoList
.
length
?
"
d-flex flex-column
"
:
"
d-block
"
}
>
todoList
.
map
((
todo
,
idx
)
=>
<>
{
todoList
.
length
!==
0
?
<
div
className
=
"
d-flex align-items-center
"
style
=
{{
width
:
"
75%
"
}}
>
todoList
.
map
((
todo
,
idx
)
=>
<
div
key
=
{
idx
}
className
=
"
d-flex mb-1
"
>
<
input
className
=
{
`form-check-input rounded-0 shadow-none mt-0
${
styles
.
checkBox
}
`
}
type
=
"
checkbox
"
checked
=
{
todo
.
done
}
/
>
<
div
className
=
"
d-flex align-items-center
"
style
=
{{
width
:
"
75%
"
}}
>
<
label
className
=
"
form-check-label fs-5 ms-3 pe-2 text-nowrap
"
style
=
{{
overflow
:
"
hidden
"
,
textOverflow
:
"
ellipsis
"
}}
>
{
todo
.
todoTitle
}
<
/label
>
<
div
className
=
"
col d-flex align-items-center
"
>
<
/div
>
<
input
className
=
{
`form-check-input rounded-0 shadow-none mt-0
${
styles
.
checkBox
}
`
}
type
=
"
checkbox
"
id
=
{
"
todoCheck
"
+
idx
}
value
=
{
todo
.
done
}
checked
=
{
todo
.
done
}
onClick
=
{(
e
)
=>
checkFn
(
e
,
todo
.
id
)}
/
>
<
div
className
=
"
d-flex justify-content-between
"
style
=
{{
cursor
:
"
pointer
"
,
width
:
"
25%
"
}}
>
<
/div
>
<
i
className
=
"
bi bi-arrow-right fs-5
"
data
-
bs
-
toggle
=
"
modal
"
data
-
bs
-
target
=
"
#postmodal
"
onClick
=
{()
=>
setSelectTodo
(
todo
)}
><
/i
>
<
label
className
=
"
col-11 form-check-label fs-5 pe-1 text-nowrap
"
style
=
{{
overflow
:
"
hidden
"
,
textOverflow
:
"
ellipsis
"
}}
>
{
todo
.
todoTitle
}
<
/label
>
<
i
className
=
"
bi bi-pencil-square fs-5
"
data
-
bs
-
toggle
=
"
modal
"
data
-
bs
-
target
=
"
#todomodal
"
onClick
=
{()
=>
setSelectTodo
(
todo
)}
><
/i
>
<
/div
>
<
i
className
=
"
bi bi-trash fs-5
"
onClick
=
{()
=>
delTodo
(
todo
.
id
)}
><
/i
>
<
div
className
=
"
d-flex justify-content-between
"
style
=
{{
cursor
:
"
pointer
"
,
width
:
"
25%
"
}}
>
<
/div
>
<
i
className
=
"
bi bi-arrow-right fs-5
"
data
-
bs
-
toggle
=
"
modal
"
data
-
bs
-
target
=
"
#postmodal
"
onClick
=
{()
=>
setSelectTodo
(
todo
)}
><
/i
>
<
/>
)
: <p className="text-center">등록된 할일이 없습니다.</
p
>
}
<
i
className
=
"
bi bi-pencil-square fs-5
"
data
-
bs
-
toggle
=
"
modal
"
data
-
bs
-
target
=
"
#todomodal
"
onClick
=
{()
=>
{
setSelectTodo
(
todo
);
setClicked
(
true
)
}}
><
/i
>
<
TodoPostModal
handleClick
=
{
delayTodo
}
/
>
<
i
className
=
"
bi bi-trash fs-5
"
onClick
=
{()
=>
delTodo
(
todo
.
id
)}
><
/i
>
<
TodoModal
curDate
=
{
date
}
selectTodo
=
{
selectTodo
}
/
>
<
/div
>
<
/div>
)
: <p className="text-center">등록된 할일이 없습니다.</
p
>
}
<
TodoPostModal
handleClick
=
{
delayTodo
}
/
>
<
TodoModal
curDate
=
{
date
}
selectTodo
=
{
selectTodo
}
clicked
=
{
clicked
}
setClicked
=
{
setClicked
}
/
>
<
/div
>
<
/div
>
<
/div
>
)
)
}
}
...
...
client/src/pages/StudyPlanPage.js
View file @
443851bc
...
@@ -33,7 +33,7 @@ const StudyPlanPage = () => {
...
@@ -33,7 +33,7 @@ const StudyPlanPage = () => {
<
Menu
/>
<
Menu
/>
<
BackBtn
/>
<
BackBtn
/>
<
h2
className
=
"
text-center
"
>
{
planList
.
name
}
<
/h2
>
<
h2
className
=
"
text-center
"
>
{
planList
.
name
}
<
/h2
>
<
AddplanList
planList
=
{
planList
}
/
>
<
AddplanList
planList
=
{
planList
}
getPlanList
=
{
getPlanList
}
/
>
<
Footer
pathname
=
{
`studyplan/submit/
${
subjectId
}
`
}
/
>
<
Footer
pathname
=
{
`studyplan/submit/
${
subjectId
}
`
}
/
>
<
/
>
<
/
>
)
)
...
...
client/src/scss/custom.scss
View file @
443851bc
...
@@ -149,10 +149,6 @@ button {
...
@@ -149,10 +149,6 @@ button {
display
:
none
;
display
:
none
;
}
}
&
.fc-dayGridDay-view
{
display
:
none
;
}
&
.text
{
&
.text
{
font-family
:
"Plex-Text"
;
font-family
:
"Plex-Text"
;
...
...
client/src/utils/context.js
View file @
443851bc
...
@@ -20,7 +20,6 @@ const AuthProvider = ({ children }) => {
...
@@ -20,7 +20,6 @@ const AuthProvider = ({ children }) => {
const
{
pathname
}
=
useLocation
()
const
{
pathname
}
=
useLocation
()
const
getUser
=
async
()
=>
{
const
getUser
=
async
()
=>
{
try
{
try
{
console
.
log
(
"
context getUser
"
)
const
resUser
=
await
authApi
.
getUser
();
const
resUser
=
await
authApi
.
getUser
();
setUser
({
...
user
,
...
resUser
})
setUser
({
...
user
,
...
resUser
})
if
(
resUser
.
role
===
"
admin
"
)
history
.
push
(
"
/admin
"
)
if
(
resUser
.
role
===
"
admin
"
)
history
.
push
(
"
/admin
"
)
...
...
server/controllers/plan.controller.js
View file @
443851bc
...
@@ -55,6 +55,18 @@ const edit = async (req, res) => {
...
@@ -55,6 +55,18 @@ const edit = async (req, res) => {
}
}
}
}
const
putCk
=
async
(
req
,
res
)
=>
{
try
{
console
.
log
(
'
server/planCtrl/putCk req.body
'
,
req
.
body
)
const
planId
=
req
.
planId
const
result
=
await
Plan
.
update
({
checked
:
!
req
.
body
.
planCk
},
{
where
:
{
id
:
planId
}
})
if
(
!
result
)
throw
new
Error
(
"
체크 상태 수정에 실패하였습니다.
"
)
else
return
res
.
send
(
"
success
"
)
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
체크 상태 저장 중 에러 발생
"
)
}
}
const
remove
=
async
(
req
,
res
)
=>
{
const
remove
=
async
(
req
,
res
)
=>
{
try
{
try
{
const
planId
=
req
.
planId
const
planId
=
req
.
planId
...
@@ -80,6 +92,7 @@ export default {
...
@@ -80,6 +92,7 @@ export default {
getOne
,
getOne
,
create
,
create
,
edit
,
edit
,
putCk
,
remove
,
remove
,
getParams
getParams
}
}
\ No newline at end of file
server/controllers/schedule.controller.js
View file @
443851bc
...
@@ -153,7 +153,6 @@ const findbyDate = async (req, res, next) => {
...
@@ -153,7 +153,6 @@ const findbyDate = async (req, res, next) => {
},
attributes
:
[
'
id
'
,
'
title
'
,
'
start
'
,
'
end
'
]
},
attributes
:
[
'
id
'
,
'
title
'
,
'
start
'
,
'
end
'
]
,
order
:
[[
'
start
'
]]
,
order
:
[[
'
start
'
]]
})
})
console
.
log
(
"
개인 일정 찾기
"
,
findIndividualList
)
findIndividualList
.
forEach
(
schedule
=>
{
findIndividualList
.
forEach
(
schedule
=>
{
schedule
.
dataValues
.
end
.
setDate
(
schedule
.
dataValues
.
end
.
getDate
()
+
1
)
schedule
.
dataValues
.
end
.
setDate
(
schedule
.
dataValues
.
end
.
getDate
()
+
1
)
schedule
.
dataValues
.
end
=
dateToString
(
schedule
.
dataValues
.
end
,
"
full
"
)
schedule
.
dataValues
.
end
=
dateToString
(
schedule
.
dataValues
.
end
,
"
full
"
)
...
...
server/controllers/subject.controller.js
View file @
443851bc
...
@@ -11,7 +11,7 @@ const findAll = async (req, res) => {
...
@@ -11,7 +11,7 @@ const findAll = async (req, res) => {
if
(
subjectId
)
findList
=
await
Subject
.
findAll
({
where
:
{
[
Op
.
and
]:
[{
id
:
subjectId
},
{
userId
:
userId
}]
},
order
:
[[
'
updatedAt
'
,
'
DESC
'
]]
})
if
(
subjectId
)
findList
=
await
Subject
.
findAll
({
where
:
{
[
Op
.
and
]:
[{
id
:
subjectId
},
{
userId
:
userId
}]
},
order
:
[[
'
updatedAt
'
,
'
DESC
'
]]
})
else
findList
=
await
Subject
.
findAll
({
where
:
{
userId
:
userId
},
order
:
[[
'
updatedAt
'
,
'
DESC
'
]]
})
else
findList
=
await
Subject
.
findAll
({
where
:
{
userId
:
userId
},
order
:
[[
'
updatedAt
'
,
'
DESC
'
]]
})
const
subjectAndPlan
=
await
Promise
.
all
(
findList
.
map
(
async
(
subjectInfo
)
=>
{
const
subjectAndPlan
=
await
Promise
.
all
(
findList
.
map
(
async
(
subjectInfo
)
=>
{
const
resPlan
=
await
Plan
.
findAll
({
where
:
{
subjectId
:
subjectInfo
.
id
}
})
const
resPlan
=
await
Plan
.
findAll
({
where
:
{
subjectId
:
subjectInfo
.
id
}
,
order
:
[[
sequelize
.
literal
(
'
checked, deadline
'
),
'
ASC
'
]]
})
subjectInfo
.
dataValues
.
planList
=
resPlan
subjectInfo
.
dataValues
.
planList
=
resPlan
return
subjectInfo
return
subjectInfo
}))
}))
...
@@ -63,8 +63,9 @@ const remove = async (req, res) => {
...
@@ -63,8 +63,9 @@ const remove = async (req, res) => {
try
{
try
{
const
{
subjectId
}
=
req
.
query
const
{
subjectId
}
=
req
.
query
const
userId
=
req
.
userId
const
userId
=
req
.
userId
const
deleted2
=
await
Plan
.
destroy
({
where
:
{
subjectId
:
subjectId
}
})
const
deleted
=
await
Subject
.
destroy
({
where
:
{
[
Op
.
and
]:
[{
id
:
subjectId
},
{
userId
:
userId
}]
}
})
const
deleted
=
await
Subject
.
destroy
({
where
:
{
[
Op
.
and
]:
[{
id
:
subjectId
},
{
userId
:
userId
}]
}
})
if
(
!
deleted
)
throw
new
Error
(
"
해당 과목을 삭제하는데 실패하였습니다.
"
)
if
(
!
(
deleted
&&
deleted2
)
)
throw
new
Error
(
"
해당 과목을 삭제하는데 실패하였습니다.
"
)
else
return
res
.
send
(
200
)
else
return
res
.
send
(
200
)
}
catch
(
error
)
{
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
과목 삭제 에러 발생
"
)
return
res
.
status
(
500
).
send
(
error
.
message
||
"
과목 삭제 에러 발생
"
)
...
...
server/controllers/todo.controller.js
View file @
443851bc
...
@@ -3,33 +3,15 @@ import sequelize from 'sequelize';
...
@@ -3,33 +3,15 @@ import sequelize from 'sequelize';
const
{
Op
}
=
sequelize
const
{
Op
}
=
sequelize
const
findbyId
=
async
(
req
,
res
,
next
)
=>
{
const
findbyDate
=
async
(
req
,
res
)
=>
{
try
{
const
userId
=
req
.
userId
const
{
todoId
}
=
req
.
query
if
(
todoId
)
{
console
.
log
(
"
findbyId todoId가 있을 때 실행
"
,
todoId
)
const
findTodo
=
await
Todo
.
findOne
({
where
:
{
[
Op
.
and
]:
[{
id
:
todoId
},
{
userId
:
userId
}]
},
attributes
:
[
'
id
'
,
[
'
title
'
,
'
todoTitle
'
],
[
'
date
'
,
'
todoDate
'
],
'
done
'
]
})
if
(
!
findTodo
)
throw
new
Error
(
"
해당 todo를 찾지 못했습니다.
"
)
req
.
todoOne
=
findTodo
}
next
()
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
todo 가져오는 중 에러 발생
"
)
}
}
const
findbyDate
=
async
(
req
,
res
,
next
)
=>
{
try
{
try
{
// Todo 페이지
const
userId
=
req
.
userId
const
userId
=
req
.
userId
const
{
date
}
=
req
.
query
const
{
date
}
=
req
.
query
if
(
date
)
{
const
nonCheck
=
await
Todo
.
findAll
({
where
:
{
[
Op
.
and
]:
[{
done
:
false
},
{
date
:
{
[
Op
.
eq
]:
date
}
},
{
userId
:
userId
}]
},
attributes
:
[
'
id
'
,
[
'
title
'
,
'
todoTitle
'
],
[
'
date
'
,
'
todoDate
'
],
'
done
'
],
order
:
[[
'
updatedAt
'
,
"
DESC
"
]]
})
console
.
log
(
"
findbydate 날짜가 있을 때 실행
"
,
date
,
userId
)
const
check
=
await
Todo
.
findAll
({
where
:
{
[
Op
.
and
]:
[{
done
:
true
},
{
date
:
{
[
Op
.
eq
]:
date
}
},
{
userId
:
userId
}]
},
attributes
:
[
'
id
'
,
[
'
title
'
,
'
todoTitle
'
],
[
'
date
'
,
'
todoDate
'
],
'
done
'
],
order
:
[[
'
updatedAt
'
,
"
DESC
"
]]
})
const
findList
=
await
Todo
.
findAll
({
where
:
{
[
Op
.
and
]:
[{
date
:
{
[
Op
.
eq
]:
date
}
},
{
userId
:
userId
}]
},
attributes
:
[
'
id
'
,
[
'
title
'
,
'
todoTitle
'
],
[
'
date
'
,
'
todoDate
'
],
'
done
'
]
})
check
.
forEach
(
el
=>
nonCheck
.
push
(
el
.
dataValues
))
console
.
log
(
"
find==
"
,
findList
)
return
res
.
json
(
nonCheck
)
req
.
todoList
=
findList
}
next
()
}
catch
(
error
)
{
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
todo 가져오는 중 에러 발생
"
)
return
res
.
status
(
500
).
send
(
error
.
message
||
"
todo 가져오는 중 에러 발생
"
)
}
}
...
@@ -37,22 +19,51 @@ const findbyDate = async (req, res, next) => {
...
@@ -37,22 +19,51 @@ const findbyDate = async (req, res, next) => {
const
findforPercent
=
async
(
req
,
res
)
=>
{
const
findforPercent
=
async
(
req
,
res
)
=>
{
try
{
try
{
let
doneTodo
=
null
let
nonCheck
=
null
let
check
=
null
const
userId
=
req
.
userId
const
userId
=
req
.
userId
const
{
start
,
end
}
=
req
.
query
const
{
start
,
end
}
=
req
.
query
if
(
end
)
{
if
(
end
)
{
const
{
count
,
rows
}
=
await
Todo
.
findAndCountAll
({
where
:
{
[
Op
.
and
]:
[{
date
:
{
[
Op
.
eq
]:
start
}
},
{
userId
:
userId
}]
}
})
// weekly percent
nonCheck
=
await
Todo
.
findAll
({
where
:
{
[
Op
.
and
]:
[{
userId
:
userId
},
{
done
:
false
},
{
date
:
{
[
Op
.
between
]:
[
start
,
end
]
}
}]
},
order
:
[[
'
date
'
]]
})
check
=
await
Todo
.
findAll
({
where
:
{
[
Op
.
and
]:
[{
userId
:
userId
},
{
done
:
true
},
{
date
:
{
[
Op
.
between
]:
[
start
,
end
]
}
}]
},
order
:
[[
'
date
'
]]
})
const
nonCheckCountList
=
countInList
(
nonCheck
)
let
checkCountList
=
countInList
(
check
)
let
percentList
=
nonCheckCountList
.
map
(
nonCheckEl
=>
{
const
findIdx
=
checkCountList
.
findIndex
(
el
=>
el
.
date
===
nonCheckEl
.
date
)
if
(
findIdx
===
-
1
)
nonCheckEl
[
'
rate
'
]
=
0
else
{
nonCheckEl
[
'
rate
'
]
=
Math
.
round
((
checkCountList
[
findIdx
].
count
/
(
nonCheckEl
.
count
+
checkCountList
[
findIdx
].
count
))
*
100
)
checkCountList
.
splice
(
findIdx
,
1
)
}
return
nonCheckEl
})
if
(
checkCountList
.
length
!==
0
)
{
checkCountList
.
forEach
(
el
=>
el
[
'
rate
'
]
=
100
)
const
sendList
=
percentList
.
concat
(
checkCountList
).
sort
((
pre
,
next
)
=>
{
if
(
pre
.
date
<
next
.
date
)
return
-
1
else
if
(
pre
.
date
>
next
.
date
)
return
1
else
return
0
})
return
res
.
json
(
sendList
)
}
else
return
res
.
json
(
percentList
)
}
else
{
}
else
{
// Menu
let
percent
=
0
let
percent
=
0
console
.
log
(
"
findforPercent end 없음
"
)
nonCheck
=
await
Todo
.
findAndCountAll
({
where
:
{
[
Op
.
and
]:
[{
date
:
{
[
Op
.
eq
]:
start
}
},
{
userId
:
userId
},
{
done
:
false
}]
},
order
:
[[
'
updatedAt
'
,
"
DESC
"
]]
})
const
nonCheck
=
await
Todo
.
findAndCountAll
({
where
:
{
[
Op
.
and
]:
[{
date
:
{
[
Op
.
eq
]:
start
}
},
{
userId
:
userId
},
{
done
:
false
}]
}
})
check
=
await
Todo
.
findAndCountAll
({
where
:
{
[
Op
.
and
]:
[{
date
:
{
[
Op
.
eq
]:
start
}
},
{
userId
:
userId
},
{
done
:
true
}]
},
order
:
[[
'
updatedAt
'
,
"
DESC
"
]]
})
const
check
=
await
Todo
.
findAndCountAll
({
where
:
{
[
Op
.
and
]:
[{
date
:
{
[
Op
.
eq
]:
start
}
},
{
userId
:
userId
},
{
done
:
true
}]
}
})
let
total
=
nonCheck
.
count
+
check
.
count
let
total
=
nonCheck
.
count
+
check
.
count
check
.
rows
.
forEach
(
el
=>
nonCheck
.
rows
.
push
(
el
.
dataValues
))
if
(
total
!==
0
)
percent
=
Math
.
round
((
check
.
count
/
total
)
*
100
)
console
.
log
(
"
non
"
,
nonCheck
)
if
(
total
===
0
)
percent
=
0
if
(
nonCheck
.
count
<
3
)
check
.
rows
.
forEach
(
el
=>
nonCheck
.
rows
.
push
(
el
.
dataValues
))
else
percent
=
Math
.
round
((
check
.
count
/
total
)
*
100
)
return
res
.
json
({
percent
:
percent
,
list
:
nonCheck
.
rows
.
slice
(
0
,
3
)
})
return
res
.
json
({
percent
:
percent
,
list
:
nonCheck
.
rows
})
}
}
}
catch
(
error
)
{
}
catch
(
error
)
{
return
res
.
status
(
500
).
send
(
error
.
message
||
"
todo 가져오는 중 에러 발생
"
)
return
res
.
status
(
500
).
send
(
error
.
message
||
"
todo 가져오는 중 에러 발생
"
)
...
@@ -75,9 +86,10 @@ const edit = async (req, res) => {
...
@@ -75,9 +86,10 @@ const edit = async (req, res) => {
let
updated
=
null
let
updated
=
null
const
userId
=
req
.
userId
const
userId
=
req
.
userId
const
{
todoId
}
=
req
.
query
const
{
todoId
}
=
req
.
query
const
{
todoTitle
,
todoDate
}
=
req
.
body
const
{
todoTitle
,
todoDate
,
done
}
=
req
.
body
if
(
todoTitle
)
updated
=
await
Todo
.
update
({
title
:
todoTitle
,
date
:
todoDate
},
{
where
:
{
[
Op
.
and
]:
[{
id
:
todoId
},
{
userId
:
userId
}]
}
})
if
(
todoTitle
)
updated
=
await
Todo
.
update
({
title
:
todoTitle
,
date
:
todoDate
},
{
where
:
{
[
Op
.
and
]:
[{
id
:
todoId
},
{
userId
:
userId
}]
}
})
else
updated
=
await
Todo
.
update
({
date
:
todoDate
},
{
where
:
{
[
Op
.
and
]:
[{
id
:
todoId
},
{
userId
:
userId
}]
}
})
else
if
(
todoDate
)
updated
=
await
Todo
.
update
({
date
:
todoDate
},
{
where
:
{
[
Op
.
and
]:
[{
id
:
todoId
},
{
userId
:
userId
}]
}
})
else
updated
=
await
Todo
.
update
({
done
:
!
done
},
{
where
:
{
[
Op
.
and
]:
[{
id
:
todoId
},
{
userId
:
userId
}]
}
})
if
(
!
updated
)
throw
new
Error
(
"
해당 todo의 일부 정보를 수정하는데 실패하였습니다.
"
)
if
(
!
updated
)
throw
new
Error
(
"
해당 todo의 일부 정보를 수정하는데 실패하였습니다.
"
)
else
return
res
.
send
(
200
)
else
return
res
.
send
(
200
)
}
catch
(
error
)
{
}
catch
(
error
)
{
...
@@ -107,22 +119,22 @@ const getParams = async (req, res, next) => {
...
@@ -107,22 +119,22 @@ const getParams = async (req, res, next) => {
}
}
}
}
const
send
=
async
(
req
,
res
)
=>
{
function
countInList
(
list
)
{
try
{
const
countList
=
list
.
reduce
((
acc
,
cur
)
=>
{
const
result
=
req
.
todoOne
||
req
.
todoList
const
findIdx
=
acc
.
findIndex
(
el
=>
el
.
date
===
cur
.
dataValues
.
date
)
return
res
.
json
(
result
)
if
(
findIdx
===
-
1
)
acc
.
push
({
date
:
cur
.
dataValues
.
date
,
count
:
1
})
}
catch
(
error
)
{
else
acc
[
findIdx
].
count
+=
1
return
res
.
status
(
500
).
send
(
error
.
message
||
"
todo 가져오는 중 에러 발생
"
)
}
return
acc
},
[])
return
countList
}
}
export
default
{
export
default
{
findbyId
,
findbyDate
,
findbyDate
,
findforPercent
,
findforPercent
,
create
,
create
,
edit
,
edit
,
remove
,
remove
,
getParams
,
getParams
send
}
}
\ No newline at end of file
server/controllers/user.controller.js
View file @
443851bc
...
@@ -17,7 +17,6 @@ const getUser = async (req, res) => {
...
@@ -17,7 +17,6 @@ const getUser = async (req, res) => {
}
}
const
signup
=
async
(
req
,
res
)
=>
{
const
signup
=
async
(
req
,
res
)
=>
{
console
.
log
(
'
server/signup req.body
'
,
req
.
body
)
const
{
userId
,
password
,
userName
,
userStudNum
}
=
req
.
body
;
const
{
userId
,
password
,
userName
,
userStudNum
}
=
req
.
body
;
try
{
try
{
const
findId
=
await
User
.
findOne
({
where
:
{
userID
:
userId
}
});
const
findId
=
await
User
.
findOne
({
where
:
{
userID
:
userId
}
});
...
@@ -39,7 +38,6 @@ const signup = async (req, res) => {
...
@@ -39,7 +38,6 @@ const signup = async (req, res) => {
}
}
const
login
=
async
(
req
,
res
)
=>
{
const
login
=
async
(
req
,
res
)
=>
{
console
.
log
(
'
server/login req.body
'
,
req
.
body
)
const
{
userId
,
password
}
=
req
.
body
;
const
{
userId
,
password
}
=
req
.
body
;
try
{
try
{
const
user
=
await
User
.
scope
(
"
withPassword
"
).
findOne
({
where
:
{
userID
:
userId
}
});
const
user
=
await
User
.
scope
(
"
withPassword
"
).
findOne
({
where
:
{
userID
:
userId
}
});
...
...
server/db/index.js
View file @
443851bc
...
@@ -34,11 +34,6 @@ const Plan = PlanModel(sequelize)
...
@@ -34,11 +34,6 @@ const Plan = PlanModel(sequelize)
Schedule
.
belongsTo
(
User
)
Schedule
.
belongsTo
(
User
)
Subject
.
belongsTo
(
User
)
Subject
.
belongsTo
(
User
)
Todo
.
belongsTo
(
User
)
Todo
.
belongsTo
(
User
)
Subject
.
hasOne
(
Plan
,
{
onDelete
:
"
CASCADE
"
})
Plan
.
belongsTo
(
Subject
)
Plan
.
belongsTo
(
Subject
)
export
{
export
{
...
...
server/routes/plan.route.js
View file @
443851bc
...
@@ -7,6 +7,10 @@ router
...
@@ -7,6 +7,10 @@ router
.
route
(
"
/
"
)
.
route
(
"
/
"
)
.
post
(
planCtrl
.
create
)
.
post
(
planCtrl
.
create
)
router
.
route
(
"
/check/:planId
"
)
.
put
(
planCtrl
.
putCk
)
router
router
.
route
(
"
/:planId
"
)
.
route
(
"
/:planId
"
)
.
get
(
planCtrl
.
getOne
)
.
get
(
planCtrl
.
getOne
)
...
...
server/routes/todo.route.js
View file @
443851bc
...
@@ -9,7 +9,7 @@ router
...
@@ -9,7 +9,7 @@ router
router
router
.
route
(
"
/:userId
"
)
.
route
(
"
/:userId
"
)
.
get
(
todoCtrl
.
findby
Id
,
todoCtrl
.
findbyDate
,
todoCtrl
.
send
)
.
get
(
todoCtrl
.
findby
Date
)
.
post
(
todoCtrl
.
create
)
.
post
(
todoCtrl
.
create
)
.
put
(
todoCtrl
.
edit
)
.
put
(
todoCtrl
.
edit
)
.
delete
(
todoCtrl
.
remove
)
.
delete
(
todoCtrl
.
remove
)
...
...
Prev
1
2
Next
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