force.go 499 B

12345678910111213141516171819202122
  1. package v2
  2. import (
  3. "database/sql"
  4. "go-common/app/infra/config/model"
  5. "go-common/library/log"
  6. )
  7. // Force get force by ID.
  8. func (d *Dao) Force(appID int64, hostname string) (version int64, err error) {
  9. row := d.DB.Select("version").Where("app_id = ? and hostname = ?", appID, hostname).Model(&model.Force{}).Row()
  10. if err = row.Scan(&version); err != nil {
  11. if err == sql.ErrNoRows {
  12. err = nil
  13. version = 0
  14. } else {
  15. log.Error("version(%v) error(%v)", version, err)
  16. }
  17. }
  18. return
  19. }