video_audit.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. package archive
  2. import (
  3. "context"
  4. "database/sql"
  5. xsql "go-common/library/database/sql"
  6. "go-common/library/log"
  7. )
  8. const (
  9. // insert
  10. _inAuditSQL = `INSERT IGNORE INTO archive_video_audit (vid,aid,tid,oname,reason) VALUES(?,?,0,'videoup-job',?)
  11. ON DUPLICATE KEY UPDATE oname='videoup-job',reason=?`
  12. _seRsnSQL = "SELECT reason FROM archive_video_audit WHERE vid=?"
  13. )
  14. // TxAddAudit add video audit by vid.
  15. func (d *Dao) TxAddAudit(tx *xsql.Tx, vid, aid int64, reason string) (rows int64, err error) {
  16. row, err := tx.Exec(_inAuditSQL, vid, aid, reason, reason)
  17. if err != nil {
  18. log.Error("tx.Exec(%d, %d, %s) error(%v)", vid, aid, reason, err)
  19. return
  20. }
  21. return row.RowsAffected()
  22. }
  23. // Reason get a archive video reject reason by vid.
  24. func (d *Dao) Reason(c context.Context, vid int64) (reason string, err error) {
  25. row := d.db.QueryRow(c, _seRsnSQL, vid)
  26. if err = row.Scan(&reason); err != nil {
  27. if err == sql.ErrNoRows {
  28. err = nil
  29. } else {
  30. log.Error("row.Scan error(%v)", err)
  31. }
  32. }
  33. return
  34. }