Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-arena-api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
ygopro-arena-api
Commits
b5a5113b
Commit
b5a5113b
authored
Sep 11, 2017
by
ganjingcun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
x
parent
33ac70de
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
125 additions
and
6 deletions
+125
-6
routes/api.js
routes/api.js
+125
-6
No files found.
routes/api.js
View file @
b5a5113b
...
@@ -405,9 +405,9 @@ router.get('/users', function (req, res) {
...
@@ -405,9 +405,9 @@ router.get('/users', function (req, res) {
var
o
=
req
.
query
.
o
||
'
pt
'
;
var
o
=
req
.
query
.
o
||
'
pt
'
;
var
sql
;
var
sql
;
if
(
o
===
'
pt
'
)
{
if
(
o
===
'
pt
'
)
{
sql
=
'
SELECT * from user_info order by pt desc limit
5
0
'
sql
=
'
SELECT * from user_info order by pt desc limit
10
0
'
}
else
{
}
else
{
sql
=
'
SELECT * from user_info order by exp desc limit
5
0
'
sql
=
'
SELECT * from user_info order by exp desc limit
10
0
'
}
}
console
.
log
(
sql
);
console
.
log
(
sql
);
...
@@ -546,13 +546,13 @@ router.get('/report', function (req, res) {
...
@@ -546,13 +546,13 @@ router.get('/report', function (req, res) {
}
}
var
from_date
=
moment
().
format
(
'
YYYY-MM-DD
'
)
var
from_date
=
moment
().
format
(
'
YYYY-MM-DD
'
)
var
to_date
=
moment
().
add
(
1
,
'
day
'
).
format
(
'
YYYY-MM-DD
'
)
var
to_date
=
moment
().
add
(
1
,
'
day
'
).
format
(
'
YYYY-MM-DD
'
)
if
(
req
.
query
.
from_date
)
{
if
(
req
.
query
.
from_date
)
{
from_date
=
moment
(
req
.
query
.
from_date
).
format
(
'
YYYY-MM-DD
'
)
from_date
=
moment
(
req
.
query
.
from_date
).
format
(
'
YYYY-MM-DD
'
)
}
}
if
(
req
.
query
.
to_date
)
{
if
(
req
.
query
.
to_date
)
{
to_date
=
moment
(
req
.
query
.
to_date
).
format
(
'
YYYY-MM-DD
'
)
to_date
=
moment
(
req
.
query
.
to_date
).
format
(
'
YYYY-MM-DD
'
)
}
}
...
@@ -659,7 +659,7 @@ router.get('/report', function (req, res) {
...
@@ -659,7 +659,7 @@ router.get('/report', function (req, res) {
var
athleticDisconnect
=
results
.
athleticDisconnect
.
rows
[
0
].
count
;
var
athleticDisconnect
=
results
.
athleticDisconnect
.
rows
[
0
].
count
;
var
athleticUsers
=
results
.
athleticUsers
.
rows
[
0
].
count
;
var
athleticUsers
=
results
.
athleticUsers
.
rows
[
0
].
count
;
var
totalActive
=
results
.
totalActive
.
rows
[
0
].
count
;
var
totalActive
=
results
.
totalActive
.
rows
[
0
].
count
;
res
.
json
({
res
.
json
({
entertain
:
{
entertain
:
{
total
:
entertainTotal
,
total
:
entertainTotal
,
...
@@ -678,6 +678,125 @@ router.get('/report', function (req, res) {
...
@@ -678,6 +678,125 @@ router.get('/report', function (req, res) {
});
});
});
});
router
.
post
(
'
/votes
'
,
function
(
req
,
res
)
{
// to run a query we can acquire a client from the pool,
// run a query on the client, and then return the client to the pool
pool
.
connect
(
function
(
err
,
client
,
done
)
{
if
(
err
)
{
done
()
return
console
.
error
(
'
error fetching client from pool
'
,
err
);
}
let
id
=
req
.
body
.
id
;
let
title
=
req
.
body
.
title
;
let
options
=
req
.
body
.
options
;
let
start_time
=
req
.
body
.
start_time
;
let
end_time
=
req
.
body
.
end_time
;
let
status
=
req
.
body
.
status
||
false
;
console
.
log
(
'
idididi:
'
,
id
)
var
now
=
moment
().
format
(
'
YYYY-MM-DD HH:mm
'
)
var
sql
=
`insert into votes (title, options, create_time, start_time, end_time, status) values (
'
${
title
}
',
'
${
options
}
',
'
${
now
}
',
'
${
start_time
}
',
'
${
end_time
}
',
'
${
status
}
'
)`
;
if
(
id
)
{
sql
=
`update votes set
title = '
${
title
}
',
options = '
${
options
}
',
start_time = '
${
start_time
}
',
end_time = '
${
end_time
}
',
status = '
${
status
}
'
where id = '
${
id
}
'`
;
}
console
.
log
(
sql
);
client
.
query
(
sql
,
function
(
err
,
result
)
{
done
();
var
response
=
{};
if
(
err
)
{
console
.
log
(
err
)
response
.
code
=
500
;
}
else
{
response
.
code
=
200
;
}
res
.
json
(
response
);
});
});
});
router
.
get
(
'
/votes
'
,
function
(
req
,
res
)
{
// to run a query we can acquire a client from the pool,
// run a query on the client, and then return the client to the pool
pool
.
connect
(
function
(
err
,
client
,
done
)
{
if
(
err
)
{
done
()
return
console
.
error
(
'
error fetching client from pool
'
,
err
);
}
var
username
=
req
.
query
.
username
;
var
type
=
req
.
query
.
type
;
var
arena
=
null
//1 athletic 2 entertain
if
(
type
===
'
1
'
)
{
arena
=
'
athletic
'
}
if
(
type
===
'
2
'
)
{
arena
=
'
entertain
'
}
var
from_date
=
req
.
query
.
from_date
;
var
to_date
=
req
.
query
.
to_date
;
// page_no 当前页数 page_num 每页展示数
// offset = (page_no - 1) * page_num
// select * from battle_history limit 5 offset 15;
var
page_no
=
req
.
query
.
page
||
1
var
page_num
=
req
.
query
.
page_num
||
15
var
offset
=
(
page_no
-
1
)
*
page_num
var
sql
=
`SELECT count(*) from votes `
console
.
log
(
sql
);
client
.
query
(
sql
,
function
(
err
,
result
)
{
var
total
=
result
.
rows
[
0
].
count
var
sql2
=
`SELECT * from votes order by create_time desc limit
${
page_num
}
offset
${
offset
}
`
console
.
log
(
sql2
)
client
.
query
(
sql2
,
function
(
err
,
result
)
{
//call `done()` to release the client back to the pool
done
()
if
(
err
)
{
return
console
.
error
(
'
error running query
'
,
err
)
}
res
.
json
({
total
:
total
-
0
,
data
:
result
.
rows
});
});
});
});
});
router
.
get
(
'
/deckinfo
'
,
function
(
req
,
res
)
{
router
.
get
(
'
/deckinfo
'
,
function
(
req
,
res
)
{
var
name
=
req
.
query
.
name
var
name
=
req
.
query
.
name
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment