當前位置: 首頁>>代碼示例>>Golang>>正文


Golang SqlExecutor.Get方法代碼示例

本文整理匯總了Golang中github.com/coopernurse/gorp.SqlExecutor.Get方法的典型用法代碼示例。如果您正苦於以下問題:Golang SqlExecutor.Get方法的具體用法?Golang SqlExecutor.Get怎麽用?Golang SqlExecutor.Get使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/coopernurse/gorp.SqlExecutor的用法示例。


在下文中一共展示了SqlExecutor.Get方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: 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
}
開發者ID:kayac,項目名稱:alphawing,代碼行數:7,代碼來源:bundle.go

示例2: 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
}
開發者ID:pyanfield,項目名稱:revel,代碼行數:26,代碼來源:booking.go

示例3: 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
}
開發者ID:kayac,項目名稱:alphawing,代碼行數:7,代碼來源:user.go

示例4: 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))
}
開發者ID:gitter-badger,項目名稱:warnabroda-server,代碼行數:29,代碼來源:warnings.go

示例5: 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
}
開發者ID:kayac,項目名稱:alphawing,代碼行數:7,代碼來源:authority.go

示例6: SaveOrUpdateMessage

func SaveOrUpdateMessage(entity models.MessageStruct, enc Encoder, db gorp.SqlExecutor, user sessionauth.User) (int, string) {

	u := UserById(user.UniqueId().(int), db)

	if user.IsAuthenticated() && u.UserRole == models.ROLE_ADMIN {

		entity.Last_modified_by = user.UniqueId().(int)

		if entity.Id < 1 {
			err := db.Insert(&entity)
			if err != nil {
				checkErr(err, "insert failed")
				return http.StatusBadRequest, ""
			}
		} else {
			obj, _ := db.Get(models.MessageStruct{}, entity.Id)
			if obj == nil {
				// Invalid id, or does not exist
				return http.StatusBadRequest, ""
			}

			_, err := db.Update(&entity)
			if err != nil {
				checkErr(err, "update failed")
				return http.StatusBadRequest, ""
			}
		}

		return http.StatusOK, Must(enc.EncodeOne(entity))

	}

	return http.StatusUnauthorized, ""
}
開發者ID:gitter-badger,項目名稱:warnabroda-server,代碼行數:34,代碼來源:messages.go

示例7: 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
}
開發者ID:kayac,項目名稱:alphawing,代碼行數:7,代碼來源:audit.go

示例8: getbyid

// Convenience types for loading info from the DB
func getbyid(tx gorp.SqlExecutor, typ interface{}, id int) (interface{}, error) {
	res, err := tx.Get(typ, id)
	if err != nil {
		return nil, err
	}

	return res, nil
}
開發者ID:hackerlist,項目名稱:monty,代碼行數:9,代碼來源:api.go

示例9: GetIgnoreContactById

func GetIgnoreContactById(id int64, db gorp.SqlExecutor) *models.Ignore_List {
	obj, err := db.Get(models.Ignore_List{}, id)

	if err != nil || obj == nil {
		return nil
	}

	entity := obj.(*models.Ignore_List)
	return entity
}
開發者ID:gitter-badger,項目名稱:warnabroda-server,代碼行數:10,代碼來源:ignore_list.go

示例10: GetReplyById

func GetReplyById(id int64, db gorp.SqlExecutor) *models.WarningResp {

	obj, err := db.Get(models.WarningResp{}, id)

	if err != nil || obj == nil {
		return nil
	}

	entity := obj.(*models.WarningResp)
	return entity
}
開發者ID:gitter-badger,項目名稱:warnabroda-server,代碼行數:11,代碼來源:warnings.go

示例11: GetSubject

// Get a subject by ID
func GetSubject(enc Encoder, db gorp.SqlExecutor, parms martini.Params) (int, string) {
	id, err := strconv.Atoi(parms["id"])
	obj, _ := db.Get(models.DefaultStruct{}, id)
	if err != nil || obj == nil {
		checkErr(err, "GET SUBJECT FAILED")
		// Invalid id, or does not exist
		return http.StatusNotFound, ""
	}
	entity := obj.(*models.DefaultStruct)
	return http.StatusOK, Must(enc.EncodeOne(entity))
}
開發者ID:gitter-badger,項目名稱:warnabroda-server,代碼行數:12,代碼來源:subjects.go

示例12: GetContact_type

func GetContact_type(enc Encoder, db gorp.SqlExecutor, parms martini.Params) (int, string) {
	id, err := strconv.Atoi(parms["id"])
	obj, _ := db.Get(models.DefaultStruct{}, id)
	if err != nil || obj == nil {
		checkErr(err, "GET CONTACT TYPE FAILED")
		// Invalid id, or does not exist
		return http.StatusBadRequest, ""
	}
	entity := obj.(*models.DefaultStruct)
	return http.StatusOK, Must(enc.EncodeOne(entity))
}
開發者ID:gitter-badger,項目名稱:warnabroda-server,代碼行數:11,代碼來源:contact_types.go

示例13: UserById

func UserById(id int, db gorp.SqlExecutor) *models.User {

	obj, err := db.Get(models.User{}, id)

	if err != nil || obj == nil {
		return nil
	}
	entity := obj.(*models.User)

	return entity
}
開發者ID:gitter-badger,項目名稱:warnabroda-server,代碼行數:11,代碼來源:user.go

示例14: GetWarning

func GetWarning(id int64, db gorp.SqlExecutor) *models.Warning {

	obj, err := db.Get(models.Warning{}, id)

	if err != nil || obj == nil {
		return nil
	}

	entity := obj.(*models.Warning)
	return entity
}
開發者ID:gitter-badger,項目名稱:warnabroda-server,代碼行數:11,代碼來源:warnings.go

示例15: notifyReplyDone

func notifyReplyDone(entity *models.WarningResp, db gorp.SqlExecutor) {
	obj, err := db.Get(models.Warning{}, entity.Id_warning)
	if err == nil {
		warningObj := obj.(*models.Warning)
		warningObj.WarnResp = entity

		if strings.Contains(entity.Reply_to, "@") { //notify the reply is ready via e-mail
			SendEmailReplyDone(warningObj, db)
		} else { //notify the reply is ready via e-mail
			SendWhatsappReplyDone(warningObj, db)
		}
	}

}
開發者ID:gitter-badger,項目名稱:warnabroda-server,代碼行數:14,代碼來源:warnings.go


注:本文中的github.com/coopernurse/gorp.SqlExecutor.Get方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。