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
849f63f1
Commit
849f63f1
authored
Oct 14, 2017
by
ganjingcun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
状态修改
parent
a8eb29eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
1 deletion
+36
-1
routes/api.js
routes/api.js
+36
-1
No files found.
routes/api.js
View file @
849f63f1
...
@@ -735,6 +735,41 @@ router.post('/votes', function (req, res) {
...
@@ -735,6 +735,41 @@ router.post('/votes', function (req, res) {
});
});
});
});
router
.
post
(
'
/voteStatus
'
,
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
status
=
req
.
body
.
status
;
var
now
=
moment
().
format
(
'
YYYY-MM-DD HH:mm
'
)
var
sql
=
`update votes set
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
.
post
(
'
/submitVote
'
,
function
(
req
,
res
)
{
router
.
post
(
'
/submitVote
'
,
function
(
req
,
res
)
{
// to run a query we can acquire a client from the pool,
// to run a query we can acquire a client from the pool,
...
@@ -874,7 +909,7 @@ router.get('/votes', function (req, res) {
...
@@ -874,7 +909,7 @@ router.get('/votes', function (req, res) {
async
.
each
(
options
,
function
(
option
,
callback2
)
{
async
.
each
(
options
,
function
(
option
,
callback2
)
{
var
queryVoteOptionCount
=
`SELECT count(*) from vote_result where vote_id='
${
vateid
}
' and option_id ='
${
option
.
key
}
'`
var
queryVoteOptionCount
=
`SELECT count(*) from vote_result where vote_id='
${
vateid
}
' and option_id ='
${
option
.
key
}
'`
console
.
log
(
queryVoteOptionCount
)
//
console.log(queryVoteOptionCount)
client
.
query
(
queryVoteOptionCount
,
function
(
err
,
result
)
{
client
.
query
(
queryVoteOptionCount
,
function
(
err
,
result
)
{
//call `done()` to release the client back to the pool
//call `done()` to release the client back to the pool
done
()
done
()
...
...
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