최정민

CHORE : 페이지 디자인 수정

-
......@@ -86,21 +86,38 @@ router.get("/login", checkAuthenticated, (req, res) => {
});
router.post("/login", (req, res) => {
console.log("구글로그인 성공");
//입력을 다하였는지
if(!req.body.nickname || !req.body.age || !req.body.gender || !req.body.price || !req.body.kindness || !req.body.accessibility ){
console.log("입력받지 않은 데이터 존재");
return res.render("login", {
user: req.session.user,
message: "need data",
});
}
var set = new Set([req.body.price, req.body.accessibility, req.body.kindness, req.body.noise]);
//db에 동일 닉네임있는지 검사(닉네임은 유일해야함)
var sql = " SELECT * FROM USER WHERE NICKNAME=?";
var parameter = [req.body.nickname];
connection.query(sql, parameter, function (err, row) {
if (err) {
console.log(err);
}
if (row.length > 0) {
else if (row.length > 0) {
console.log("동일 닉네임있음");
return res.render("login", {
user: req.session.user,
message: "same nickname",
});
} else {
}
//중복순위제
else if (set.size!=4){
console.log("중복된 순위 존재");
return res.render("login", {
user: req.session.user,
message: "wrong preference",
});
}
else {
req.session.user.nickname = req.body.nickname;
req.session.user.age = req.body.age;
req.session.user.gender = req.body.gender;
......@@ -109,24 +126,40 @@ router.post("/login", (req, res) => {
req.session.user.noise=req.body.noise;
req.session.user.accessibility=req.body.accessibility;
var sql =
"INSERT INTO USER(EMAIL,NICKNAME, AGE, GENDER, PICTURE, KINDNESS, NOISE, ACCESSIBILITY) VALUES(?,?,?,?,?,?,?,?)";
"INSERT INTO USER(EMAIL,NICKNAME, AGE, GENDER) VALUES(?,?,?,?)";
var parameter = [
req.session.user.email,
req.session.user.nickname,
req.session.user.age,
req.session.user.gender,
];
connection.query(sql, parameter, function (err) {
if (err) {
console.log(err);
return res.render("/");
} else {
console.log("새로운 user데이터 입력");
}
});
var sql2 =
"INSERT INTO PREFERENCE(NICKNAME, PRICE, KINDNESS, NOISE, ACCESSIBILITY) VALUES(?,?,?,?,?)";
var parameter2 = [
req.session.user.nickname,
req.session.user.price,
req.session.user.kindness,
req.session.user.noise,
req.session.user.accessibility
];
connection.query(sql, parameter, function (err) {
connection.query(sql2, parameter2, function (err) {
if (err) {
console.log(err);
return res.render("/");
} else {
console.log("새로운 user데이터 입력");
console.log("새로운 PREFERENCE데이터 입력");
}
});
return res.render("map", { user: req.session.user });
}
});
......@@ -159,6 +192,15 @@ router.get("/logout", function (req, res) {
res.redirect("/");
});
router.get("/map", function(req, res, next){
if (req.session.user) {
res.render("map", {user: req.session.user});
}
else{
res.render("/")
}
})
router.get("/review/:cafeId", function (req, res) {
const cafeId = req.params.cafeId;
res.render("review", { cafeId: cafeId });
......@@ -200,4 +242,5 @@ router.post("/review", function (req, res) {
);
});
module.exports = router;
......
{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"__lastAccess":1622135361726,"user":{"email":"cjm104174@gmail.com","picture":"https://lh3.googleusercontent.com/a-/AOh14Gh3nytGsPbviGhkznR8HIwrL6o7xBIoFL08nIeU=s96-c","nickname":"cjm","age":"19","gender":"male","price":"1","kindness":"2","noise":"3","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
......
......@@ -89,13 +89,14 @@
<hr class="my-2" style="background-color: white">
<div class="pricing-header px-3 py-1 pt-md-3 pb-md-1 mx-auto text-center">
<h5 class="display- ">PREFERENCE</h5>
<hr class="my-1" style="background-color: white">
<p>카페를 선택할 떄 중요하게 여기는 요소들의 순위를 매겨주세요.</p>
<p>(순위가 중복되면 안됩니다. ex) 가격 1순위, 친절 1순위(X)</p>
<p>[ 순위가 중복되면 안됩니다. ex) 가격 1순위, 친절 1순위(X) ]</p>
</div>
<div class="text-center">
<label for="price_form" class="form-label font-weight-bold" style="margin-right: 15px">가격</label>
<div class="form-check form-check-inline" id="price_form">
<input class="form-check-input" type="radio" name="price" id="price1" value="1">
<input class="form-check-input" type="radio" name="price" id="price1" value="1" checked>
<label class="form-check-label" for="price1">1순위</label>
</div>
<div class="form-check form-check-inline">
......@@ -118,7 +119,7 @@
<label class="form-check-label" for="kindness">1순위</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="kindness" id="kindness2" value="2">
<input class="form-check-input" type="radio" name="kindness" id="kindness2" value="2" checked>
<label class="form-check-label" for="kindness2">2순위</label>
</div>
<div class="form-check form-check-inline">
......@@ -132,7 +133,7 @@
<hr class="my-1" style="background-color: white" />
<label for="noise_form" class="form-label font-weight-bold" style="margin-right: 15px"></label>
<label for="noise_form" class="form-label font-weight-bold" style="margin-right: 15px"></label>
<div class="form-check form-check-inline" id="noise_form">
<input class="form-check-input" type="radio" name="noise" id="noise1" value="1">
<label class="form-check-label" for="noise">1순위</label>
......@@ -142,7 +143,7 @@
<label class="form-check-label" for="kindness2">2순위</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="noise" id="noise3" value="3" >
<input class="form-check-input" type="radio" name="noise" id="noise3" value="3" checked>
<label class="form-check-label" for="noise3">3순위</label>
</div>
<div class="form-check form-check-inline">
......@@ -166,7 +167,7 @@
<label class="form-check-label" for="accessibility3">3순위</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" type="radio" name="accessibility" id="accessibility4" value="4" >
<input class="form-check-input" type="radio" name="accessibility" id="accessibility4" value="4" checked>
<label class="form-check-label" for="accessibility4">4순위</label>
</div>
</div>
......@@ -186,6 +187,24 @@
);
</script>
<%}%>
<%if (message=='need data'){%>
<script type="text/javascript">
alert(
"입력하시지 않은 정보가 있습니다." +
"모든 정보를 입력해주시길 바라겠습니다."
);
</script>
<%}%>
<%if (message=='wrong preference'){%>
<script type="text/javascript">
alert(
"중복된 선호도 순위가 있습니다." +
"순위를 겹치지 않게해주세요(ex 1 3 2 4)"
);
</script>
<%}%>
</body>
<script>
function signOut() {
......
......@@ -35,7 +35,10 @@
</style>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
<a class="navbar-brand" href="/"
><img src="/images/home.png" width="40" height="40" alt="" />
</a>
<button
class="navbar-toggler"
type="button"
......@@ -47,7 +50,10 @@
>
<span class="navbar-toggler-icon"></span>
</button>
</nav>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<a class="navbar-brand" href="/"><strong>Home</strong></a>
</div>
</nav>
<div class="pricing-header px-3 py-1 pt-md-3 pb-md-1 mx-auto text-center">
<h3 class="display-6 font-weight-bold">후기 등록</h3>
......@@ -117,4 +123,6 @@
</div>
</section>
</body>
<script src="/javascripts/bootstrap.js"></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
</html>
\ No newline at end of file
......