当前位置: 首页>>代码示例>>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;未经允许,请勿转载。