|
|
@ -2,6 +2,7 @@ package pc |
|
|
|
|
|
|
|
import ( |
|
|
|
"fmt" |
|
|
|
"github.com/ouxuanserver/osmanthuswine/src/core" |
|
|
|
"hudongzhuanjia/controllers" |
|
|
|
"hudongzhuanjia/models" |
|
|
|
"hudongzhuanjia/utils" |
|
|
@ -9,8 +10,6 @@ import ( |
|
|
|
"hudongzhuanjia/utils/define" |
|
|
|
"strconv" |
|
|
|
"time" |
|
|
|
|
|
|
|
"github.com/ouxuanserver/osmanthuswine/src/core" |
|
|
|
) |
|
|
|
|
|
|
|
type VoteCtl struct { |
|
|
@ -133,42 +132,37 @@ func (t *VoteCtl) JoinTotal() { |
|
|
|
func (t *VoteCtl) List() { |
|
|
|
activityId := t.MustGetInt64("activity_id") |
|
|
|
|
|
|
|
list := make([]*models.NewVoteActivity, 0) |
|
|
|
total, err := core.GetXormAuto().Where("is_delete=0 and activity_id=?", activityId). |
|
|
|
Asc("created_at").FindAndCount(&list) |
|
|
|
votes, err := models.GetVoteListByActivityId(activityId) |
|
|
|
t.CheckErr(err) |
|
|
|
|
|
|
|
ids := make([]int64, 0) |
|
|
|
for _, v := range list { |
|
|
|
for _, v := range votes { |
|
|
|
ids = append(ids, v.Id) |
|
|
|
} |
|
|
|
ladders := make([]*models.NewVoteActivityLadder, 0) |
|
|
|
err = core.GetXormAuto().Where("is_delete=0").In("vote_activity_id", ids).Find(&ladders) |
|
|
|
t.CheckErr(err) |
|
|
|
|
|
|
|
for index := range list { |
|
|
|
for index := range votes { |
|
|
|
for i := range ladders { |
|
|
|
if list[index].Id == ladders[i].VoteActivityId { |
|
|
|
list[index].VoteActivityLadders = append(list[index].VoteActivityLadders, ladders[i]) |
|
|
|
if votes[index].Id == ladders[i].VoteActivityId { |
|
|
|
votes[index].VoteActivityLadders = append(votes[index].VoteActivityLadders, ladders[i]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
t.JSON(map[string]interface{}{ |
|
|
|
"total": total, |
|
|
|
"list": list, |
|
|
|
"total": len(votes), |
|
|
|
"list": votes, |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
//获取投票的前几(头像、姓名、票数)
|
|
|
|
func (t *VoteCtl) History() { |
|
|
|
voteActivityId := t.MustGetInt64("vote_activity_id") |
|
|
|
//rehearsalId := t.MustGetInt64("rehearsal_id")
|
|
|
|
total := t.MustGetInt("total") |
|
|
|
|
|
|
|
ladders := make([]*models.NewVoteActivityLadder, 0) |
|
|
|
err := core.GetXormAuto().Where("is_delete=0 and vote_activity_id=?", voteActivityId). |
|
|
|
Desc("total_number").Asc("updated_at").Limit(total).Find(&ladders) |
|
|
|
ladders, err := models.GetNewVoteTopByVoteActivityId(voteActivityId, total) |
|
|
|
t.CheckErr(err) |
|
|
|
t.JSON(ladders) |
|
|
|
} |