최정민

CHORE : 페이지 디자인 수정

-
...@@ -86,21 +86,38 @@ router.get("/login", checkAuthenticated, (req, res) => { ...@@ -86,21 +86,38 @@ router.get("/login", checkAuthenticated, (req, res) => {
86 }); 86 });
87 87
88 router.post("/login", (req, res) => { 88 router.post("/login", (req, res) => {
89 - console.log("구글로그인 성공"); 89 + //입력을 다하였는지
90 + if(!req.body.nickname || !req.body.age || !req.body.gender || !req.body.price || !req.body.kindness || !req.body.accessibility ){
91 + console.log("입력받지 않은 데이터 존재");
92 + return res.render("login", {
93 + user: req.session.user,
94 + message: "need data",
95 + });
96 + }
97 + var set = new Set([req.body.price, req.body.accessibility, req.body.kindness, req.body.noise]);
98 + //db에 동일 닉네임있는지 검사(닉네임은 유일해야함)
90 var sql = " SELECT * FROM USER WHERE NICKNAME=?"; 99 var sql = " SELECT * FROM USER WHERE NICKNAME=?";
91 var parameter = [req.body.nickname]; 100 var parameter = [req.body.nickname];
92 connection.query(sql, parameter, function (err, row) { 101 connection.query(sql, parameter, function (err, row) {
93 if (err) { 102 if (err) {
94 console.log(err); 103 console.log(err);
95 } 104 }
96 - if (row.length > 0) { 105 + else if (row.length > 0) {
97 console.log("동일 닉네임있음"); 106 console.log("동일 닉네임있음");
98 -
99 return res.render("login", { 107 return res.render("login", {
100 user: req.session.user, 108 user: req.session.user,
101 message: "same nickname", 109 message: "same nickname",
102 }); 110 });
103 - } else { 111 + }
112 + //중복순위제
113 + else if (set.size!=4){
114 + console.log("중복된 순위 존재");
115 + return res.render("login", {
116 + user: req.session.user,
117 + message: "wrong preference",
118 + });
119 + }
120 + else {
104 req.session.user.nickname = req.body.nickname; 121 req.session.user.nickname = req.body.nickname;
105 req.session.user.age = req.body.age; 122 req.session.user.age = req.body.age;
106 req.session.user.gender = req.body.gender; 123 req.session.user.gender = req.body.gender;
...@@ -109,24 +126,40 @@ router.post("/login", (req, res) => { ...@@ -109,24 +126,40 @@ router.post("/login", (req, res) => {
109 req.session.user.noise=req.body.noise; 126 req.session.user.noise=req.body.noise;
110 req.session.user.accessibility=req.body.accessibility; 127 req.session.user.accessibility=req.body.accessibility;
111 var sql = 128 var sql =
112 - "INSERT INTO USER(EMAIL,NICKNAME, AGE, GENDER, PICTURE, KINDNESS, NOISE, ACCESSIBILITY) VALUES(?,?,?,?,?,?,?,?)"; 129 + "INSERT INTO USER(EMAIL,NICKNAME, AGE, GENDER) VALUES(?,?,?,?)";
113 var parameter = [ 130 var parameter = [
114 req.session.user.email, 131 req.session.user.email,
115 req.session.user.nickname, 132 req.session.user.nickname,
116 req.session.user.age, 133 req.session.user.age,
117 req.session.user.gender, 134 req.session.user.gender,
135 + ];
136 + connection.query(sql, parameter, function (err) {
137 + if (err) {
138 + console.log(err);
139 + return res.render("/");
140 + } else {
141 + console.log("새로운 user데이터 입력");
142 + }
143 + });
144 + var sql2 =
145 + "INSERT INTO PREFERENCE(NICKNAME, PRICE, KINDNESS, NOISE, ACCESSIBILITY) VALUES(?,?,?,?,?)";
146 + var parameter2 = [
147 + req.session.user.nickname,
118 req.session.user.price, 148 req.session.user.price,
119 req.session.user.kindness, 149 req.session.user.kindness,
120 req.session.user.noise, 150 req.session.user.noise,
121 req.session.user.accessibility 151 req.session.user.accessibility
122 ]; 152 ];
123 - connection.query(sql, parameter, function (err) { 153 + connection.query(sql2, parameter2, function (err) {
124 if (err) { 154 if (err) {
125 console.log(err); 155 console.log(err);
156 + return res.render("/");
126 } else { 157 } else {
127 - console.log("새로운 user데이터 입력"); 158 + console.log("새로운 PREFERENCE데이터 입력");
159 +
128 } 160 }
129 }); 161 });
162 +
130 return res.render("map", { user: req.session.user }); 163 return res.render("map", { user: req.session.user });
131 } 164 }
132 }); 165 });
...@@ -159,6 +192,15 @@ router.get("/logout", function (req, res) { ...@@ -159,6 +192,15 @@ router.get("/logout", function (req, res) {
159 res.redirect("/"); 192 res.redirect("/");
160 }); 193 });
161 194
195 +router.get("/map", function(req, res, next){
196 + if (req.session.user) {
197 + res.render("map", {user: req.session.user});
198 + }
199 + else{
200 + res.render("/")
201 + }
202 +})
203 +
162 router.get("/review/:cafeId", function (req, res) { 204 router.get("/review/:cafeId", function (req, res) {
163 const cafeId = req.params.cafeId; 205 const cafeId = req.params.cafeId;
164 res.render("review", { cafeId: cafeId }); 206 res.render("review", { cafeId: cafeId });
...@@ -200,4 +242,5 @@ router.post("/review", function (req, res) { ...@@ -200,4 +242,5 @@ router.post("/review", function (req, res) {
200 ); 242 );
201 }); 243 });
202 244
245 +
203 module.exports = router; 246 module.exports = router;
......
1 -{"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 ...\ 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
......
...@@ -89,13 +89,14 @@ ...@@ -89,13 +89,14 @@
89 <hr class="my-2" style="background-color: white"> 89 <hr class="my-2" style="background-color: white">
90 <div class="pricing-header px-3 py-1 pt-md-3 pb-md-1 mx-auto text-center"> 90 <div class="pricing-header px-3 py-1 pt-md-3 pb-md-1 mx-auto text-center">
91 <h5 class="display- ">PREFERENCE</h5> 91 <h5 class="display- ">PREFERENCE</h5>
92 + <hr class="my-1" style="background-color: white">
92 <p>카페를 선택할 떄 중요하게 여기는 요소들의 순위를 매겨주세요.</p> 93 <p>카페를 선택할 떄 중요하게 여기는 요소들의 순위를 매겨주세요.</p>
93 - <p>(순위가 중복되면 안됩니다. ex) 가격 1순위, 친절 1순위(X)</p> 94 + <p>[ 순위가 중복되면 안됩니다. ex) 가격 1순위, 친절 1순위(X) ]</p>
94 </div> 95 </div>
95 <div class="text-center"> 96 <div class="text-center">
96 <label for="price_form" class="form-label font-weight-bold" style="margin-right: 15px">가격</label> 97 <label for="price_form" class="form-label font-weight-bold" style="margin-right: 15px">가격</label>
97 <div class="form-check form-check-inline" id="price_form"> 98 <div class="form-check form-check-inline" id="price_form">
98 - <input class="form-check-input" type="radio" name="price" id="price1" value="1"> 99 + <input class="form-check-input" type="radio" name="price" id="price1" value="1" checked>
99 <label class="form-check-label" for="price1">1순위</label> 100 <label class="form-check-label" for="price1">1순위</label>
100 </div> 101 </div>
101 <div class="form-check form-check-inline"> 102 <div class="form-check form-check-inline">
...@@ -118,7 +119,7 @@ ...@@ -118,7 +119,7 @@
118 <label class="form-check-label" for="kindness">1순위</label> 119 <label class="form-check-label" for="kindness">1순위</label>
119 </div> 120 </div>
120 <div class="form-check form-check-inline"> 121 <div class="form-check form-check-inline">
121 - <input class="form-check-input" type="radio" name="kindness" id="kindness2" value="2"> 122 + <input class="form-check-input" type="radio" name="kindness" id="kindness2" value="2" checked>
122 <label class="form-check-label" for="kindness2">2순위</label> 123 <label class="form-check-label" for="kindness2">2순위</label>
123 </div> 124 </div>
124 <div class="form-check form-check-inline"> 125 <div class="form-check form-check-inline">
...@@ -132,7 +133,7 @@ ...@@ -132,7 +133,7 @@
132 133
133 <hr class="my-1" style="background-color: white" /> 134 <hr class="my-1" style="background-color: white" />
134 135
135 - <label for="noise_form" class="form-label font-weight-bold" style="margin-right: 15px"></label> 136 + <label for="noise_form" class="form-label font-weight-bold" style="margin-right: 15px"></label>
136 <div class="form-check form-check-inline" id="noise_form"> 137 <div class="form-check form-check-inline" id="noise_form">
137 <input class="form-check-input" type="radio" name="noise" id="noise1" value="1"> 138 <input class="form-check-input" type="radio" name="noise" id="noise1" value="1">
138 <label class="form-check-label" for="noise">1순위</label> 139 <label class="form-check-label" for="noise">1순위</label>
...@@ -142,7 +143,7 @@ ...@@ -142,7 +143,7 @@
142 <label class="form-check-label" for="kindness2">2순위</label> 143 <label class="form-check-label" for="kindness2">2순위</label>
143 </div> 144 </div>
144 <div class="form-check form-check-inline"> 145 <div class="form-check form-check-inline">
145 - <input class="form-check-input" type="radio" name="noise" id="noise3" value="3" > 146 + <input class="form-check-input" type="radio" name="noise" id="noise3" value="3" checked>
146 <label class="form-check-label" for="noise3">3순위</label> 147 <label class="form-check-label" for="noise3">3순위</label>
147 </div> 148 </div>
148 <div class="form-check form-check-inline"> 149 <div class="form-check form-check-inline">
...@@ -166,7 +167,7 @@ ...@@ -166,7 +167,7 @@
166 <label class="form-check-label" for="accessibility3">3순위</label> 167 <label class="form-check-label" for="accessibility3">3순위</label>
167 </div> 168 </div>
168 <div class="form-check form-check-inline"> 169 <div class="form-check form-check-inline">
169 - <input class="form-check-input" type="radio" name="accessibility" id="accessibility4" value="4" > 170 + <input class="form-check-input" type="radio" name="accessibility" id="accessibility4" value="4" checked>
170 <label class="form-check-label" for="accessibility4">4순위</label> 171 <label class="form-check-label" for="accessibility4">4순위</label>
171 </div> 172 </div>
172 </div> 173 </div>
...@@ -186,6 +187,24 @@ ...@@ -186,6 +187,24 @@
186 ); 187 );
187 </script> 188 </script>
188 <%}%> 189 <%}%>
190 +
191 + <%if (message=='need data'){%>
192 + <script type="text/javascript">
193 + alert(
194 + "입력하시지 않은 정보가 있습니다." +
195 + "모든 정보를 입력해주시길 바라겠습니다."
196 + );
197 + </script>
198 + <%}%>
199 +
200 + <%if (message=='wrong preference'){%>
201 + <script type="text/javascript">
202 + alert(
203 + "중복된 선호도 순위가 있습니다." +
204 + "순위를 겹치지 않게해주세요(ex 1 3 2 4)"
205 + );
206 + </script>
207 + <%}%>
189 </body> 208 </body>
190 <script> 209 <script>
191 function signOut() { 210 function signOut() {
......
...@@ -35,7 +35,10 @@ ...@@ -35,7 +35,10 @@
35 </style> 35 </style>
36 </head> 36 </head>
37 <body> 37 <body>
38 - <nav class="navbar navbar-expand-lg navbar-dark bg-dark"> 38 +<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
39 + <a class="navbar-brand" href="/"
40 + ><img src="/images/home.png" width="40" height="40" alt="" />
41 + </a>
39 <button 42 <button
40 class="navbar-toggler" 43 class="navbar-toggler"
41 type="button" 44 type="button"
...@@ -47,7 +50,10 @@ ...@@ -47,7 +50,10 @@
47 > 50 >
48 <span class="navbar-toggler-icon"></span> 51 <span class="navbar-toggler-icon"></span>
49 </button> 52 </button>
50 - </nav> 53 + <div class="collapse navbar-collapse" id="navbarSupportedContent">
54 + <a class="navbar-brand" href="/"><strong>Home</strong></a>
55 + </div>
56 +</nav>
51 57
52 <div class="pricing-header px-3 py-1 pt-md-3 pb-md-1 mx-auto text-center"> 58 <div class="pricing-header px-3 py-1 pt-md-3 pb-md-1 mx-auto text-center">
53 <h3 class="display-6 font-weight-bold">후기 등록</h3> 59 <h3 class="display-6 font-weight-bold">후기 등록</h3>
...@@ -117,4 +123,6 @@ ...@@ -117,4 +123,6 @@
117 </div> 123 </div>
118 </section> 124 </section>
119 </body> 125 </body>
126 +<script src="/javascripts/bootstrap.js"></script>
127 +<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
120 </html> 128 </html>
...\ No newline at end of file ...\ No newline at end of file
......