|
@ -3,6 +3,7 @@ package vote_record |
|
|
import ( |
|
|
import ( |
|
|
"context" |
|
|
"context" |
|
|
"fmt" |
|
|
"fmt" |
|
|
|
|
|
"github.com/gogf/gf/v2/frame/g" |
|
|
"github.com/gogf/gf/v2/os/gtime" |
|
|
"github.com/gogf/gf/v2/os/gtime" |
|
|
v1 "practice_ArticleVote_Go/api/vote_record/v1" |
|
|
v1 "practice_ArticleVote_Go/api/vote_record/v1" |
|
|
"practice_ArticleVote_Go/internal/consts" |
|
|
"practice_ArticleVote_Go/internal/consts" |
|
@ -28,10 +29,13 @@ func (l *VoteRecordLogic) AddRecord(ctx context.Context, req *v1.AddRecordReq) ( |
|
|
if err != nil { |
|
|
if err != nil { |
|
|
return nil, err |
|
|
return nil, err |
|
|
} |
|
|
} |
|
|
voteDetailpattern := fmt.Sprintf(consts.VOTE_DETAIL+":%d:*", req.VoteId) |
|
|
|
|
|
_, err = utils.DeleteKeys(ctx, voteDetailpattern) |
|
|
|
|
|
ExportFilepattern := fmt.Sprintf(consts.EXPORT_FILE+":%d:*", req.VoteId) |
|
|
|
|
|
_, err = utils.DeleteKeys(ctx, ExportFilepattern) |
|
|
|
|
|
|
|
|
voteDetailPattern := fmt.Sprintf(consts.VOTE_DETAIL+":%d:*", req.VoteId) |
|
|
|
|
|
_, err = utils.DeleteKeys(ctx, voteDetailPattern) |
|
|
|
|
|
exportFilePattern := fmt.Sprintf(consts.EXPORT_FILE+":%d:*", req.VoteId) |
|
|
|
|
|
_, err = utils.DeleteKeys(ctx, exportFilePattern) |
|
|
|
|
|
articleAndVote := fmt.Sprintf(consts.ARTICLE+":%d", req.ArticleId) |
|
|
|
|
|
redis := g.Redis() |
|
|
|
|
|
_, err = redis.Del(ctx, articleAndVote) |
|
|
res = &v1.AddRecordRes{} |
|
|
res = &v1.AddRecordRes{} |
|
|
return res, nil |
|
|
return res, nil |
|
|
} |
|
|
} |