aso_full_migration.go 841 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package service
  2. import (
  3. "context"
  4. "go-common/app/job/main/passport-encrypt/model"
  5. "go-common/library/log"
  6. )
  7. // fullMigration full migration
  8. func (s *Service) fullMigration(start, end, inc, limit int64, group string) {
  9. var count int64
  10. for {
  11. log.Info(" group is %s,start %d, end %d,inc %d,limit %d", group, start, end, inc, limit)
  12. var (
  13. res []*model.OriginAccount
  14. err error
  15. effected int64
  16. )
  17. if res, err = s.d.AsoAccounts(context.TODO(), start, end); err != nil {
  18. log.Error("error is (%+v)\n", err)
  19. break
  20. }
  21. for _, acc := range res {
  22. enAcc := EncryptAccount(acc)
  23. if effected, err = s.d.AddAsoAccount(context.TODO(), enAcc); err != nil || effected == 0 {
  24. log.Error("insert error (%+v)", err)
  25. }
  26. }
  27. start = end
  28. count = end
  29. end = end + inc
  30. if count >= limit {
  31. break
  32. }
  33. }
  34. }