archive_delay.go 694 B

12345678910111213141516171819202122232425262728
  1. package archive
  2. import (
  3. "context"
  4. "go-common/app/job/main/videoup-report/model/archive"
  5. "go-common/library/database/sql"
  6. "go-common/library/log"
  7. )
  8. const (
  9. _delaysSQL = "SELECT id,aid,dtime,type,state FROM archive_delay WHERE aid=? AND deleted_at = 0 ORDER BY dtime DESC LIMIT 1"
  10. )
  11. // Delay get delay by aid
  12. func (d *Dao) Delay(c context.Context, aid int64) (delay *archive.Delay, err error) {
  13. rows := d.db.QueryRow(c, _delaysSQL, aid)
  14. delay = &archive.Delay{}
  15. if err = rows.Scan(&delay.ID, &delay.Aid, &delay.DTime, &delay.Type, &delay.State); err != nil {
  16. if err == sql.ErrNoRows {
  17. delay = nil
  18. err = nil
  19. } else {
  20. log.Error("row.Scan error(%v)", err)
  21. }
  22. }
  23. return
  24. }