이승윤

feat: 현재 카테고리에 있는 영상 목록 보여주기 기능

...@@ -16,7 +16,7 @@ router.get('/', function (req, res) { ...@@ -16,7 +16,7 @@ router.get('/', function (req, res) {
16 } 16 }
17 if (videos.length != 0) { 17 if (videos.length != 0) {
18 // 빈 배열 체크 18 // 빈 배열 체크
19 - console.log(videos); 19 + //console.log(videos);
20 var items = { 20 var items = {
21 category: category[i], 21 category: category[i],
22 videos: videos, 22 videos: videos,
......
...@@ -54,6 +54,22 @@ router.get('/products/detail/:id', function (req, res) { ...@@ -54,6 +54,22 @@ router.get('/products/detail/:id', function (req, res) {
54 var video = []; 54 var video = [];
55 //제품정보를 받고 그안에서 댓글을 받아온다. 55 //제품정보를 받고 그안에서 댓글을 받아온다.
56 CategoriModel.find({ product_id: req.params.id }, function (err, comments) { 56 CategoriModel.find({ product_id: req.params.id }, function (err, comments) {
57 + VideoModel.find(function (err, myVideo) {
58 + var mitem = []; // 카테고리별 비디오 목록을 담아두는 배열
59 + var videos = []; // 비디오 목록을 담는 임시 배열
60 + for (var j in myVideo) {
61 + if (product.title == myVideo[j].categori) {
62 + videos.push(myVideo[j].title);
63 + }
64 + }
65 + if (videos.length != 0) {
66 + // 빈 배열 체크
67 + //console.log(videos);
68 + var items = videos;
69 + mitem.push(items);
70 + }
71 + //console.log(item[2].category.title);
72 + //console.log(item[2].videos);
57 if (word != null) { 73 if (word != null) {
58 var count = 0; 74 var count = 0;
59 youtube.addParam('order', 'rating'); // 평점 순으로 정렬 75 youtube.addParam('order', 'rating'); // 평점 순으로 정렬
...@@ -61,7 +77,7 @@ router.get('/products/detail/:id', function (req, res) { ...@@ -61,7 +77,7 @@ router.get('/products/detail/:id', function (req, res) {
61 youtube.addParam('videoLicense', 'creativeCommon'); // 크리에이티브 커먼즈 아이템만 불러옴 77 youtube.addParam('videoLicense', 'creativeCommon'); // 크리에이티브 커먼즈 아이템만 불러옴
62 youtube.search(word, limit, function (err, result) { 78 youtube.search(word, limit, function (err, result) {
63 // 검색 실행 79 // 검색 실행
64 - console.log(word); 80 + //console.log(word);
65 if (err) { 81 if (err) {
66 console.log(err); 82 console.log(err);
67 } // 에러일 경우 에러공지하고 빠져나감 83 } // 에러일 경우 에러공지하고 빠져나감
...@@ -92,17 +108,21 @@ router.get('/products/detail/:id', function (req, res) { ...@@ -92,17 +108,21 @@ router.get('/products/detail/:id', function (req, res) {
92 product: product, 108 product: product,
93 comments: comments, 109 comments: comments,
94 videos: video, 110 videos: video,
111 + items: mitem,
95 }); 112 });
96 }); 113 });
97 } else { 114 } else {
115 + //console.log(item[0]);
98 res.render('category/productsDetail', { 116 res.render('category/productsDetail', {
99 product: product, 117 product: product,
100 comments: comments, 118 comments: comments,
101 videos: video, 119 videos: video,
120 + items: mitem,
102 }); 121 });
103 } 122 }
104 }); 123 });
105 }); 124 });
125 + });
106 }); 126 });
107 127
108 router.post('/products/detail/:id', loginRequired, function (req, res) { 128 router.post('/products/detail/:id', loginRequired, function (req, res) {
......
...@@ -3,6 +3,24 @@ ...@@ -3,6 +3,24 @@
3 <div class="panel-heading"> 3 <div class="panel-heading">
4 <%=product.title%> 4 <%=product.title%>
5 </div> 5 </div>
6 + <div style="padding-bottom: 10px">
7 + 작성일 :
8 + <%=product.getDate.year%> -
9 + <%=product.getDate.month%> -
10 + <%=product.getDate.day%>
11 + </div>
12 + <div>
13 + <% var count=0; %>
14 + 보유중인 영상
15 + <% for (var i in items[0]) { %>
16 + <div>
17 + <%=items[0][i]%>
18 + </div>
19 + <%count++;};%>
20 + </div>
21 + <div>
22 + 설명 : <%=product.description%>
23 + </div>
6 <form method="get" action=""> 24 <form method="get" action="">
7 <div class="input-group"> 25 <div class="input-group">
8 <input type="text" class="form-control" placeholder="검색 키워드를 입력하세요!" name="keyword" autocomplete='off'> 26 <input type="text" class="form-control" placeholder="검색 키워드를 입력하세요!" name="keyword" autocomplete='off'>
...@@ -30,18 +48,6 @@ ...@@ -30,18 +48,6 @@
30 <button class="btn btn-primary" style="margin-top: 10px; margin-left: 15px;" >영상담기</button> 48 <button class="btn btn-primary" style="margin-top: 10px; margin-left: 15px;" >영상담기</button>
31 </form> 49 </form>
32 <div class="panel-body"> 50 <div class="panel-body">
33 - <div style="padding-bottom: 10px">
34 - 작성일 :
35 - <%=product.getDate.year%> -
36 - <%=product.getDate.month%> -
37 - <%=product.getDate.day%>
38 - </div>
39 - <% if(product.thumbnail){%>
40 - <p>
41 - <img src="/uploads/<%=product.thumbnail%>" style="max-width: 100%"/>
42 - </p>
43 - <% } %>
44 - <%=product.description%>
45 <!-- 댓글영역 --> 51 <!-- 댓글영역 -->
46 <div> 52 <div>
47 댓글작성하기 53 댓글작성하기
......