Toggle navigation
Toggle navigation
This project
Loading...
Sign in
오인제
/
Tunnel
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
정의왕
2021-12-09 12:54:53 +0900
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
731a579f1e194a0a8a1e5129edf734dc5425129b
731a579f
2 parents
c988a2b8
a7a00ce3
Merge branch 'master' of
http://khuhub.khu.ac.kr/2019102198/Tunnel
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
42 additions
and
10 deletions
tunnel_BE/server/models/post.js
tunnel_BE/server/routes/comment.js
tunnel_BE/server/routes/post.js
turnel_FE/src/component/views/Modal/ContentModal.js
tunnel_BE/server/models/post.js
View file @
731a579
...
...
@@ -35,6 +35,9 @@ module.exports = class Post extends Sequelize.Model {
static
associate
(
db
)
{
db
.
Post
.
belongsTo
(
db
.
User
,{
foreignKey
:
'userid'
,
targetKey
:
'name'
});
<<<<<<<
HEAD
//db.Post.hasMany(db.Post,{foreignKey: 'postid', sourceKey:'id' });
=======
>>>>>>>
a7a00ce3dcec95df5fd17594f215fe752568dfa5
}
};
\ No newline at end of file
...
...
tunnel_BE/server/routes/comment.js
View file @
731a579
...
...
@@ -7,11 +7,16 @@ const {User}=require('../models'); //유저정보 db연결
const
{
Post
}
=
require
(
'../models'
);
//게시물정보 db연결
const
{
Comment
}
=
require
(
'../models'
);
//현재 로그인된 사용자의 게시물 배열 응답
router
.
get
(
'/:boardId
'
,
auth
,(
req
,
res
)
=>
{
router
.
post
(
'/reply
'
,
auth
,(
req
,
res
)
=>
{
Comment
.
findAll
({
<<<<<<<
HEAD
where
:{
postid
:
req
.
params
.
id
},
=======
where
:{
postid
:
req
.
body
.
id
},
>>>>>>>
a7a00ce3dcec95df5fd17594f215fe752568dfa5
order
:
[[
'created_at'
,
'ASC'
]],
})
.
then
((
result
)
=>
{
...
...
@@ -28,15 +33,18 @@ router.get('/:boardId',auth,(req,res)=>{
// }
})
});
//게시물 작성
router
.
post
(
'/:boardId'
,
auth
,(
req
,
res
)
=>
{
router
.
post
(
'/write'
,
auth
,(
req
,
res
)
=>
{
console
.
log
(
req
.
params
.
id
);
try
{
Comment
.
create
({
userid
:
req
.
session
.
name
,
<<<<<<<
HEAD
postid
:
req
.
body
.
id
,
=======
postid
:
req
.
body
.
postid
,
>>>>>>>
a7a00ce3dcec95df5fd17594f215fe752568dfa5
comment
:
req
.
body
.
comment
,
})
console
.
log
(
"게시"
);
...
...
@@ -55,5 +63,9 @@ router.post('/:boardId',auth,(req,res)=>{
*/
});
module
.
exports
=
router
;
\ No newline at end of file
...
...
tunnel_BE/server/routes/post.js
View file @
731a579
...
...
@@ -8,10 +8,13 @@ const {Post}=require('../models'); //게시물정보 db연결
//현재 로그인된 사용자의 게시물 배열 응답
router
.
get
(
'/'
,
auth
,(
req
,
res
)
=>
{
Post
.
findAll
({
// where:{userid: req.session.name},
<<<<<<<
HEAD
// order: [['created_at', 'DESC']],
=======
order
:
[[
'created_at'
,
'DESC'
]],
>>>>>>>
a7a00ce3dcec95df5fd17594f215fe752568dfa5
})
.
then
((
result
)
=>
{
//console.log(result);
...
...
turnel_FE/src/component/views/Modal/ContentModal.js
View file @
731a579
...
...
@@ -7,8 +7,8 @@ import '../style/ContentModal.scss'
function
ContentModal
({
element
})
{
const
[
viewComment
,
setviewComment
]
=
useState
([]);
useEffect
(()
=>
{
Axios
.
get
(
'/api/comment/'
+
element
.
id
).
then
((
response
)
=>
{
setviewComment
(
response
.
data
);
Axios
.
post
(
'/api/comment/reply'
,{
id
:
element
.
id
}
).
then
((
response
)
=>
{
setviewComment
(
response
.
data
);
})
},[
viewComment
])
...
...
@@ -17,14 +17,24 @@ function ContentModal({element}) {
setOpen
(
false
);
}
const
[
open
,
setOpen
]
=
useState
(
false
)
<<<<<<<
HEAD
const
[
BoardComment
,
setBoardComment
]
=
useState
(
''
)
=======
const
[
BoardComment
,
setBoardComment
]
=
useState
(
""
)
>>>>>>>
a7a00ce3dcec95df5fd17594f215fe752568dfa5
const
onCommentHandler
=
(
event
)
=>
{
setBoardComment
(
event
.
currentTarget
.
value
)
console
.
log
(
BoardComment
)
}
const
onSubmitHandler
=
()
=>
{
<<<<<<<
HEAD
Axios
.
post
(
`/api/comment
${
element
.
id
}
`
,{
content
:
BoardComment
=======
Axios
.
post
(
'/api/comment/write'
,{
postid
:
element
.
id
,
comment
:
BoardComment
>>>>>>>
a7a00ce3dcec95df5fd17594f215fe752568dfa5
})
.
then
((
res
)
=>
{
if
(
res
.
status
===
200
){
...
...
@@ -54,15 +64,19 @@ function ContentModal({element}) {
<
/Modal.Description
>
<
/Modal.Content
>
<
Modal
.
Content
>
{
viewComment
&&
viewComment
.
map
(
elem
=>
{
{
viewComment
&&
viewComment
.
map
(
elem
=>
{
return
<
div
className
=
"ui segment"
>
<<<<<<<
HEAD
<
h2
>
{
elem
.
id
}
<
/h2
>
=======
<
h2
>
{
elem
.
userid
}
<
/h2
>
>>>>>>>
a7a00ce3dcec95df5fd17594f215fe752568dfa5
<
h4
>
{
elem
.
comment
}
<
/h4
>
<
/div>
}
)}
)}
<
/Modal.Content
>
<
Modal
.
Actions
>
<
Comment
>
<
Comment
>
<
Form
reply
>
<
Form
.
TextArea
value
=
{
BoardComment
}
onChange
=
{
onCommentHandler
}
/
>
<
div
onClick
=
{
handleClose
}
>
...
...
Please
register
or
login
to post a comment