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:53:09 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c988a2b8be1449f70784e483f2f634dbdc247adc
c988a2b8
1 parent
fea55b99
Fix conflict
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
22 additions
and
30 deletions
tunnel_BE/server/models/comment.js
tunnel_BE/server/models/post.js
tunnel_BE/server/routes/comment.js
tunnel_BE/server/routes/post.js
turnel_FE/src/component/views/Board/Board.js
turnel_FE/src/component/views/Modal/BoardModal.js
turnel_FE/src/component/views/Modal/ContentModal.js
turnel_FE/src/component/views/style/MainPage.scss
turnel_FE/src/component/views/style/RegisterPage.scss
tunnel_BE/server/models/comment.js
View file @
c988a2b
...
...
@@ -3,6 +3,10 @@ const Sequelize = require('sequelize');
module
.
exports
=
class
Comment
extends
Sequelize
.
Model
{
static
init
(
sequelize
)
{
return
super
.
init
({
postid
:{
type
:
Sequelize
.
INTEGER
,
allowNull
:
false
,
},
userid
:{
type
:
Sequelize
.
STRING
(
30
),
allowNull
:
false
,
...
...
@@ -31,6 +35,6 @@ module.exports = class Comment extends Sequelize.Model {
static
associate
(
db
)
{
db
.
Comment
.
belongsTo
(
db
.
Post
,{
foreignKey
:
'postid'
,
targetKey
:
'id'
});
//
db.Comment.belongsTo(db.Post,{foreignKey: 'postid', targetKey:'id' });
}
};
\ No newline at end of file
...
...
tunnel_BE/server/models/post.js
View file @
c988a2b
...
...
@@ -35,6 +35,6 @@ module.exports = class Post extends Sequelize.Model {
static
associate
(
db
)
{
db
.
Post
.
belongsTo
(
db
.
User
,{
foreignKey
:
'userid'
,
targetKey
:
'name'
});
db
.
Post
.
hasMany
(
db
.
Post
,{
foreignKey
:
'postid'
,
sourceKey
:
'id'
});
//
db.Post.hasMany(db.Post,{foreignKey: 'postid', sourceKey:'id' });
}
};
\ No newline at end of file
...
...
tunnel_BE/server/routes/comment.js
View file @
c988a2b
...
...
@@ -11,7 +11,7 @@ const {Comment}=require('../models');
router
.
get
(
'/:boardId'
,
auth
,(
req
,
res
)
=>
{
Comment
.
findAll
({
where
:{
postid
:
req
.
params
.
boardI
d
},
where
:{
postid
:
req
.
params
.
i
d
},
order
:
[[
'created_at'
,
'ASC'
]],
})
.
then
((
result
)
=>
{
...
...
@@ -36,7 +36,7 @@ router.post('/:boardId',auth,(req,res)=>{
try
{
Comment
.
create
({
userid
:
req
.
session
.
name
,
postid
:
req
.
params
.
boardI
d
,
postid
:
req
.
body
.
i
d
,
comment
:
req
.
body
.
comment
,
})
console
.
log
(
"게시"
);
...
...
tunnel_BE/server/routes/post.js
View file @
c988a2b
...
...
@@ -10,8 +10,8 @@ const {Post}=require('../models'); //게시물정보 db연결
router
.
get
(
'/'
,
auth
,(
req
,
res
)
=>
{
Post
.
findAll
({
where
:{
userid
:
req
.
session
.
name
},
order
:
[[
'created_at'
,
'DESC'
]],
//
where:{userid: req.session.name},
//
order: [['created_at', 'DESC']],
})
.
then
((
result
)
=>
{
//console.log(result);
...
...
turnel_FE/src/component/views/Board/Board.js
View file @
c988a2b
import
Axios
from
'axios'
;
import
React
,
{
useState
,
useEffect
}
from
'react'
;
import
'../style/Board.scss'
import
ReactHtmlParser
from
'react-html-parser'
;
import
BoardModal
from
"../Modal/BoardModal"
;
import
ContentModal
from
'../Modal/ContentModal'
;
...
...
turnel_FE/src/component/views/Modal/BoardModal.js
View file @
c988a2b
...
...
@@ -4,6 +4,7 @@ import { Button, Modal } from 'semantic-ui-react'
import
{
CKEditor
}
from
"@ckeditor/ckeditor5-react"
;
import
ClassicEditor
from
"@ckeditor/ckeditor5-build-classic"
;
function
BoardModal
()
{
const
handleClose
=
(
event
)
=>
{
event
.
preventDefault
();
...
...
turnel_FE/src/component/views/Modal/ContentModal.js
View file @
c988a2b
...
...
@@ -17,22 +17,19 @@ function ContentModal({element}) {
setOpen
(
false
);
}
const
[
open
,
setOpen
]
=
useState
(
false
)
const
[
BoardComment
,
setBoardComment
]
=
useState
({
id
:
null
,
content
:
''
})
const
[
BoardComment
,
setBoardComment
]
=
useState
(
''
)
const
onCommentHandler
=
(
event
)
=>
{
setBoardComment
(
event
.
currentTarget
.
value
)
console
.
log
(
BoardComment
)
}
const
onSubmitHandler
=
()
=>
{
Axios
.
post
(
'/api/comment'
,{
id
:
element
.
id
,
const
onSubmitHandler
=
()
=>
{
Axios
.
post
(
`/api/comment
${
element
.
id
}
`
,{
content
:
BoardComment
})
.
then
((
res
)
=>
{
if
(
res
.
status
===
200
){
alert
(
"댓글 작성을 완료하였습니다."
)
setOpen
(
false
);
}
}).
catch
((
error
)
=>
{
console
.
log
(
error
.
response
)
...
...
@@ -59,18 +56,18 @@ function ContentModal({element}) {
<
Modal
.
Content
>
{
viewComment
&&
viewComment
.
map
(
elem
=>
{
return
<
div
className
=
"ui segment"
>
<
h2
>
{
elem
.
title
}
<
/h2
>
<
h4
>
{
elem
.
c
reated_at
.
slice
(
0
,
10
)
+
" "
+
elem
.
created_at
.
slice
(
11
,
16
)
}
<
/h4
>
<
h2
>
{
elem
.
id
}
<
/h2
>
<
h4
>
{
elem
.
c
omment
}
<
/h4
>
<
/div>
}
)}
<
/Modal.Content
>
<
Modal
.
Actions
>
<
Comment
>
<
Form
reply
>
<
Form
.
TextArea
onChange
=
{
onCommentHandler
}
/
>
<
Form
.
TextArea
value
=
{
BoardComment
}
onChange
=
{
onCommentHandler
}
/
>
<
div
onClick
=
{
handleClose
}
>
<
Button
content
=
'댓글 남기기'
labelPosition
=
'left'
icon
=
'edit'
primary
onSubmit
=
{
onSubmitHandler
}
/
>
<
Button
color
=
'black'
>
닫기
<
/Button
>
<
Button
content
=
'댓글 남기기'
onClick
=
{
onSubmitHandler
}
labelPosition
=
'left'
icon
=
'edit'
primary
/>
<
Button
onClick
=
{
handleClose
}
color
=
'black'
>
닫기
<
/Button
>
<
/div
>
<
/Form
>
<
/Comment
>
...
...
turnel_FE/src/component/views/style/MainPage.scss
View file @
c988a2b
...
...
@@ -9,7 +9,7 @@
display
:
flex
;
flex-direction
:
row
;
height
:
70px
;
width
:
100%
;
.title
{
display
:
flex
;
justify-content
:
center
;
...
...
turnel_FE/src/component/views/style/RegisterPage.scss
View file @
c988a2b
...
...
@@ -43,16 +43,6 @@
color
:
white
;
outline
:
none
;
}
.dropdown
{
width
:
75%
;
padding
:
15px
.8em
.8em
;
background-color
:
transparent
;
border
:
2px
solid
white
;
border-radius
:
30px
;
font-size
:
18px
;
color
:
white
;
outline
:
none
;
}
label
{
position
:
absolute
;
...
...
Please
register
or
login
to post a comment