Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OPENTECH
/
yoho-node-ci
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
2
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
郝肖肖
8 years ago
Commit
51c3056be680f9c64a8f5dd30446faf49eb3200e
1 parent
d7629670
'myql-queue'
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
2 deletions
apps/web/actions/keywords.js
lib/mysql-promise.js
apps/web/actions/keywords.js
View file @
51c3056
...
...
@@ -9,6 +9,7 @@
const
Router
=
require
(
'koa-router'
);
const
moment
=
require
(
'moment'
);
const
pager
=
require
(
'../utils/pager'
);
const
Mysql
=
require
(
'../../../lib/mysql-promise'
);
const
r
=
new
Router
();
...
...
@@ -155,4 +156,17 @@ r.get('/searchKeywords', async(ctx) => {
total
:
1
};
});
r
.
get
(
'/syncWord'
,
async
(
ctx
)
=>
{
let
mysql
=
new
Mysql
();
let
r
=
await
mysql
.
query
(
`
select
*
from
seo_keywords
`
);
console
.
log
(
r
[
0
].
keyword
,
' ==='
);
ctx
.
body
=
{
code
:
200
,
message
:
'success'
,
data
:
r
};
});
module
.
exports
=
r
;
...
...
lib/mysql-promise.js
View file @
51c3056
...
...
@@ -6,12 +6,13 @@ const config = require('../config/config');
class
MysqlPromise
{
constructor
()
{
this
.
connect
().
then
(
conn
=>
{
this
.
connect
=
conn
;
this
.
conn
=
conn
;
return
conn
;
});
}
connect
()
{
if
(
this
.
conn
ect
)
{
if
(
this
.
conn
)
{
return
Promise
.
resolve
(
this
.
connect
);
}
...
...
@@ -28,6 +29,15 @@ class MysqlPromise {
return
null
;
});
}
query
(
sql
)
{
return
this
.
connect
().
then
(
d
=>
{
return
d
.
query
(
sql
);
}).
catch
(
err
=>
{
console
.
error
(
`
mysql
query
,
err
:
$
{
err
.
message
}
`
);
return
[];
});
}
}
module
.
exports
=
MysqlPromise
;
\ No newline at end of file
...
...
Please
register
or
login
to post a comment