check.go 883 B

1234567891011121314151617181920212223242526272829303132333435
  1. package dao
  2. import (
  3. "context"
  4. "database/sql"
  5. "fmt"
  6. "go-common/library/log"
  7. )
  8. const (
  9. _queryBvcResource = "select id from %s where svid = %d"
  10. _queryCoverResource = "select cover_url,cover_width,cover_height from video_repository where svid = ?"
  11. )
  12. //CheckSVResource ...
  13. func (d *Dao) CheckSVResource(c context.Context, svid int64) (err error) {
  14. var (
  15. ID int64
  16. cURL string
  17. cH int64
  18. cW int64
  19. )
  20. tN := fmt.Sprintf("video_bvc_%02d", svid%100)
  21. if err = d.db.QueryRow(c, fmt.Sprintf(_queryBvcResource, tN, svid)).Scan(&ID); err == sql.ErrNoRows {
  22. log.Error("CheckSVResource bvc err,svid:%d,err:%v", svid, err)
  23. return
  24. }
  25. //cover,err := d.cmsdb.QueryRow(c, query, ...)
  26. if err = d.db.QueryRow(c, _queryCoverResource, svid).Scan(&cURL, &cW, &cH); err == sql.ErrNoRows {
  27. log.Error("CheckSVResource cover err,svid:%d,err:%v", svid, err)
  28. return
  29. }
  30. return
  31. }