track.go 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. package track
  2. import (
  3. "context"
  4. "go-common/app/admin/main/videoup/model/track"
  5. "go-common/library/log"
  6. )
  7. const (
  8. _arcTrackSQL = "SELECT state,round,remark,ctime,attribute FROM archive_track WHERE aid=? ORDER BY id DESC"
  9. _vdoTrackSQL = "SELECT aid,xcode_state,status,remark,ctime FROM archive_video_track WHERE filename=? AND aid=? ORDER BY id DESC"
  10. )
  11. // ArchiveTrack get archive track info.
  12. func (d *Dao) ArchiveTrack(c context.Context, aid int64) (res []*track.Archive, err error) {
  13. rows, err := d.db.Query(c, _arcTrackSQL, aid)
  14. if err != nil {
  15. log.Error("ArchiveTrack d.arcTrackStmt.Query(%d) error(%v)", aid, err)
  16. return
  17. }
  18. defer rows.Close()
  19. res = make([]*track.Archive, 0)
  20. for rows.Next() {
  21. a := &track.Archive{}
  22. if err = rows.Scan(&a.State, &a.Round, &a.Remark, &a.Timestamp, &a.Attribute); err != nil {
  23. log.Error("ArchiveTrack rows.Scan() error(%v)", err)
  24. return
  25. }
  26. res = append(res, a)
  27. }
  28. return
  29. }
  30. // VideoTrack get video track info.
  31. func (d *Dao) VideoTrack(c context.Context, filename string, aid int64) (res []*track.Video, er error) {
  32. rows, err := d.db.Query(c, _vdoTrackSQL, filename, aid)
  33. if err != nil {
  34. log.Error("VideoTrack d.vdoTrackStmt.Query(%s, %d) error(%v)", filename, aid, err)
  35. return
  36. }
  37. defer rows.Close()
  38. res = make([]*track.Video, 0)
  39. for rows.Next() {
  40. v := &track.Video{}
  41. if err = rows.Scan(&v.AID, &v.XCodeState, &v.Status, &v.Remark, &v.Timestamp); err != nil {
  42. log.Error("VideoTrack rows.Scan() error(%v)", err)
  43. return
  44. }
  45. res = append(res, v)
  46. }
  47. return
  48. }