최정민

FEAT : 추천 api 로직 추가

-
......@@ -242,5 +242,30 @@ router.post("/review", function (req, res) {
);
});
router.get("/recommend", function(req, res){
var sql = "SELECT CAFE_ID FROM REVIEW WHERE PRICE >= ? AND KINDNESS >= ? AND NOISE >= ? AND ACCESSIBILITY >= ?";
var parameter=[5-req.session.user.price, 5-req.session.user.kindness, 5-req.session.user.noise, 5-req.session.user.accessibility];
connection.query(sql, parameter, function (err, row) {
if(err){
console.log(err);
}else if (row.length > 0) { //만족하는 조건이 한개도없을때
var parameter2=[4-req.session.user.price, 4-req.session.user.kindness, 4-req.session.user.noise, 4-req.session.user.accessibility];
connection.query(sql, parameter2, function (err, row) {
if(err){
console.log(err);
}else{
console.log(row);
res.render("map", {user: req.session.user});
}
});
}else{
console.log(row);
res.render("map", {user: req.session.user});
}
});
});
module.exports = router;
......
{"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
{"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
{"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
{"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
......@@ -136,6 +136,11 @@
>Logout<span class="sr-only">(current)</span></a
>
</li>
<li class="nav-item active">
<a class="nav-link" style="color: #ffffff" href="/recommend">Recommend
<span class="sr-only">(current)</span>
</a>
</li>
</ul>
</div>
</nav>
......