优化结构

This commit is contained in:
Yvan
2026-08-22 20:14:29 +08:00
parent 44ab14448a
commit 699bcceeea
90 changed files with 534 additions and 298 deletions
+26
View File
@@ -0,0 +1,26 @@
package system
import (
"context"
"time"
bizsystem "kra/internal/biz/system"
"gorm.io/gorm"
)
type maintenanceRepo struct{ data Provider }
func NewMaintenanceRepo(data Provider) bizsystem.MaintenanceRepo {
return &maintenanceRepo{data: data}
}
func (r *maintenanceRepo) CleanupExpired(ctx context.Context) error {
now := time.Now()
return r.data.DB().WithContext(ctx).Transaction(func(tx *gorm.DB) error {
if err := tx.Unscoped().Where("created_at < ?", now.Add(-2160*time.Hour)).Delete(&operationPO{}).Error; err != nil {
return err
}
return tx.Unscoped().Where("created_at < ?", now.Add(-168*time.Hour)).Delete(&jwtBlacklistPO{}).Error
})
}