김예미

Edit template 6

...@@ -8,7 +8,6 @@ exports.handleMessage=function(sender_psid, received_message) { ...@@ -8,7 +8,6 @@ exports.handleMessage=function(sender_psid, received_message) {
8 if(text === "처음으로"){ 8 if(text === "처음으로"){
9 template.greetingTemplate(function(result, res){ 9 template.greetingTemplate(function(result, res){
10 if(result==true){ 10 if(result==true){
11 - console.log(res);
12 response=res; 11 response=res;
13 } 12 }
14 }); 13 });
...@@ -19,8 +18,8 @@ exports.handleMessage=function(sender_psid, received_message) { ...@@ -19,8 +18,8 @@ exports.handleMessage=function(sender_psid, received_message) {
19 response=res; 18 response=res;
20 } 19 }
21 }); 20 });
21 + callSendAPI(sender_psid, response);
22 } 22 }
23 - callSendAPI(sender_psid, response);
24 } 23 }
25 24
26 exports.handlePostback =function(sender_psid, received_postback) { 25 exports.handlePostback =function(sender_psid, received_postback) {
......
1 +var mysql = require('mysql');
2 +const db_config = {
3 + host: 'us-cdbr-iron-east-02.cleardb.net',
4 + user: 'b9ecfdfc1d4928',
5 + password: '085c9fc6',
6 + database:'heroku_852566e0eb8d56e',
7 +};
8 +
9 +var db;
10 +function connectDB() {
11 + if (!db) {
12 + db = mysql.createConnection(db_config);
13 + db.connect(function(err) {
14 + if (!err) {
15 + console.log('Database is connected');
16 + } else {
17 + console.log('Error: ', err);
18 + }
19 + });
20 + }
21 +
22 + return db;
23 +}
24 +
25 +module.exports = connectDB();
26 +
27 +
28 +/*
29 +const mysql = require('mysql');
30 +const db_config = require('./config/db-config.json');
31 +
32 +let db;
33 +function connectDB() {
34 + if (!db) {
35 + db = mysql.createConnection(db_config);
36 + db.connect(function(err) {
37 + if (!err) {
38 + console.log('Database is connected');
39 + } else {
40 + console.log('Error: ', err);
41 + }
42 + });
43 + }
44 +
45 + return db;
46 +}
47 +
48 +module.exports = connectDB();
49 +*/
...\ No newline at end of file ...\ No newline at end of file
...@@ -77,11 +77,12 @@ exports.getLectNameTemplate = function(cb){ ...@@ -77,11 +77,12 @@ exports.getLectNameTemplate = function(cb){
77 77
78 exports.choiceLectProfTemplate=function(message,cb) { 78 exports.choiceLectProfTemplate=function(message,cb) {
79 var sqlquery = 'SELECT * FROM reviews WHERE lecturename = ? OR proname = ?'; 79 var sqlquery = 'SELECT * FROM reviews WHERE lecturename = ? OR proname = ?';
80 - var par = [message,message]; 80 + var par = ['%'+message+'%','%'+message+'%'];
81 - db.query(sqlquery, par, function(error,results){ 81 +
82 + db.query(sqlquery,par, function(error,results){
83 + console.log("!~~!~!~!~!~!~!~!~!");
82 if (error){ 84 if (error){
83 - console.log(error); 85 + res.render('error');
84 - res.render('error');
85 } 86 }
86 if(results.length==0){ 87 if(results.length==0){
87 cb(true, {text: "검색 결과가 없습니다. 검색어를 다시 입력해주세요."}); 88 cb(true, {text: "검색 결과가 없습니다. 검색어를 다시 입력해주세요."});
...@@ -93,9 +94,9 @@ exports.choiceLectProfTemplate=function(message,cb) { ...@@ -93,9 +94,9 @@ exports.choiceLectProfTemplate=function(message,cb) {
93 }); 94 });
94 }else if(results.length>2){ 95 }else if(results.length>2){
95 LectProfList(results,0,2,true,'1',message, function(result, text){ 96 LectProfList(results,0,2,true,'1',message, function(result, text){
96 - if(result==true){ 97 + if(result==true){
97 cb(true, text); 98 cb(true, text);
98 - } 99 + }
99 }); 100 });
100 } 101 }
101 }); 102 });
...@@ -187,7 +188,7 @@ exports.moreProfTemplate = function(payload,cb){ ...@@ -187,7 +188,7 @@ exports.moreProfTemplate = function(payload,cb){
187 var message=ms[1]; 188 var message=ms[1];
188 189
189 var sqlquery='SELECT * FROM reviews WHERE lecturename = ? OR proname = ?'; 190 var sqlquery='SELECT * FROM reviews WHERE lecturename = ? OR proname = ?';
190 - var par=[message,message]; 191 + var par=['%'+message+'%','%'+message+'%'];
191 db.query(sqlquery, par, function(error,results){ 192 db.query(sqlquery, par, function(error,results){
192 if (error){ 193 if (error){
193 console.log(error); 194 console.log(error);
......