index.js
2.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var express = require('express');
var mysql = require('mysql');
var dbconfig = require('../config/database.js');
var dbconfig2 = require('../config/database2.js');
var dbconfig3 = require('../config/database3.js');
var pool = mysql.createPool(dbconfig3);
var bodyParser = require('body-parser');
var router = express.Router();
// configuration ===============================================================
router.get('/first',function(req,res){
res.render('first',{title : "첫번째 화면"});
})
router.get('/', function(req, res){
res.render('index',{title: "첫화면"});
});
router.get('/reservation',function(req,res){
res.render('reservation',{title : "예약"});
});
router.post('/reservation',function(req, res){
var creater_id = req.body.creater_id;
var phone = req.body.phone;
var email = req.body.email;
var num = req.body.num;
var restime = req.body.restime;
var resmin = req.body.resmin;
var date = req.body.date;
var content = req.body.content;
pool.getConnection(function (err, connection)
{
// Use the connection
var sqlForInsertBoard = "insert into menu(creater_id, phone, email, num, restime, resmin,date,content) values('"+creater_id+"', '"+phone+"', '"+email+"','"+num+"','"+restime+"','"+resmin+"','"+date+"','"+content+"')";
connection.query(sqlForInsertBoard, function (err, rows) {
if (err) console.error("err : " + err);
console.log("rows : " + JSON.stringify(rows));
res.redirect('/resconfirm');
connection.release();
// Don't use the connection here, it has been returned to the pool.
});
});
})
router.get('/resconfirm', function(req, res){
res.render('resconfirm',{title : "예약확인"});
});
router.get('/menu',function(req,res){
res.render('menu',{title : "메뉴판"});
});
router.get('/db', function(req, res){
pool.getConnection(function (err, connection)
{
// Use the connection
//var sqlForInsertBoard = "insert into menu(creater_id, phone, email, num, restime, resmin,date,food,content) values('"+creater_id+"', '"+phone+"', '"+email+"','"+num+"','"+restime+"','"+resmin+"','"+date+"','"+food+"','"+content+"')";
var sqlForSelect = 'SELECT * from menu'
connection.query(sqlForSelect, function (err, rows) {
if (err) console.error("err : " + err);
console.log("rows : " + JSON.stringify(rows));
connection.release();
// Don't use the connection here, it has been returned to the pool.
});
});
});
/* GET home page. */
router.get('/pay', function(req, res, next) {
res.render('pay', { title: '결제' });
res.render('first');
});
module.exports = router;