video.go 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. package result
  2. import (
  3. "context"
  4. "go-common/app/job/main/archive/model/archive"
  5. "go-common/library/database/sql"
  6. "go-common/library/log"
  7. )
  8. const (
  9. _inVideoSQL = `INSERT INTO archive_video (aid,eptitle,description,filename,src_type,cid,duration,index_order,attribute,weblink,dimensions) VALUES(?,?,?,?,?,?,?,?,?,?,?)
  10. ON DUPLICATE KEY UPDATE eptitle=?,description=?,filename=?,src_type=?,duration=?,index_order=?,attribute=?,weblink=?,dimensions=?`
  11. _delVideoByCidSQL = "DELETE FROM archive_video where aid=? and cid=?"
  12. _delVideosSQL = "DELETE FROM archive_video WHERE aid=?"
  13. )
  14. // TxAddVideo add videos result
  15. func (d *Dao) TxAddVideo(c context.Context, tx *sql.Tx, v *archive.Video) (rows int64, err error) {
  16. res, err := tx.Exec(_inVideoSQL, v.Aid, v.Title, v.Desc, v.Filename, v.SrcType, v.Cid, v.Duration, v.Index, v.Attribute, v.WebLink, v.Dimensions,
  17. v.Title, v.Desc, v.Filename, v.SrcType, v.Duration, v.Index, v.Attribute, v.WebLink, v.Dimensions)
  18. if err != nil {
  19. log.Error("tx.Exec error(%v)", err)
  20. return
  21. }
  22. return res.RowsAffected()
  23. }
  24. // TxDelVideoByCid del videos by aid and cid
  25. func (d *Dao) TxDelVideoByCid(c context.Context, tx *sql.Tx, aid, cid int64) (rows int64, err error) {
  26. res, err := tx.Exec(_delVideoByCidSQL, aid, cid)
  27. if err != nil {
  28. log.Error("tx.Exec error(%v)", err)
  29. return
  30. }
  31. return res.RowsAffected()
  32. }
  33. // TxDelVideos del videos
  34. func (d *Dao) TxDelVideos(c context.Context, tx *sql.Tx, aid int64) (rows int64, err error) {
  35. res, err := tx.Exec(_delVideosSQL, aid)
  36. if err != nil {
  37. log.Error("tx.Exec(%s, %d) error(%v)", _delVideosSQL, aid, err)
  38. return
  39. }
  40. return res.RowsAffected()
  41. }