本文整理汇总了Golang中github.com/coopernurse/gorp.SqlExecutor类的典型用法代码示例。如果您正苦于以下问题:Golang SqlExecutor类的具体用法?Golang SqlExecutor怎么用?Golang SqlExecutor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SqlExecutor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetAuthority
func GetAuthority(txn gorp.SqlExecutor, id int) (*Authority, error) {
authority, err := txn.Get(Authority{}, id)
if err != nil {
return nil, err
}
return authority.(*Authority), nil
}
示例2: SetReply
func SetReply(entity models.WarningResp, enc Encoder, db gorp.SqlExecutor) (int, string) {
if isInvalidReply(&entity) {
return http.StatusBadRequest, Must(enc.EncodeOne(entity))
}
obj, err := db.Get(models.WarningResp{}, entity.Id)
replyObj := obj.(*models.WarningResp)
if err != nil || replyObj == nil || entity.Resp_hash != replyObj.Resp_hash {
return http.StatusBadRequest, ""
} else {
replyObj.Message = entity.Message
replyObj.Ip = entity.Ip
replyObj.Browser = entity.Browser
replyObj.Operating_system = entity.Operating_system
replyObj.Device = entity.Device
replyObj.Raw = entity.Raw
replyObj.Reply_date = entity.Reply_date
replyObj.Timezone = entity.Timezone
go notifyReplyDone(replyObj, db)
_, err = db.Update(replyObj)
checkErr(err, "ERROR UpdateWarningSent ERROR")
}
return http.StatusOK, Must(enc.EncodeOne(replyObj))
}
示例3: SelectOne
func SelectOne(s gorp.SqlExecutor, builder squirrel.SelectBuilder, src interface{}) error {
sql, args, err := builder.ToSql()
if err != nil {
return err
}
return s.SelectOne(src, sql, args...)
}
示例4: GetAudit
func GetAudit(txn gorp.SqlExecutor, id int) (*Audit, error) {
audit, err := txn.Get(Audit{}, id)
if err != nil {
return nil, err
}
return audit.(*Audit), nil
}
示例5: PostGet
func (b *Booking) PostGet(exe gorp.SqlExecutor) error {
var (
obj interface{}
err error
)
obj, err = exe.Get(User{}, b.UserId)
if err != nil {
return fmt.Errorf("Error loading a booking's user (%d): %s", b.UserId, err)
}
b.User = obj.(*User)
obj, err = exe.Get(Hotel{}, b.HotelId)
if err != nil {
return fmt.Errorf("Error loading a booking's hotel (%d): %s", b.HotelId, err)
}
b.Hotel = obj.(*Hotel)
if b.CheckInDate, err = time.Parse(SQL_DATE_FORMAT, b.CheckInStr); err != nil {
return fmt.Errorf("Error parsing check in date '%s':", b.CheckInStr, err)
}
if b.CheckOutDate, err = time.Parse(SQL_DATE_FORMAT, b.CheckOutStr); err != nil {
return fmt.Errorf("Error parsing check out date '%s':", b.CheckOutStr, err)
}
return nil
}
示例6: UpdateIgnoreList
func UpdateIgnoreList(entity *models.Ignore_List, db gorp.SqlExecutor) {
_, err := db.Update(entity)
if err != nil {
checkErr(err, "update failed")
}
}
示例7: UpdateIgnoreSent
func UpdateIgnoreSent(entity *models.Ignore_List, db gorp.SqlExecutor) bool {
entity.Sent = true
entity.Last_modified_date = time.Now().String()
_, err := db.Update(entity)
checkErr(err, "ERROR UpdateWarningSent ERROR")
return err == nil
}
示例8: GetAppByApiToken
func GetAppByApiToken(txn gorp.SqlExecutor, apiToken string) (*App, error) {
var app App
if err := txn.SelectOne(&app, "SELECT * FROM app where api_token = ?", apiToken); err != nil {
return nil, err
}
return &app, nil
}
示例9: GetApp
func GetApp(txn gorp.SqlExecutor, id int) (*App, error) {
var app App
if err := txn.SelectOne(&app, "SELECT * FROM app WHERE id = ?", id); err != nil {
return nil, err
}
return &app, nil
}
示例10: GetBundleByFileId
func GetBundleByFileId(txn gorp.SqlExecutor, fileId string) (*Bundle, error) {
var bundle Bundle
if err := txn.SelectOne(&bundle, "SELECT * FROM bundle WHERE file_id = ?", fileId); err != nil {
return nil, err
}
return &bundle, nil
}
示例11: GetBundle
func GetBundle(txn gorp.SqlExecutor, id int) (*Bundle, error) {
var bundle Bundle
if err := txn.SelectOne(&bundle, "SELECT * FROM bundle WHERE id = ?", id); err != nil {
return nil, err
}
return &bundle, nil
}
示例12: App
func (bundle *Bundle) App(txn gorp.SqlExecutor) (*App, error) {
app, err := txn.Get(App{}, bundle.AppId)
if err != nil {
return nil, err
}
return app.(*App), nil
}
示例13: GetUser
func GetUser(txn gorp.SqlExecutor, id int) (*User, error) {
user, err := txn.Get(User{}, id)
if err != nil {
return nil, err
}
return user.(*User), nil
}
示例14: UpdateReplySent
func UpdateReplySent(entity *models.WarningResp, db gorp.SqlExecutor) bool {
entity.Sent = true
_, err := db.Update(entity)
checkErr(err, "ERROR UpdateReplySent ERROR")
return err == nil
}
示例15: GetMaxRevisionByBundleVersion
func (app *App) GetMaxRevisionByBundleVersion(txn gorp.SqlExecutor, bundleVersion string) (int, error) {
revision, err := txn.SelectInt(
"SELECT IFNULL(MAX(revision), 0) FROM bundle WHERE app_id = ? AND bundle_version = ?",
app.Id,
bundleVersion,
)
return int(revision), err
}