Browse Source

获取活动列表创建时间和截止时间判断

master
maziyang 6 days ago
parent
commit
439f2f4b71
  1. 5
      internal/logic/vote/get_allvote.go
  2. 4
      internal/logic/vote_record/get_vote_detail.go

5
internal/logic/vote/get_allvote.go

@ -37,11 +37,11 @@ func (l *VoteLogic) GetAllVote(ctx context.Context, req *v1.VoteReq) (res *v1.Vo
query += " AND v.vote_title LIKE ?"
conditions = append(conditions, "%"+req.VoteTitle+"%")
}
if req.CreateTime != nil {
if req.CreateTime != nil && !req.CreateTime.IsZero() {
query += " AND DATE(v.create_time) = ?"
conditions = append(conditions, req.CreateTime)
}
if req.DeadlineTime != nil {
if req.DeadlineTime != nil && !req.DeadlineTime.IsZero() {
query += " AND DATE(v.deadline_time) = ?"
conditions = append(conditions, req.DeadlineTime)
}
@ -67,7 +67,6 @@ func (l *VoteLogic) GetAllVote(ctx context.Context, req *v1.VoteReq) (res *v1.Vo
query += " LIMIT ?, ? "
offset := (req.Page - 1) * req.PageSize
conditions = append(conditions, offset, req.PageSize)
err = g.DB().Ctx(ctx).
Raw(query, conditions...).
Scan(&res.Rows)

4
internal/logic/vote_record/get_vote_detail.go

@ -119,8 +119,8 @@ func (l *VoteRecordLogic) GetVoteDetail(ctx context.Context, req *v1.GetVoteDeta
return nil, err
}
res.VoteList = voteList
buf, merr := json.Marshal(res)
if merr == nil {
buf, err := json.Marshal(res)
if err == nil {
ttl := utils.GetCacheTTL()
_ = redis.SetEX(ctx, cacheKey, string(buf), int64(ttl))
}

Loading…
Cancel
Save