Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
plugin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
link33
plugin
Commits
f485969a
Commit
f485969a
authored
Jan 28, 2021
by
jiangpeng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dapp/vote:add vote status info
parent
5a906fb2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
22 additions
and
21 deletions
+22
-21
query.go
plugin/dapp/vote/executor/query.go
+5
-5
util.go
plugin/dapp/vote/executor/util.go
+12
-8
vote.proto
plugin/dapp/vote/proto/vote.proto
+3
-6
readme.md
plugin/dapp/vote/readme.md
+2
-2
vote.pb.go
plugin/dapp/vote/types/vote.pb.go
+0
-0
No files found.
plugin/dapp/vote/executor/query.go
View file @
f485969a
...
@@ -68,15 +68,15 @@ func (v *vote) Query_GetVotes(in *vty.ReqStrings) (types.Message, error) {
...
@@ -68,15 +68,15 @@ func (v *vote) Query_GetVotes(in *vty.ReqStrings) (types.Message, error) {
if
in
==
nil
{
if
in
==
nil
{
return
nil
,
types
.
ErrInvalidParam
return
nil
,
types
.
ErrInvalidParam
}
}
infos
:=
&
vty
.
VoteInfos
{
VoteList
:
make
([]
*
vty
.
VoteInfo
,
0
,
len
(
in
.
GetItems
()))}
voteList
:=
make
([]
*
vty
.
VoteInfo
,
0
,
len
(
in
.
GetItems
()))
for
_
,
id
:=
range
in
.
GetItems
()
{
for
_
,
id
:=
range
in
.
GetItems
()
{
info
,
err
:=
v
.
getVote
(
id
)
info
,
err
:=
v
.
getVote
(
id
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
infos
.
VoteList
=
append
(
infos
.
V
oteList
,
info
)
voteList
=
append
(
v
oteList
,
info
)
}
}
return
classifyVoteList
(
infos
),
nil
return
classifyVoteList
(
voteList
),
nil
}
}
...
@@ -163,13 +163,13 @@ func (v *vote) Query_ListVote(in *vty.ReqListVote) (types.Message, error) {
...
@@ -163,13 +163,13 @@ func (v *vote) Query_ListVote(in *vty.ReqListVote) (types.Message, error) {
return
nil
,
err
return
nil
,
err
}
}
list
:=
&
vty
.
VoteInfos
{
VoteList
:
make
([]
*
vty
.
VoteInfo
,
0
,
len
(
rows
))}
list
:=
make
([]
*
vty
.
VoteInfo
,
0
,
len
(
rows
))
for
_
,
row
:=
range
rows
{
for
_
,
row
:=
range
rows
{
info
,
ok
:=
row
.
Data
.
(
*
vty
.
VoteInfo
)
info
,
ok
:=
row
.
Data
.
(
*
vty
.
VoteInfo
)
if
!
ok
{
if
!
ok
{
return
nil
,
types
.
ErrTypeAsset
return
nil
,
types
.
ErrTypeAsset
}
}
list
.
VoteList
=
append
(
list
.
VoteL
ist
,
info
)
list
=
append
(
l
ist
,
info
)
}
}
return
classifyVoteList
(
list
),
nil
return
classifyVoteList
(
list
),
nil
...
...
plugin/dapp/vote/executor/util.go
View file @
f485969a
...
@@ -7,8 +7,11 @@ import (
...
@@ -7,8 +7,11 @@ import (
)
)
const
(
const
(
voteStatusNormal
=
iota
voteStatusNormal
=
iota
//非关闭常规状态
voteStatusClosed
voteStatusPending
//即将开始
voteStatusOngoing
//正在进行
voteStatusFinished
//已经结束
voteStatusClosed
//已经关闭
)
)
const
(
const
(
...
@@ -88,22 +91,23 @@ func decodeCommitInfo(data []byte) *vty.CommitInfo {
...
@@ -88,22 +91,23 @@ func decodeCommitInfo(data []byte) *vty.CommitInfo {
return
info
return
info
}
}
func
classifyVoteList
(
infos
*
vty
.
VoteInfos
)
*
vty
.
ReplyVoteList
{
func
classifyVoteList
(
voteList
[]
*
vty
.
VoteInfo
)
*
vty
.
ReplyVoteList
{
reply
:=
&
vty
.
ReplyVoteList
{}
reply
:=
&
vty
.
ReplyVoteList
{}
currentTime
:=
types
.
Now
()
.
Unix
()
currentTime
:=
types
.
Now
()
.
Unix
()
for
_
,
voteInfo
:=
range
infos
.
GetVoteList
()
{
for
_
,
voteInfo
:=
range
voteList
{
if
voteInfo
.
Status
==
voteStatusClosed
{
if
voteInfo
.
Status
==
voteStatusClosed
{
reply
.
ClosedList
=
append
(
reply
.
ClosedList
,
voteInfo
)
continue
}
else
if
voteInfo
.
BeginTimestamp
>
currentTime
{
}
else
if
voteInfo
.
BeginTimestamp
>
currentTime
{
reply
.
PendingList
=
append
(
reply
.
PendingList
,
voteInfo
)
voteInfo
.
Status
=
voteStatusPending
}
else
if
voteInfo
.
EndTimestamp
>
currentTime
{
}
else
if
voteInfo
.
EndTimestamp
>
currentTime
{
reply
.
OngoingList
=
append
(
reply
.
OngoingList
,
voteInfo
)
voteInfo
.
Status
=
voteStatusOngoing
}
else
{
}
else
{
reply
.
FinishedList
=
append
(
reply
.
FinishedList
,
voteInfo
)
voteInfo
.
Status
=
voteStatusFinished
}
}
}
}
reply
.
CurrentTimestamp
=
currentTime
reply
.
CurrentTimestamp
=
currentTime
reply
.
VoteList
=
voteList
return
reply
return
reply
}
}
plugin/dapp/vote/proto/vote.proto
View file @
f485969a
...
@@ -100,7 +100,7 @@ message VoteInfo {
...
@@ -100,7 +100,7 @@ message VoteInfo {
int64
endTimestamp
=
7
;
//投票结束时间戳
int64
endTimestamp
=
7
;
//投票结束时间戳
repeated
CommitInfo
commitInfos
=
8
;
//已投票的提交信息
repeated
CommitInfo
commitInfos
=
8
;
//已投票的提交信息
string
description
=
9
;
//描述信息
string
description
=
9
;
//描述信息
uint32
status
=
10
;
//状态,
0正常,1
关闭
uint32
status
=
10
;
//状态,
1即将开始,2正在进行,3已经结束,4已
关闭
}
}
message
VoteInfos
{
message
VoteInfos
{
...
@@ -134,9 +134,6 @@ message ReqListVote {
...
@@ -134,9 +134,6 @@ message ReqListVote {
}
}
message
ReplyVoteList
{
message
ReplyVoteList
{
repeated
VoteInfo
pendingList
=
1
;
//即将开始投票列表
repeated
VoteInfo
voteList
=
1
;
//投票列表
repeated
VoteInfo
ongoingList
=
2
;
//正在进行投票列表
int64
currentTimestamp
=
2
;
//当前系统时间
repeated
VoteInfo
finishedList
=
3
;
//已经完成投票列表
repeated
VoteInfo
closedList
=
4
;
//已经关闭投票列表
int64
currentTimestamp
=
5
;
}
}
plugin/dapp/vote/readme.md
View file @
f485969a
...
@@ -131,7 +131,7 @@ message VoteInfo {
...
@@ -131,7 +131,7 @@ message VoteInfo {
int64
endTimestamp
=
7
;
//投票结束时间戳
int64
endTimestamp
=
7
;
//投票结束时间戳
repeated
CommitInfo
commitInfos
=
8
;
//已投票的提交信息
repeated
CommitInfo
commitInfos
=
8
;
//已投票的提交信息
string
description
=
9
;
//描述信息
string
description
=
9
;
//描述信息
uint32
status
=
10
;
//状态,
0正常,1
关闭
uint32
status
=
10
;
//状态,
1即将开始,2正在进行,3已经结束,4已
关闭
}
}
//投票选项
//投票选项
...
@@ -212,7 +212,7 @@ message VoteInfo {
...
@@ -212,7 +212,7 @@ message VoteInfo {
int64
endTimestamp
=
7
;
//投票结束时间戳
int64
endTimestamp
=
7
;
//投票结束时间戳
repeated
CommitInfo
commitInfos
=
8
;
//已投票的提交信息
repeated
CommitInfo
commitInfos
=
8
;
//已投票的提交信息
string
description
=
9
;
//描述信息
string
description
=
9
;
//描述信息
uint32
status
=
10
;
//状态,
0正常,1
关闭
uint32
status
=
10
;
//状态,
1即将开始,2正在进行,3已经结束,4已
关闭
}
}
```
```
...
...
plugin/dapp/vote/types/vote.pb.go
View file @
f485969a
This diff is collapsed.
Click to expand it.
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