From 439f2f4b715fe49129bec33b3e346e72a825824d Mon Sep 17 00:00:00 2001 From: maziyang Date: Thu, 26 Jun 2025 10:22:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E6=B4=BB=E5=8A=A8=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E5=88=9B=E5=BB=BA=E6=97=B6=E9=97=B4=E5=92=8C=E6=88=AA?= =?UTF-8?q?=E6=AD=A2=E6=97=B6=E9=97=B4=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/logic/vote/get_allvote.go | 5 ++--- internal/logic/vote_record/get_vote_detail.go | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) 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)) }