김예미

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);
}
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,11 +77,12 @@ 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');
res.render('error');
}
if(results.length==0){
cb(true, {text: "검색 결과가 없습니다. 검색어를 다시 입력해주세요."});
......@@ -93,9 +94,9 @@ exports.choiceLectProfTemplate=function(message,cb) {
});
}else if(results.length>2){
LectProfList(results,0,2,true,'1',message, function(result, text){
if(result==true){
if(result==true){
cb(true, text);
}
}
});
}
});
......@@ -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);
......