watermark.go 954 B

1234567891011121314151617181920212223242526272829303132333435
  1. package archive
  2. import (
  3. "context"
  4. "go-common/app/admin/main/videoup/model/archive"
  5. "go-common/library/database/sql"
  6. "go-common/library/log"
  7. )
  8. const _watermark = "SELECT id, info, md5, mid, position, type, uname, url, state, mtime FROM watermark WHERE mid=? AND state != 0"
  9. //Watermark get watermark
  10. func (d *Dao) Watermark(c context.Context, mid int64) (m []*archive.Watermark, err error) {
  11. var rows *sql.Rows
  12. m = []*archive.Watermark{}
  13. if rows, err = d.creativeDB.Query(c, _watermark, mid); err != nil {
  14. log.Error("Watermark d.rddb.Query error(%v) mid(%d)", err, mid)
  15. return
  16. }
  17. defer rows.Close()
  18. for rows.Next() {
  19. wm := new(archive.Watermark)
  20. if err = rows.Scan(&wm.ID, &wm.Info, &wm.MD5, &wm.MID, &wm.Position, &wm.Type, &wm.Uname, &wm.URL, &wm.State, &wm.MTime); err != nil {
  21. log.Error("Watermark rows.Scan error(%v) mid(%d)", err, mid)
  22. return
  23. }
  24. if wm.State == "0" {
  25. continue
  26. }
  27. m = append(m, wm)
  28. }
  29. return
  30. }