| | |
| | | return "caches" |
| | | } |
| | | |
| | | func (c *Cache) First() error { |
| | | return db.Table(c.TableName()).First(c).Error |
| | | } |
| | | |
| | | func (c *Cache) FindAll() ([]Cache, error) { |
| | | var caches []Cache |
| | | if err := db.Table(c.TableName()).Find(&caches).Error; err != nil { |
| | |
| | | return caches, nil |
| | | } |
| | | |
| | | func (c *Cache) Count() (int64, error) { |
| | | var total int64 |
| | | if err := db.Table(c.TableName()).Count(&total).Error; err != nil { |
| | | return total, err |
| | | } |
| | | |
| | | return total, nil |
| | | } |
| | | |
| | | func (c *Cache) Save() error { |
| | | return db.Table(c.TableName()).Save(c).Error |
| | | } |
| | |
| | | |
| | | func ResendImageData() { |
| | | var cacheMod models.Cache |
| | | cacheItems, _ := cacheMod.FindAll() |
| | | logger.Debug("Start resend task. cache len:%d", len(cacheItems)) |
| | | total, _ := cacheMod.Count() |
| | | logger.Debug("Start resend task. cache len:%d", total) |
| | | |
| | | for _, c := range cacheItems { |
| | | for i := 0; i < int(total); i++ { |
| | | var c models.Cache |
| | | err := c.First() |
| | | if err != nil { |
| | | logger.Error(err.Error()) |
| | | return |
| | | } |
| | | if c.Type == "1400" { |
| | | if client.FaceCapture([]byte(c.Data)) != vo.StatusSuccess { |
| | | c.UpdateRetryCount() |