Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이승윤
/
OpenSource-MyCookBook
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-06-01 16:04:42 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5542303cbd34cc249763c2fd8e2ef443e8c03298
5542303c
1 parent
f754021d
feat: video column 삭제 기능
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
7 deletions
routes/categori.js
views/category/products.ejs
routes/categori.js
View file @
5542303
...
...
@@ -26,6 +26,7 @@ router.get('/products', function (req, res) {
});
router
.
get
(
'/categories/write'
,
loginRequired
,
function
(
req
,
res
)
{
console
.
log
(
'??'
);
res
.
render
(
'category/form'
,
{
categories
:
''
});
});
...
...
@@ -35,7 +36,7 @@ router.post('/categories/write', loginRequired, function (req, res) {
description
:
req
.
body
.
description
,
username
:
req
.
user
.
username
,
});
//
이 아래는 수정되지 않았음
//
var
validationError
=
category
.
validateSync
();
if
(
validationError
)
{
res
.
send
(
validationError
);
...
...
@@ -44,11 +45,11 @@ router.post('/categories/write', loginRequired, function (req, res) {
res
.
redirect
(
'/categori/products'
);
});
}
//
이 위는 수정되지 않았음
//
});
router
.
get
(
'/products/detail/:id'
,
function
(
req
,
res
)
{
//url 에서 변수 값을 받아올
떈
req.params.id 로 받아온다
//url 에서 변수 값을 받아올
때
req.params.id 로 받아온다
var
word
=
req
.
query
.
keyword
;
CategoriModel
.
findOne
({
_id
:
req
.
params
.
id
},
function
(
err
,
product
)
{
var
video
=
[];
...
...
@@ -59,7 +60,11 @@ router.get('/products/detail/:id', function (req, res) {
var
videos
=
[];
// 비디오 목록을 담는 임시 배열
for
(
var
j
in
myVideo
)
{
if
(
product
.
title
==
myVideo
[
j
].
categori
)
{
videos
.
push
(
myVideo
[
j
].
title
);
var
k
=
{
title
:
myVideo
[
j
].
title
,
id
:
myVideo
[
j
].
_id
,
};
videos
.
push
(
k
);
}
}
if
(
videos
.
length
!=
0
)
{
...
...
@@ -112,7 +117,7 @@ router.get('/products/detail/:id', function (req, res) {
});
});
}
else
{
//console.log(item[0]
);
console
.
log
(
mitem
);
res
.
render
(
'category/productsDetail'
,
{
product
:
product
,
comments
:
comments
,
...
...
@@ -145,7 +150,7 @@ router.post('/products/detail/:id', loginRequired, function (req, res) {
}
count
++
;
}
res
.
redirect
(
'/categori/products
'
);
res
.
redirect
(
'/categori/products
/detail/'
+
req
.
params
.
id
);
});
router
.
get
(
'/products/edit/:id'
,
loginRequired
,
function
(
req
,
res
)
{
...
...
@@ -193,6 +198,14 @@ router.get('/products/delete/:id', function (req, res) {
});
});
router
.
get
(
'/products/detail/delete/:id'
,
function
(
req
,
res
)
{
VideoModel
.
findOne
({
_id
:
req
.
params
.
id
},
function
(
err
,
products
)
{
VideoModel
.
deleteMany
({
_id
:
products
},
function
(
err
)
{
res
.
redirect
(
'/categori/products/'
);
});
});
});
router
.
post
(
'/products/ajax_comment/insert'
,
function
(
req
,
res
)
{
var
comment
=
new
CategoriModel
({
content
:
req
.
body
.
content
,
...
...
views/category/products.ejs
View file @
5542303
...
...
@@ -30,6 +30,6 @@
<% }); %>
</table>
<a href="categories/write" class="btn btn-primary">작성하기</a>
<a href="
/categori/
categories/write" class="btn btn-primary">작성하기</a>
<% include ../includes/footer.ejs %>
\ No newline at end of file
...
...
Please
register
or
login
to post a comment