Showing
2 changed files
with
20 additions
and
7 deletions
... | @@ -26,6 +26,7 @@ router.get('/products', function (req, res) { | ... | @@ -26,6 +26,7 @@ router.get('/products', function (req, res) { |
26 | }); | 26 | }); |
27 | 27 | ||
28 | router.get('/categories/write', loginRequired, function (req, res) { | 28 | router.get('/categories/write', loginRequired, function (req, res) { |
29 | + console.log('??'); | ||
29 | res.render('category/form', { categories: '' }); | 30 | res.render('category/form', { categories: '' }); |
30 | }); | 31 | }); |
31 | 32 | ||
... | @@ -35,7 +36,7 @@ router.post('/categories/write', loginRequired, function (req, res) { | ... | @@ -35,7 +36,7 @@ router.post('/categories/write', loginRequired, function (req, res) { |
35 | description: req.body.description, | 36 | description: req.body.description, |
36 | username: req.user.username, | 37 | username: req.user.username, |
37 | }); | 38 | }); |
38 | - //이 아래는 수정되지 않았음 | 39 | + // |
39 | var validationError = category.validateSync(); | 40 | var validationError = category.validateSync(); |
40 | if (validationError) { | 41 | if (validationError) { |
41 | res.send(validationError); | 42 | res.send(validationError); |
... | @@ -44,11 +45,11 @@ router.post('/categories/write', loginRequired, function (req, res) { | ... | @@ -44,11 +45,11 @@ router.post('/categories/write', loginRequired, function (req, res) { |
44 | res.redirect('/categori/products'); | 45 | res.redirect('/categori/products'); |
45 | }); | 46 | }); |
46 | } | 47 | } |
47 | - //이 위는 수정되지 않았음 | 48 | + // |
48 | }); | 49 | }); |
49 | 50 | ||
50 | router.get('/products/detail/:id', function (req, res) { | 51 | router.get('/products/detail/:id', function (req, res) { |
51 | - //url 에서 변수 값을 받아올떈 req.params.id 로 받아온다 | 52 | + //url 에서 변수 값을 받아올때 req.params.id 로 받아온다 |
52 | var word = req.query.keyword; | 53 | var word = req.query.keyword; |
53 | CategoriModel.findOne({ _id: req.params.id }, function (err, product) { | 54 | CategoriModel.findOne({ _id: req.params.id }, function (err, product) { |
54 | var video = []; | 55 | var video = []; |
... | @@ -59,7 +60,11 @@ router.get('/products/detail/:id', function (req, res) { | ... | @@ -59,7 +60,11 @@ router.get('/products/detail/:id', function (req, res) { |
59 | var videos = []; // 비디오 목록을 담는 임시 배열 | 60 | var videos = []; // 비디오 목록을 담는 임시 배열 |
60 | for (var j in myVideo) { | 61 | for (var j in myVideo) { |
61 | if (product.title == myVideo[j].categori) { | 62 | if (product.title == myVideo[j].categori) { |
62 | - videos.push(myVideo[j].title); | 63 | + var k = { |
64 | + title: myVideo[j].title, | ||
65 | + id: myVideo[j]._id, | ||
66 | + }; | ||
67 | + videos.push(k); | ||
63 | } | 68 | } |
64 | } | 69 | } |
65 | if (videos.length != 0) { | 70 | if (videos.length != 0) { |
... | @@ -112,7 +117,7 @@ router.get('/products/detail/:id', function (req, res) { | ... | @@ -112,7 +117,7 @@ router.get('/products/detail/:id', function (req, res) { |
112 | }); | 117 | }); |
113 | }); | 118 | }); |
114 | } else { | 119 | } else { |
115 | - //console.log(item[0]); | 120 | + console.log(mitem); |
116 | res.render('category/productsDetail', { | 121 | res.render('category/productsDetail', { |
117 | product: product, | 122 | product: product, |
118 | comments: comments, | 123 | comments: comments, |
... | @@ -145,7 +150,7 @@ router.post('/products/detail/:id', loginRequired, function (req, res) { | ... | @@ -145,7 +150,7 @@ router.post('/products/detail/:id', loginRequired, function (req, res) { |
145 | } | 150 | } |
146 | count++; | 151 | count++; |
147 | } | 152 | } |
148 | - res.redirect('/categori/products'); | 153 | + res.redirect('/categori/products/detail/' + req.params.id); |
149 | }); | 154 | }); |
150 | 155 | ||
151 | router.get('/products/edit/:id', loginRequired, function (req, res) { | 156 | router.get('/products/edit/:id', loginRequired, function (req, res) { |
... | @@ -193,6 +198,14 @@ router.get('/products/delete/:id', function (req, res) { | ... | @@ -193,6 +198,14 @@ router.get('/products/delete/:id', function (req, res) { |
193 | }); | 198 | }); |
194 | }); | 199 | }); |
195 | 200 | ||
201 | +router.get('/products/detail/delete/:id', function (req, res) { | ||
202 | + VideoModel.findOne({ _id: req.params.id }, function (err, products) { | ||
203 | + VideoModel.deleteMany({ _id: products }, function (err) { | ||
204 | + res.redirect('/categori/products/'); | ||
205 | + }); | ||
206 | + }); | ||
207 | +}); | ||
208 | + | ||
196 | router.post('/products/ajax_comment/insert', function (req, res) { | 209 | router.post('/products/ajax_comment/insert', function (req, res) { |
197 | var comment = new CategoriModel({ | 210 | var comment = new CategoriModel({ |
198 | content: req.body.content, | 211 | content: req.body.content, | ... | ... |
... | @@ -30,6 +30,6 @@ | ... | @@ -30,6 +30,6 @@ |
30 | <% }); %> | 30 | <% }); %> |
31 | </table> | 31 | </table> |
32 | 32 | ||
33 | - <a href="categories/write" class="btn btn-primary">작성하기</a> | 33 | + <a href="/categori/categories/write" class="btn btn-primary">작성하기</a> |
34 | 34 | ||
35 | <% include ../includes/footer.ejs %> | 35 | <% include ../includes/footer.ejs %> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment