김예미

Edit template 6

......@@ -8,7 +8,6 @@ exports.handleMessage=function(sender_psid, received_message) {
if(text === "처음으로"){
template.greetingTemplate(function(result, res){
if(result==true){
console.log(res);
response=res;
}
});
......@@ -19,8 +18,8 @@ exports.handleMessage=function(sender_psid, received_message) {
response=res;
}
});
}
callSendAPI(sender_psid, response);
}
}
exports.handlePostback =function(sender_psid, received_postback) {
......
var mysql = require('mysql');
const db_config = {
host: 'us-cdbr-iron-east-02.cleardb.net',
user: 'b9ecfdfc1d4928',
password: '085c9fc6',
database:'heroku_852566e0eb8d56e',
};
var db;
function connectDB() {
if (!db) {
db = mysql.createConnection(db_config);
db.connect(function(err) {
if (!err) {
console.log('Database is connected');
} else {
console.log('Error: ', err);
}
});
}
return db;
}
module.exports = connectDB();
/*
const mysql = require('mysql');
const db_config = require('./config/db-config.json');
let db;
function connectDB() {
if (!db) {
db = mysql.createConnection(db_config);
db.connect(function(err) {
if (!err) {
console.log('Database is connected');
} else {
console.log('Error: ', err);
}
});
}
return db;
}
module.exports = connectDB();
*/
\ No newline at end of file
......@@ -77,10 +77,11 @@ exports.getLectNameTemplate = function(cb){
exports.choiceLectProfTemplate=function(message,cb) {
var sqlquery = 'SELECT * FROM reviews WHERE lecturename = ? OR proname = ?';
var par = [message,message];
db.query(sqlquery, par, function(error,results){
var par = ['%'+message+'%','%'+message+'%'];
db.query(sqlquery,par, function(error,results){
console.log("!~~!~!~!~!~!~!~!~!");
if (error){
console.log(error);
res.render('error');
}
if(results.length==0){
......@@ -187,7 +188,7 @@ exports.moreProfTemplate = function(payload,cb){
var message=ms[1];
var sqlquery='SELECT * FROM reviews WHERE lecturename = ? OR proname = ?';
var par=[message,message];
var par=['%'+message+'%','%'+message+'%'];
db.query(sqlquery, par, function(error,results){
if (error){
console.log(error);
......