本文整理汇总了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
}
示例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
}
示例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
}
示例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))
}
示例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
}
示例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, ""
}
示例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
}
示例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
}
示例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
}
示例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
}
示例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))
}
示例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))
}
示例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
}
示例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
}
示例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)
}
}
}