保存更改记录;优化同步作业日志级别

This commit is contained in:
2025-08-21 15:58:34 +08:00
parent 261ee88a4b
commit 89adb4f8a4
5 changed files with 66 additions and 2 deletions

24
actions/changes.go Normal file
View File

@@ -0,0 +1,24 @@
package actions
import (
"zzman/model"
"gorm.io/gorm"
)
func RecordChange(tx *gorm.DB, changes []model.Change) error {
if len(changes) == 0 {
return nil
}
batchSize := 1000
for i := 0; i < len(changes); i += batchSize {
end := min(i+batchSize, len(changes))
batch := changes[i:end]
err := tx.Create(&batch).Error
if err != nil {
return err
}
}
return nil
}