Toggle navigation
Toggle navigation
This project
Loading...
Sign in
최재은
/
밀당강의봇
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김예미
2019-06-04 21:36:55 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
76e68c2125ac74da1fc0753eabe998ac4fcc419d
76e68c21
1 parent
c8967dc8
Edit template 6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
58 additions
and
9 deletions
controller.js
db.js
template.js
controller.js
View file @
76e68c2
...
...
@@ -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
)
{
...
...
db.js
0 → 100644
View file @
76e68c2
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
template.js
View file @
76e68c2
...
...
@@ -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
);
...
...
Please
register
or
login
to post a comment