reason.go 726 B

123456789101112131415161718192021222324252627282930
  1. package manager
  2. import (
  3. "context"
  4. xsql "database/sql"
  5. "go-common/library/log"
  6. )
  7. const (
  8. _reasonSQL = "SELECT reason.tag_id as tag_id from reason_log left join reason on reason_log.reason_id=reason.id where reason_log.type=1 AND reason_log.oid=? order by reason_log.id desc limit 1;"
  9. )
  10. // ArcReason get a archive reason tag
  11. func (d *Dao) ArcReason(c context.Context, aid int64) (tagID int64, err error) {
  12. var (
  13. row = d.managerDB.QueryRow(c, _reasonSQL, aid)
  14. tagIDI xsql.NullInt64
  15. )
  16. if err := row.Scan(&tagIDI); err != nil {
  17. if err == xsql.ErrNoRows {
  18. err = nil
  19. } else {
  20. log.Error("ArcReason row.Scan error(%v)", err)
  21. }
  22. }
  23. log.Info("ArcReason retrun(%v)", tagIDI)
  24. tagID = tagIDI.Int64
  25. return
  26. }