최정민

FEAT : 추천 api 로직 추가

-
...@@ -242,5 +242,30 @@ router.post("/review", function (req, res) { ...@@ -242,5 +242,30 @@ router.post("/review", function (req, res) {
242 ); 242 );
243 }); 243 });
244 244
245 +router.get("/recommend", function(req, res){
246 + var sql = "SELECT CAFE_ID FROM REVIEW WHERE PRICE >= ? AND KINDNESS >= ? AND NOISE >= ? AND ACCESSIBILITY >= ?";
247 + var parameter=[5-req.session.user.price, 5-req.session.user.kindness, 5-req.session.user.noise, 5-req.session.user.accessibility];
248 +
249 + connection.query(sql, parameter, function (err, row) {
250 + if(err){
251 + console.log(err);
252 + }else if (row.length > 0) { //만족하는 조건이 한개도없을때
253 + var parameter2=[4-req.session.user.price, 4-req.session.user.kindness, 4-req.session.user.noise, 4-req.session.user.accessibility];
254 +
255 + connection.query(sql, parameter2, function (err, row) {
256 + if(err){
257 + console.log(err);
258 + }else{
259 + console.log(row);
260 + res.render("map", {user: req.session.user});
261 + }
262 + });
263 +
264 + }else{
265 + console.log(row);
266 + res.render("map", {user: req.session.user});
267 + }
268 + });
269 +});
245 270
246 module.exports = router; 271 module.exports = router;
......
1 -{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"__lastAccess":1622135767964,"user":{"email":"kdc9619@khu.ac.kr","picture":"https://lh3.googleusercontent.com/a/AATXAJyP14ipRboJZ8T5-oNS3sRp4CG8wKCEwVABQ5G_=s96-c","nickname":"Meerkat","age":"26","gender":"male"}}
...\ No newline at end of file ...\ No newline at end of file
1 -{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"__lastAccess":1622125471625,"user":{"name":"‍최정민[학생](소프트웨어융합대학 컴퓨터공학과)","email":"cjm2021401@khu.ac.kr","picture":"https://lh3.googleusercontent.com/a/AATXAJzFD3R6CaL2NpysVrfvdGqcQ83vh_wpbN_5hj-0=s96-c"}}
...\ No newline at end of file ...\ No newline at end of file
1 +{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"__lastAccess":1622539560784,"user":{"email":"cjm2021401@khu.ac.kr","picture":"https://lh3.googleusercontent.com/a/AATXAJzFD3R6CaL2NpysVrfvdGqcQ83vh_wpbN_5hj-0=s96-c","nickname":"초보베이시스트","age":"16","gender":"male","price":"2","kindness":"3","noise":"1","accessibility":"4"}}
...\ No newline at end of file ...\ No newline at end of file
1 -{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"__lastAccess":1622139888672,"user":{"email":"cjm104174@gmail.com","picture":"https://lh3.googleusercontent.com/a-/AOh14Gh3nytGsPbviGhkznR8HIwrL6o7xBIoFL08nIeU=s96-c","nickname":"Mayf","age":25,"gender":"male"}}
...\ No newline at end of file ...\ No newline at end of file
...@@ -136,6 +136,11 @@ ...@@ -136,6 +136,11 @@
136 >Logout<span class="sr-only">(current)</span></a 136 >Logout<span class="sr-only">(current)</span></a
137 > 137 >
138 </li> 138 </li>
139 + <li class="nav-item active">
140 + <a class="nav-link" style="color: #ffffff" href="/recommend">Recommend
141 + <span class="sr-only">(current)</span>
142 + </a>
143 + </li>
139 </ul> 144 </ul>
140 </div> 145 </div>
141 </nav> 146 </nav>
......