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 16:32:01 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
64f56d0be80e59dbac67209284f36af5958dd9f6
64f56d0b
1 parent
7b09fe58
temp
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
19 deletions
DB.txt
tunnel_BE/server/models/comment.js
tunnel_BE/server/models/post.js
tunnel_BE/server/routes/comment.js
tunnel_BE/server/routes/post.js
DB.txt
View file @
64f56d0
...
...
@@ -20,6 +20,7 @@ title TEXT NOT NULL,
post TEXT NOT NULL,
created_at DATETIME NOT NULL DEFAULT now(),
status TINYINT NOT NULL,
mbti CHAR(4) NOT NULL,
PRIMARY KEY(id),
INDEX userid_idx (userid ASC),
CONSTRAINT commenter FOREIGN KEY (userid) REFERENCES tunnel.users (name)
...
...
tunnel_BE/server/models/comment.js
View file @
64f56d0
...
...
@@ -10,7 +10,6 @@ module.exports = class Comment extends Sequelize.Model {
userid
:{
type
:
Sequelize
.
STRING
(
30
),
allowNull
:
false
,
unique
:
true
,
},
comment
:{
type
:
Sequelize
.
TEXT
,
...
...
tunnel_BE/server/models/post.js
View file @
64f56d0
...
...
@@ -20,6 +20,10 @@ module.exports = class Post extends Sequelize.Model {
allowNull
:
false
,
defaultValue
:
Sequelize
.
NOW
,
},
mbti
:{
type
:
Sequelize
.
CHAR
(
4
),
allowNull
:
false
,
}
},{
sequelize
,
timestamps
:
false
,
...
...
@@ -35,9 +39,5 @@ 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 @
64f56d0
...
...
@@ -12,11 +12,9 @@ const {Comment}=require('../models');
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
)
=>
{
...
...
@@ -40,11 +38,8 @@ router.post('/write',auth,(req,res)=>{
try
{
Comment
.
create
({
userid
:
req
.
session
.
name
,
<<<<<<<
HEAD
postid
:
req
.
body
.
id
,
=======
postid
:
req
.
body
.
postid
,
>>>>>>>
a7a00ce3dcec95df5fd17594f215fe752568dfa5
comment
:
req
.
body
.
comment
,
})
console
.
log
(
"게시"
);
...
...
tunnel_BE/server/routes/post.js
View file @
64f56d0
...
...
@@ -9,12 +9,8 @@ const {Post}=require('../models'); //게시물정보 db연결
//현재 로그인된 사용자의 게시물 배열 응답
router
.
get
(
'/'
,
auth
,(
req
,
res
)
=>
{
Post
.
findAll
({
// where:{userid: req.session.name},
<<<<<<<
HEAD
// order: [['created_at', 'DESC']],
=======
where
:{
mbti
:
req
.
session
.
personality
},
order
:
[[
'created_at'
,
'DESC'
]],
>>>>>>>
a7a00ce3dcec95df5fd17594f215fe752568dfa5
})
.
then
((
result
)
=>
{
//console.log(result);
...
...
@@ -40,7 +36,8 @@ router.post('/',auth,(req,res)=>{
userid
:
req
.
session
.
name
,
title
:
req
.
body
.
title
,
post
:
req
.
body
.
content
,
status
:
false
status
:
false
,
mbti
:
req
.
session
.
personality
})
console
.
log
(
"게시"
);
res
.
sendStatus
(
200
);
...
...
Please
register
or
login
to post a comment