first_pass.go 919 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. package archive
  2. import (
  3. "context"
  4. "go-common/library/database/sql"
  5. "go-common/library/log"
  6. "time"
  7. )
  8. const (
  9. _slByAID = "SELECT `id` FROM `archive_first_pass` WHERE `aid`=? LIMIT 1;"
  10. _inFirstPass = "INSERT INTO `archive_first_pass`(`aid`, `ctime`, `mtime`) VALUES(?,?,?);"
  11. )
  12. //GetFirstPassByAID 根据aid获取第一次过审的记录
  13. func (d *Dao) GetFirstPassByAID(c context.Context, aid int64) (id int64, err error) {
  14. row := d.db.QueryRow(c, _slByAID, aid)
  15. if err = row.Scan(&id); err != nil {
  16. if err == sql.ErrNoRows {
  17. err = nil
  18. } else {
  19. log.Error("GetFirstPassByAID error(%v) aid(%d)", err, aid)
  20. }
  21. return
  22. }
  23. return
  24. }
  25. //AddFirstPass 添加一条 第一次过审的记录
  26. func (d *Dao) AddFirstPass(tx *sql.Tx, aid int64) (err error) {
  27. now := time.Now()
  28. if _, err = tx.Exec(_inFirstPass, aid, now, now); err != nil {
  29. log.Error("AddFirstPass error(%v) aid(%d)", err)
  30. }
  31. return
  32. }