This commit is contained in:
2026-01-12 16:43:08 +08:00
parent dc747139c9
commit 3c6e2683f5
110 changed files with 9630 additions and 481 deletions

View File

@@ -8,7 +8,6 @@ import (
"time"
"ycc-server/app/main/api/internal/svc"
"ycc-server/app/main/model"
"ycc-server/common/globalkey"
"github.com/google/uuid"
"github.com/hibiken/asynq"
@@ -99,7 +98,6 @@ func (l *CleanQueryDataHandler) ProcessTask(ctx context.Context, t *asynq.Task)
// 先快速检查是否有数据需要清理(避免创建无用的日志记录)
checkBuilder := l.svcCtx.QueryModel.SelectBuilder().
Where("create_time < ?", cleanupBefore).
Where("del_state = ?", globalkey.DelStateNo).
Limit(1) // 只查询1条用于判断是否有数据
checkQueries, checkErr := l.svcCtx.QueryModel.FindAll(taskCtx, checkBuilder, "")
@@ -160,7 +158,6 @@ func (l *CleanQueryDataHandler) ProcessTask(ctx context.Context, t *asynq.Task)
// 1. 查询一批要删除的记录(添加排序确保一致性)
builder := l.svcCtx.QueryModel.SelectBuilder().
Where("create_time < ?", cleanupBefore).
Where("del_state = ?", globalkey.DelStateNo).
OrderBy("id ASC"). // 添加排序,确保处理顺序一致
Limit(uint64(batchSize))