diff --git a/internal/logic/vote/get_allvote.go b/internal/logic/vote/get_allvote.go index b6102cf..da46f46 100644 --- a/internal/logic/vote/get_allvote.go +++ b/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) diff --git a/internal/logic/vote_record/get_vote_detail.go b/internal/logic/vote_record/get_vote_detail.go index 2ce2f40..4d95d0c 100644 --- a/internal/logic/vote_record/get_vote_detail.go +++ b/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)) }