go-common/app/infra/config/dao/v2/force.go

23 lines
499 B
Go
Raw Normal View History

2019-04-22 10:49:16 +00:00
package v2
import (
"database/sql"
"go-common/app/infra/config/model"
"go-common/library/log"
)
// Force get force by ID.
func (d *Dao) Force(appID int64, hostname string) (version int64, err error) {
row := d.DB.Select("version").Where("app_id = ? and hostname = ?", appID, hostname).Model(&model.Force{}).Row()
if err = row.Scan(&version); err != nil {
if err == sql.ErrNoRows {
err = nil
version = 0
} else {
log.Error("version(%v) error(%v)", version, err)
}
}
return
}