Showing
10 changed files
with
124 additions
and
63 deletions
1 | ###초기설정 | 1 | ###초기설정 |
2 | ->####데이터 베이스 설정 | 2 | + |
3 | +> ####데이터 베이스 설정 | ||
4 | +> | ||
3 | > <pre><code> | 5 | > <pre><code> |
4 | > CREATE TABLE USER( | 6 | > CREATE TABLE USER( |
5 | > ID int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, | 7 | > ID int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, |
... | @@ -10,22 +12,25 @@ | ... | @@ -10,22 +12,25 @@ |
10 | > GENDER varchar(32), | 12 | > GENDER varchar(32), |
11 | > PICTURE varchar(128) NOT NULL | 13 | > PICTURE varchar(128) NOT NULL |
12 | > ); | 14 | > ); |
13 | -</code> | 15 | +> </code> |
16 | + | ||
14 | </pre> | 17 | </pre> |
15 | 18 | ||
16 | > <pre><code> | 19 | > <pre><code> |
17 | -> CREATE TABLE COMMENT( | 20 | +> CREATE TABLE REVIEW( |
18 | > ID int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, | 21 | > ID int(10) NOT NULL AUTO_INCREMENT PRIMARY KEY, |
19 | -> CAFE_ID int(10) NOT NULL | 22 | +> CAFE_ID int(10) NOT NULL, |
20 | > PRICE int(10) NOT NULL, | 23 | > PRICE int(10) NOT NULL, |
21 | > KINDNESS int(10) NOT NULL, | 24 | > KINDNESS int(10) NOT NULL, |
22 | > NOISE int(10) NOT NULL, | 25 | > NOISE int(10) NOT NULL, |
23 | > ACCESSIBILITY int(10) NOT NULL | 26 | > ACCESSIBILITY int(10) NOT NULL |
24 | > ); | 27 | > ); |
25 | -</code> | 28 | +> </code> |
29 | + | ||
26 | </pre> | 30 | </pre> |
27 | 31 | ||
28 | ###commit 형식 | 32 | ###commit 형식 |
33 | + | ||
29 | <pre><code> | 34 | <pre><code> |
30 | ##### 제목 - 50자 이내로 요약! | 35 | ##### 제목 - 50자 이내로 요약! |
31 | 36 | ||
... | @@ -52,5 +57,3 @@ | ... | @@ -52,5 +57,3 @@ |
52 | # 제목 첫 글자는 대문자로 작성했나요? | 57 | # 제목 첫 글자는 대문자로 작성했나요? |
53 | </code> | 58 | </code> |
54 | </pre> | 59 | </pre> |
55 | - | ||
56 | - | ... | ... |
... | @@ -14,12 +14,14 @@ const FileStore = require("session-file-store")(session); | ... | @@ -14,12 +14,14 @@ const FileStore = require("session-file-store")(session); |
14 | 14 | ||
15 | router.use(bodyParser.urlencoded({ extended: false })); //url인코딩 x | 15 | router.use(bodyParser.urlencoded({ extended: false })); //url인코딩 x |
16 | router.use(bodyParser.json()); //json방식으로 파싱 | 16 | router.use(bodyParser.json()); //json방식으로 파싱 |
17 | -router.use(session({ | 17 | +router.use( |
18 | - secret: '209', // 암호화 | 18 | + session({ |
19 | - resave: false, | 19 | + secret: "209", // 암호화 |
20 | - saveUninitialized: true, | 20 | + resave: false, |
21 | - store: new FileStore() | 21 | + saveUninitialized: true, |
22 | -})) | 22 | + store: new FileStore(), |
23 | + }) | ||
24 | +); | ||
23 | 25 | ||
24 | var connection = mysql.createConnection({ | 26 | var connection = mysql.createConnection({ |
25 | host: "localhost", | 27 | host: "localhost", |
... | @@ -60,10 +62,10 @@ router.post("/index", (req, res) => { | ... | @@ -60,10 +62,10 @@ router.post("/index", (req, res) => { |
60 | }); | 62 | }); |
61 | 63 | ||
62 | router.get("/login", checkAuthenticated, (req, res) => { | 64 | router.get("/login", checkAuthenticated, (req, res) => { |
63 | - req.session.user =req.user; | 65 | + req.session.user = req.user; |
64 | req.session.user.email = req.user.email; | 66 | req.session.user.email = req.user.email; |
65 | - req.session.user.name=req.user.name; | 67 | + req.session.user.name = req.user.name; |
66 | - req.session.user.picture=req.user.picture; | 68 | + req.session.user.picture = req.user.picture; |
67 | var sql = "SELECT * FROM USER WHERE EMAIL=?"; | 69 | var sql = "SELECT * FROM USER WHERE EMAIL=?"; |
68 | var parameter = [req.session.user.email]; | 70 | var parameter = [req.session.user.email]; |
69 | connection.query(sql, parameter, function (err, row) { | 71 | connection.query(sql, parameter, function (err, row) { |
... | @@ -146,25 +148,18 @@ function checkAuthenticated(req, res, next) { | ... | @@ -146,25 +148,18 @@ function checkAuthenticated(req, res, next) { |
146 | }); | 148 | }); |
147 | } | 149 | } |
148 | 150 | ||
149 | -router.get("/map", (req, res) => { | ||
150 | - if (req.session.user) { | ||
151 | - res.render("map", {user:req.session.user}); | ||
152 | - } | ||
153 | - res.render("map"); | ||
154 | -}); | ||
155 | - | ||
156 | router.get("/logout", function (req, res) { | 151 | router.get("/logout", function (req, res) { |
157 | req.session.destroy(); //세션비우기 | 152 | req.session.destroy(); //세션비우기 |
158 | res.redirect("/"); | 153 | res.redirect("/"); |
159 | }); | 154 | }); |
160 | 155 | ||
161 | -router.get("/comment/:cafeId", function (req, res) { | 156 | +router.get("/review/:cafeId", function (req, res) { |
162 | const cafeId = req.params.cafeId; | 157 | const cafeId = req.params.cafeId; |
163 | - res.render("comment", { cafeId: cafeId }); | 158 | + res.render("review", { cafeId: cafeId }); |
164 | }); | 159 | }); |
165 | 160 | ||
166 | // 카페 후기 등록 | 161 | // 카페 후기 등록 |
167 | -router.post("/comment", function (req, res) { | 162 | +router.post("/review", function (req, res) { |
168 | var cafeId = req.body.cafeId; | 163 | var cafeId = req.body.cafeId; |
169 | var price = req.body.price; | 164 | var price = req.body.price; |
170 | var kindness = req.body.kindness; | 165 | var kindness = req.body.kindness; |
... | @@ -179,11 +174,11 @@ router.post("/comment", function (req, res) { | ... | @@ -179,11 +174,11 @@ router.post("/comment", function (req, res) { |
179 | // 입력받지 않은 데이터가 하나라도 존재 (카페아이디는 후기작성시 자동으로 받아옴) | 174 | // 입력받지 않은 데이터가 하나라도 존재 (카페아이디는 후기작성시 자동으로 받아옴) |
180 | if (!cafeId || !price || !kindness || !noise || !accessibility) { | 175 | if (!cafeId || !price || !kindness || !noise || !accessibility) { |
181 | console.log("입력받지 않은 데이터 존재"); | 176 | console.log("입력받지 않은 데이터 존재"); |
182 | - res.redirect("/comment/:cafeId"); // 후기작성으로 다시 이동 | 177 | + res.redirect("/review/:cafeId"); // 후기작성으로 다시 이동 |
183 | } | 178 | } |
184 | 179 | ||
185 | var sql = | 180 | var sql = |
186 | - "INSERT INTO COMMENT(CAFE_ID, PRICE, KINDNESS, NOISE, ACCESSIBILITY) VALUES(?,?,?,?,?)"; | 181 | + "INSERT INTO REVIEW(CAFE_ID, PRICE, KINDNESS, NOISE, ACCESSIBILITY) VALUES(?,?,?,?,?)"; |
187 | 182 | ||
188 | var parameter = [cafeId, price, kindness, noise, accessibility]; | 183 | var parameter = [cafeId, price, kindness, noise, accessibility]; |
189 | 184 | ||
... | @@ -194,7 +189,9 @@ router.post("/comment", function (req, res) { | ... | @@ -194,7 +189,9 @@ router.post("/comment", function (req, res) { |
194 | console.log("새로운 comment 데이터 입력"); | 189 | console.log("새로운 comment 데이터 입력"); |
195 | } | 190 | } |
196 | }); | 191 | }); |
197 | - return res.render("map"); | 192 | + return res.send( |
193 | + '<script>alert("등록 완료"); location.href = "/login";</script>' | ||
194 | + ); | ||
198 | }); | 195 | }); |
199 | 196 | ||
200 | module.exports = router; | 197 | module.exports = router; | ... | ... |
1 | -{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"__lastAccess":1622063531297} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"__lastAccess":1622031757269} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"__lastAccess":1622032034021} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"__lastAccess":1622032180844} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -{"cookie":{"originalMaxAge":null,"expires":null,"httpOnly":true,"path":"/"},"__lastAccess":1622070807469,"user":{"name":"최정민","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 |
... | @@ -78,7 +78,7 @@ | ... | @@ -78,7 +78,7 @@ |
78 | console.log('Signed in as: ' + xhr.responseText); | 78 | console.log('Signed in as: ' + xhr.responseText); |
79 | if(xhr.responseText == 'success'){ | 79 | if(xhr.responseText == 'success'){ |
80 | signOut(); | 80 | signOut(); |
81 | - location.assign('/login') | 81 | + location.assign('/login'); |
82 | } | 82 | } |
83 | }; | 83 | }; |
84 | xhr.send(JSON.stringify({token : id_token})); | 84 | xhr.send(JSON.stringify({token : id_token})); | ... | ... |
1 | <!DOCTYPE html> | 1 | <!DOCTYPE html> |
2 | <html> | 2 | <html> |
3 | <head> | 3 | <head> |
4 | - <link rel="stylesheet" href="stylesheets/bootstrap.css"> | 4 | + <link rel="stylesheet" href="stylesheets/bootstrap.css" /> |
5 | <title>Cafe Map</title> | 5 | <title>Cafe Map</title> |
6 | <style> | 6 | <style> |
7 | .navbar { | 7 | .navbar { |
... | @@ -116,7 +116,16 @@ | ... | @@ -116,7 +116,16 @@ |
116 | <a class="navbar-brand" href="/"><strong>Home</strong></a> | 116 | <a class="navbar-brand" href="/"><strong>Home</strong></a> |
117 | <ul class="navbar-nav mr-auto mt-2 mt-lg-0"> | 117 | <ul class="navbar-nav mr-auto mt-2 mt-lg-0"> |
118 | <li class="nav-item active"> | 118 | <li class="nav-item active"> |
119 | - <a class="nav-link" style="color:#ffffff" href="#" data-toggle="modal" data-target="#profile"><%=user.nickname%>'s Profile<span class="sr-only">(current)</span></a> | 119 | + <a |
120 | + class="nav-link" | ||
121 | + style="color: #ffffff" | ||
122 | + href="#" | ||
123 | + data-toggle="modal" | ||
124 | + data-target="#profile" | ||
125 | + ><%=user.nickname%>'s Profile<span class="sr-only" | ||
126 | + >(current)</span | ||
127 | + ></a | ||
128 | + > | ||
120 | </li> | 129 | </li> |
121 | <li class="nav-item active"> | 130 | <li class="nav-item active"> |
122 | <a | 131 | <a |
... | @@ -137,14 +146,14 @@ | ... | @@ -137,14 +146,14 @@ |
137 | <div class="row"> | 146 | <div class="row"> |
138 | <div class="col-1"></div> | 147 | <div class="col-1"></div> |
139 | 148 | ||
140 | - <div class="col-10"><div id="map" style="width: 100%; height: 575px"></div></div> | 149 | + <div class="col-10"> |
141 | - | 150 | + <div id="map" style="width: 100%; height: 575px"></div> |
151 | + </div> | ||
142 | 152 | ||
143 | <div class="col-1"></div> | 153 | <div class="col-1"></div> |
144 | </div> | 154 | </div> |
145 | </section> | 155 | </section> |
146 | 156 | ||
147 | - | ||
148 | <script | 157 | <script |
149 | type="text/javascript" | 158 | type="text/javascript" |
150 | src="//dapi.kakao.com/v2/maps/sdk.js?appkey=68cbccbcd6f0fef0a213e62ad37393ee&libraries=services" | 159 | src="//dapi.kakao.com/v2/maps/sdk.js?appkey=68cbccbcd6f0fef0a213e62ad37393ee&libraries=services" |
... | @@ -274,7 +283,7 @@ | ... | @@ -274,7 +283,7 @@ |
274 | ' <span class="tel">' + | 283 | ' <span class="tel">' + |
275 | place.phone + | 284 | place.phone + |
276 | "</span>" + | 285 | "</span>" + |
277 | - `<a href="/comment/${place.id}"><button>후기 작성</button>`; | 286 | + `<a href="/review/${place.id}"><button>후기 작성</button>`; |
278 | "</div>" + '<div class="after"></div>'; | 287 | "</div>" + '<div class="after"></div>'; |
279 | contentNode.innerHTML = content; | 288 | contentNode.innerHTML = content; |
280 | placeOverlay.setPosition(new kakao.maps.LatLng(place.y, place.x)); | 289 | placeOverlay.setPosition(new kakao.maps.LatLng(place.y, place.x)); |
... | @@ -284,14 +293,27 @@ | ... | @@ -284,14 +293,27 @@ |
284 | <script src="javascripts/bootstrap.js"></script> | 293 | <script src="javascripts/bootstrap.js"></script> |
285 | <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> | 294 | <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script> |
286 | 295 | ||
287 | - | ||
288 | <!-- 모달 바디 --> | 296 | <!-- 모달 바디 --> |
289 | - <div class="modal fade" id="profile" tabindex="-1" role="dialog" aria-labelledby="profilemodal" aria-hidden="true"> | 297 | + <div |
298 | + class="modal fade" | ||
299 | + id="profile" | ||
300 | + tabindex="-1" | ||
301 | + role="dialog" | ||
302 | + aria-labelledby="profilemodal" | ||
303 | + aria-hidden="true" | ||
304 | + > | ||
290 | <div class="modal-dialog" role="document"> | 305 | <div class="modal-dialog" role="document"> |
291 | <div class="modal-content"> | 306 | <div class="modal-content"> |
292 | <div class="modal-header"> | 307 | <div class="modal-header"> |
293 | - <h5 class="modal-title" id="profilemodal"><%=user.nickname%>'s PROFILE</h5> | 308 | + <h5 class="modal-title" id="profilemodal"> |
294 | - <button type="button" class="close" data-dismiss="modal" aria-label="Close"> | 309 | + <%=user.nickname%>'s PROFILE |
310 | + </h5> | ||
311 | + <button | ||
312 | + type="button" | ||
313 | + class="close" | ||
314 | + data-dismiss="modal" | ||
315 | + aria-label="Close" | ||
316 | + > | ||
295 | <span aria-hidden="true">×</span> | 317 | <span aria-hidden="true">×</span> |
296 | </button> | 318 | </button> |
297 | </div> | 319 | </div> |
... | @@ -299,21 +321,33 @@ | ... | @@ -299,21 +321,33 @@ |
299 | <div class="card mb-3"> | 321 | <div class="card mb-3"> |
300 | <div class="row g-0"> | 322 | <div class="row g-0"> |
301 | <div class="col-md-4"> | 323 | <div class="col-md-4"> |
302 | - <img src="<%= user.picture%>" alt="google profile picture" style="width:100%; height: 100%; "> | 324 | + <img |
325 | + src="<%= user.picture%>" | ||
326 | + alt="google profile picture" | ||
327 | + style="width: 100%; height: 100%" | ||
328 | + /> | ||
303 | </div> | 329 | </div> |
304 | <div class="col-md-8"> | 330 | <div class="col-md-8"> |
305 | <div class="card-body"> | 331 | <div class="card-body"> |
306 | <h5 class="card-title"><%=user.name%></h5> | 332 | <h5 class="card-title"><%=user.name%></h5> |
307 | - <p class="card-text">Age : <%=user.age%>, Gender : <%=user.gender%></p> | 333 | + <p class="card-text"> |
308 | - <p class="card-text">Emaile : <%=user.email%> | 334 | + Age : <%=user.age%>, Gender : <%=user.gender%> |
309 | - <p class="card-text"><small class="text-muted">from Google and CafeRecommend</small></p> | 335 | + </p> |
336 | + <p class="card-text">Emaile : <%=user.email%></p> | ||
337 | + <p class="card-text"> | ||
338 | + <small class="text-muted" | ||
339 | + >from Google and CafeRecommend</small | ||
340 | + > | ||
341 | + </p> | ||
310 | </div> | 342 | </div> |
311 | </div> | 343 | </div> |
312 | </div> | 344 | </div> |
313 | </div> | 345 | </div> |
314 | </div> | 346 | </div> |
315 | 347 | ||
316 | - <button type="button" class="btn btn-primary" data-dismiss="modal">확인</button> | 348 | + <button type="button" class="btn btn-primary" data-dismiss="modal"> |
349 | + 확인 | ||
350 | + </button> | ||
317 | </div> | 351 | </div> |
318 | </div> | 352 | </div> |
319 | </div> | 353 | </div> | ... | ... |
... | @@ -3,28 +3,55 @@ | ... | @@ -3,28 +3,55 @@ |
3 | <meta charset="UTF-8"> | 3 | <meta charset="UTF-8"> |
4 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> | 4 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
5 | 5 | ||
6 | - <title>Enroll Comment</title> | 6 | + <title>Enroll Review</title> |
7 | 7 | ||
8 | <link rel="stylesheet" href="/stylesheets/bootstrap.css"> | 8 | <link rel="stylesheet" href="/stylesheets/bootstrap.css"> |
9 | <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@700&display=swap" rel="stylesheet"> | 9 | <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@700&display=swap" rel="stylesheet"> |
10 | 10 | ||
11 | <style> | 11 | <style> |
12 | - img{ | 12 | + img { |
13 | - max-width: 100%; | 13 | + max-width: 100%; |
14 | - height: 100% !important; | 14 | + height: 100% !important; |
15 | } | 15 | } |
16 | - h1{font-family: 'Noto Sans KR', sans-serif;} | 16 | + h1 { |
17 | - h4{font-family: 'Noto Sans KR', sans-serif;} | 17 | + font-family: "Noto Sans KR", sans-serif; |
18 | - h2{font-family: 'Noto Sans KR', sans-serif;} | 18 | + } |
19 | - h3{font-family: 'Noto Sans KR', sans-serif;} | 19 | + h4 { |
20 | - h5{font-family: 'Noto Sans KR', sans-serif;} | 20 | + font-family: "Noto Sans KR", sans-serif; |
21 | - .middle{ | 21 | + } |
22 | - display: inline-block; | 22 | + h2 { |
23 | - vertical-align: middle; | 23 | + font-family: "Noto Sans KR", sans-serif; |
24 | + } | ||
25 | + h3 { | ||
26 | + font-family: "Noto Sans KR", sans-serif; | ||
27 | + } | ||
28 | + h5 { | ||
29 | + font-family: "Noto Sans KR", sans-serif; | ||
30 | + } | ||
31 | + .middle { | ||
32 | + display: inline-block; | ||
33 | + vertical-align: middle; | ||
24 | } | 34 | } |
25 | </style> | 35 | </style> |
26 | </head> | 36 | </head> |
27 | <body> | 37 | <body> |
38 | + <nav class="navbar navbar-expand-lg navbar-dark bg-dark"> | ||
39 | + <button | ||
40 | + class="navbar-toggler" | ||
41 | + type="button" | ||
42 | + data-toggle="collapse" | ||
43 | + data-target="#navbarSupportedContent" | ||
44 | + aria-controls="navbarSupportedContent" | ||
45 | + aria-expanded="false" | ||
46 | + aria-label="Toggle navigation" | ||
47 | + > | ||
48 | + <span class="navbar-toggler-icon"></span> | ||
49 | + </button> | ||
50 | + </nav> | ||
51 | + | ||
52 | + <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> | ||
54 | + </div> | ||
28 | 55 | ||
29 | <hr class="my-2" > | 56 | <hr class="my-2" > |
30 | <section id="carousel-1"> | 57 | <section id="carousel-1"> |
... | @@ -32,7 +59,12 @@ | ... | @@ -32,7 +59,12 @@ |
32 | <div class="col-2"></div> | 59 | <div class="col-2"></div> |
33 | <div class="col-8"> | 60 | <div class="col-8"> |
34 | <hr class="my-4" style="background-color: white"> | 61 | <hr class="my-4" style="background-color: white"> |
35 | - <form action="/comment" method="post"> | 62 | + <form action="/review" method="post"> |
63 | + <hr class="my-3" style="background-color: white"> | ||
64 | + <label for="cafeId" class="form-label">카페ID</label> | ||
65 | + <select class="form-select form-select-lg" id="cafeId" name="cafeId" required> | ||
66 | + <option value="<%=cafeId%>" selected><%=cafeId%></option> | ||
67 | + </select> | ||
36 | <hr class="my-3" style="background-color: white"> | 68 | <hr class="my-3" style="background-color: white"> |
37 | <label for="price" class="form-label">가격</label> | 69 | <label for="price" class="form-label">가격</label> |
38 | <select class="form-select form-select-lg" id="price" name="price" required> | 70 | <select class="form-select form-select-lg" id="price" name="price" required> | ... | ... |
-
Please register or login to post a comment