Merge branch 'master' of http://khuhub.khu.ac.kr/2019102198/Tunnel
Showing
4 changed files
with
38 additions
and
6 deletions
... | @@ -35,6 +35,9 @@ module.exports = class Post extends Sequelize.Model { | ... | @@ -35,6 +35,9 @@ module.exports = class Post extends Sequelize.Model { |
35 | 35 | ||
36 | static associate(db) { | 36 | static associate(db) { |
37 | db.Post.belongsTo(db.User,{foreignKey: 'userid', targetKey:'name' }); | 37 | db.Post.belongsTo(db.User,{foreignKey: 'userid', targetKey:'name' }); |
38 | +<<<<<<< HEAD | ||
38 | //db.Post.hasMany(db.Post,{foreignKey: 'postid', sourceKey:'id' }); | 39 | //db.Post.hasMany(db.Post,{foreignKey: 'postid', sourceKey:'id' }); |
40 | +======= | ||
41 | +>>>>>>> a7a00ce3dcec95df5fd17594f215fe752568dfa5 | ||
39 | } | 42 | } |
40 | }; | 43 | }; |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -7,11 +7,16 @@ const {User}=require('../models'); //유저정보 db연결 | ... | @@ -7,11 +7,16 @@ const {User}=require('../models'); //유저정보 db연결 |
7 | const {Post}=require('../models'); //게시물정보 db연결 | 7 | const {Post}=require('../models'); //게시물정보 db연결 |
8 | const {Comment}=require('../models'); | 8 | const {Comment}=require('../models'); |
9 | 9 | ||
10 | + | ||
10 | //현재 로그인된 사용자의 게시물 배열 응답 | 11 | //현재 로그인된 사용자의 게시물 배열 응답 |
11 | -router.get('/:boardId',auth,(req,res)=>{ | 12 | +router.post('/reply',auth,(req,res)=>{ |
12 | 13 | ||
13 | Comment.findAll({ | 14 | Comment.findAll({ |
15 | +<<<<<<< HEAD | ||
14 | where:{postid: req.params.id}, | 16 | where:{postid: req.params.id}, |
17 | +======= | ||
18 | + where:{postid: req.body.id}, | ||
19 | +>>>>>>> a7a00ce3dcec95df5fd17594f215fe752568dfa5 | ||
15 | order: [['created_at', 'ASC']], | 20 | order: [['created_at', 'ASC']], |
16 | }) | 21 | }) |
17 | .then((result)=>{ | 22 | .then((result)=>{ |
... | @@ -29,14 +34,17 @@ router.get('/:boardId',auth,(req,res)=>{ | ... | @@ -29,14 +34,17 @@ router.get('/:boardId',auth,(req,res)=>{ |
29 | }) | 34 | }) |
30 | }); | 35 | }); |
31 | 36 | ||
32 | - | ||
33 | - | ||
34 | //게시물 작성 | 37 | //게시물 작성 |
35 | -router.post('/:boardId',auth,(req,res)=>{ | 38 | +router.post('/write',auth,(req,res)=>{ |
39 | + console.log(req.params.id); | ||
36 | try{ | 40 | try{ |
37 | Comment.create({ | 41 | Comment.create({ |
38 | userid : req.session.name, | 42 | userid : req.session.name, |
43 | +<<<<<<< HEAD | ||
39 | postid : req.body.id, | 44 | postid : req.body.id, |
45 | +======= | ||
46 | + postid : req.body.postid, | ||
47 | +>>>>>>> a7a00ce3dcec95df5fd17594f215fe752568dfa5 | ||
40 | comment : req.body.comment, | 48 | comment : req.body.comment, |
41 | }) | 49 | }) |
42 | console.log("게시"); | 50 | console.log("게시"); |
... | @@ -56,4 +64,8 @@ router.post('/:boardId',auth,(req,res)=>{ | ... | @@ -56,4 +64,8 @@ router.post('/:boardId',auth,(req,res)=>{ |
56 | }); | 64 | }); |
57 | 65 | ||
58 | 66 | ||
67 | + | ||
68 | + | ||
69 | + | ||
70 | + | ||
59 | module.exports = router; | 71 | module.exports = router; |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -8,10 +8,13 @@ const {Post}=require('../models'); //게시물정보 db연결 | ... | @@ -8,10 +8,13 @@ const {Post}=require('../models'); //게시물정보 db연결 |
8 | 8 | ||
9 | //현재 로그인된 사용자의 게시물 배열 응답 | 9 | //현재 로그인된 사용자의 게시물 배열 응답 |
10 | router.get('/',auth,(req,res)=>{ | 10 | router.get('/',auth,(req,res)=>{ |
11 | - | ||
12 | Post.findAll({ | 11 | Post.findAll({ |
13 | // where:{userid: req.session.name}, | 12 | // where:{userid: req.session.name}, |
13 | +<<<<<<< HEAD | ||
14 | // order: [['created_at', 'DESC']], | 14 | // order: [['created_at', 'DESC']], |
15 | +======= | ||
16 | + order: [['created_at', 'DESC']], | ||
17 | +>>>>>>> a7a00ce3dcec95df5fd17594f215fe752568dfa5 | ||
15 | }) | 18 | }) |
16 | .then((result)=>{ | 19 | .then((result)=>{ |
17 | //console.log(result); | 20 | //console.log(result); | ... | ... |
... | @@ -7,7 +7,7 @@ import '../style/ContentModal.scss' | ... | @@ -7,7 +7,7 @@ import '../style/ContentModal.scss' |
7 | function ContentModal({element}) { | 7 | function ContentModal({element}) { |
8 | const [viewComment,setviewComment] = useState([]); | 8 | const [viewComment,setviewComment] = useState([]); |
9 | useEffect(()=>{ | 9 | useEffect(()=>{ |
10 | - Axios.get('/api/comment/'+element.id).then((response)=>{ | 10 | + Axios.post('/api/comment/reply',{id : element.id}).then((response)=>{ |
11 | setviewComment(response.data); | 11 | setviewComment(response.data); |
12 | }) | 12 | }) |
13 | },[viewComment]) | 13 | },[viewComment]) |
... | @@ -17,14 +17,24 @@ function ContentModal({element}) { | ... | @@ -17,14 +17,24 @@ function ContentModal({element}) { |
17 | setOpen(false); | 17 | setOpen(false); |
18 | } | 18 | } |
19 | const [open, setOpen] = useState(false) | 19 | const [open, setOpen] = useState(false) |
20 | +<<<<<<< HEAD | ||
20 | const [BoardComment, setBoardComment] = useState('') | 21 | const [BoardComment, setBoardComment] = useState('') |
22 | +======= | ||
23 | + const [BoardComment, setBoardComment] = useState("") | ||
24 | +>>>>>>> a7a00ce3dcec95df5fd17594f215fe752568dfa5 | ||
21 | const onCommentHandler = (event) => { | 25 | const onCommentHandler = (event) => { |
22 | setBoardComment(event.currentTarget.value) | 26 | setBoardComment(event.currentTarget.value) |
23 | console.log(BoardComment) | 27 | console.log(BoardComment) |
24 | } | 28 | } |
25 | const onSubmitHandler = () => { | 29 | const onSubmitHandler = () => { |
30 | +<<<<<<< HEAD | ||
26 | Axios.post(`/api/comment${element.id}`,{ | 31 | Axios.post(`/api/comment${element.id}`,{ |
27 | content: BoardComment | 32 | content: BoardComment |
33 | +======= | ||
34 | + Axios.post('/api/comment/write',{ | ||
35 | + postid: element.id, | ||
36 | + comment: BoardComment | ||
37 | +>>>>>>> a7a00ce3dcec95df5fd17594f215fe752568dfa5 | ||
28 | }) | 38 | }) |
29 | .then((res)=>{ | 39 | .then((res)=>{ |
30 | if(res.status === 200){ | 40 | if(res.status === 200){ |
... | @@ -56,7 +66,11 @@ function ContentModal({element}) { | ... | @@ -56,7 +66,11 @@ function ContentModal({element}) { |
56 | <Modal.Content> | 66 | <Modal.Content> |
57 | {viewComment&&viewComment.map(elem =>{ | 67 | {viewComment&&viewComment.map(elem =>{ |
58 | return <div className="ui segment"> | 68 | return <div className="ui segment"> |
69 | +<<<<<<< HEAD | ||
59 | <h2>{elem.id}</h2> | 70 | <h2>{elem.id}</h2> |
71 | +======= | ||
72 | + <h2>{elem.userid}</h2> | ||
73 | +>>>>>>> a7a00ce3dcec95df5fd17594f215fe752568dfa5 | ||
60 | <h4>{elem.comment}</h4> | 74 | <h4>{elem.comment}</h4> |
61 | </div>} | 75 | </div>} |
62 | )} | 76 | )} | ... | ... |
-
Please register or login to post a comment