当前位置: 首页>>代码示例>>Golang>>正文


Golang SqlExecutor.Update方法代码示例

本文整理汇总了Golang中github.com/coopernurse/gorp.SqlExecutor.Update方法的典型用法代码示例。如果您正苦于以下问题:Golang SqlExecutor.Update方法的具体用法?Golang SqlExecutor.Update怎么用?Golang SqlExecutor.Update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/coopernurse/gorp.SqlExecutor的用法示例。


在下文中一共展示了SqlExecutor.Update方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: UpdateIgnoreList

func UpdateIgnoreList(entity *models.Ignore_List, db gorp.SqlExecutor) {

	_, err := db.Update(entity)
	if err != nil {
		checkErr(err, "update failed")
	}
}
开发者ID:gitter-badger,项目名称:warnabroda-server,代码行数:7,代码来源:ignore_list.go

示例2: 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
}
开发者ID:gitter-badger,项目名称:warnabroda-server,代码行数:7,代码来源:ignore_list.go

示例3: 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

示例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: 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
}
开发者ID:gitter-badger,项目名称:warnabroda-server,代码行数:7,代码来源:warnings.go

示例6: RefreshToken

func (app *App) RefreshToken(txn gorp.SqlExecutor) error {
	current, err := GetApp(txn, app.Id)
	if err != nil {
		return err
	}

	current.ApiToken = NewToken()

	_, err = txn.Update(current)
	return err
}
开发者ID:kayac,项目名称:alphawing,代码行数:11,代码来源:app.go

示例7: Update

func (app *App) Update(txn gorp.SqlExecutor) error {
	current, err := GetApp(txn, app.Id)
	if err != nil {
		return err
	}

	current.Title = app.Title
	current.Description = app.Description

	_, err = txn.Update(current)
	return err
}
开发者ID:kayac,项目名称:alphawing,代码行数:12,代码来源:app.go

示例8: Update

func (bundle *Bundle) Update(txn gorp.SqlExecutor) error {
	current, err := GetBundle(txn, bundle.Id)
	if err != nil {
		return err
	}

	current.Description = bundle.Description
	if bundle.FileId != "" {
		current.FileId = bundle.FileId
	}

	_, err = txn.Update(current)
	return err
}
开发者ID:kayac,项目名称:alphawing,代码行数:14,代码来源:bundle.go

示例9: UpdateContact_type

func UpdateContact_type(entity models.DefaultStruct, 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, ""
	}
	oldEntity := obj.(*models.DefaultStruct)

	entity.Id = oldEntity.Id
	_, err = db.Update(&entity)
	if err != nil {
		checkErr(err, "UPDATE CONTACT TYPE FAILED")
		return http.StatusBadRequest, ""
	}
	return http.StatusOK, Must(enc.EncodeOne(entity))
}
开发者ID:gitter-badger,项目名称:warnabroda-server,代码行数:18,代码来源:contact_types.go

示例10: PreInsert

func (f *Feed) PreInsert(s gorp.SqlExecutor) error {
	f.Created = milli.Timestamp(time.Now())
	f.Updated = milli.Timestamp(time.Now())

	icon := ""
	switch FeedType(f.Type) {
	case FeedTypeFacebook:
		// get user from facebook api
		session := facebookSession()
		route := fmt.Sprintf("/%s", f.Identifier)
		result, err := session.Api(route, facebook.GET, nil)
		if err != nil {
			return httperr.New(http.StatusBadRequest, "invalid facebook id", err)
		}
		// decode response
		user := &fbookUser{}
		if err := result.Decode(user); err != nil {
			return err
		}
		icon = user.Cover.Source
	case FeedTypeTwitter:
		api := twitterAPI()
		user, err := api.GetUsersShow(f.Identifier, url.Values{})
		if err != nil {
			return err
		}
		icon = user.ProfileImageURL
	}

	if icon != "" {
		member := &Member{}
		if err := sqlutil.SelectOneRelation(s, TableNameMember, f.MemberID, member); err != nil {
			return err
		}
		member.Icon = icon

		if _, err := s.Update(member); err != nil {
			return err
		}
	}

	return f.Validate()
}
开发者ID:nancyandrews,项目名称:MobileMainStreet,代码行数:43,代码来源:feed.go

示例11: DecayScores

func DecayScores(s gorp.SqlExecutor) error {
	current := milli.Timestamp(time.Now())
	yesterday := milli.Timestamp(time.Now().Add(time.Hour * -24))
	tenDaysAgo := milli.Timestamp(time.Now().Add((time.Hour * 24) * 10))
	query := squirrel.Select("*").From(TableNameStory).
		Where("!(LastDecayTimestamp between ? and ?)", yesterday, current).
		Where("Timestamp > ?", tenDaysAgo)

	stories := []*Story{}
	sqlutil.Select(s, query, &stories)
	for _, story := range stories {
		story.Score /= 2.0
		story.LastDecayTimestamp = milli.Timestamp(time.Now())
		if _, err := s.Update(story); err != nil {
			return err
		}
	}
	return nil
}
开发者ID:nancyandrews,项目名称:MobileMainStreet,代码行数:19,代码来源:story.go

示例12: ReadReply

func ReadReply(entity models.WarningResp, enc Encoder, db gorp.SqlExecutor) (int, string) {

	if isInvalidReplyRead(&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.Read_hash != replyObj.Read_hash {
		return http.StatusBadRequest, ""
	} else {
		replyObj.Response_read = entity.Response_read

		_, err = db.Update(replyObj)
		checkErr(err, "ERROR UpdateReplySent ERROR")
	}

	return http.StatusOK, ""

}
开发者ID:gitter-badger,项目名称:warnabroda-server,代码行数:21,代码来源:warnings.go

示例13: DoLogout

func DoLogout(enc Encoder, session sessions.Session, user sessionauth.User, db gorp.SqlExecutor) (int, string) {

	status := &models.DefaultStruct{
		Id:       http.StatusOK,
		Name:     messages.GetLocaleMessage("en", "MSG_LOGIN_REQUIRED"),
		Lang_key: "en",
	}

	if user.IsAuthenticated() {

		sessionauth.Logout(session, user)
		session.Clear()
		status.Name = messages.GetLocaleMessage("en", "MSG_SUCCESSFUL_LOGOUT")
	}

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

	updateUser.Authenticated = false
	db.Update(updateUser)

	return http.StatusOK, Must(enc.EncodeOne(status))
}
开发者ID:gitter-badger,项目名称:warnabroda-server,代码行数:22,代码来源:user.go

示例14: PostInsert

func (story *Story) PostInsert(s gorp.SqlExecutor) error {
	m := &Member{}
	if err := sqlutil.SelectOneRelation(s, TableNameMember, story.MemberID, m); err != nil {
		return err
	}

	images := append(story.ImagesSlice(), m.ImagesSlice()...)
	m.SetImages(images)

	hashtags := append(story.HashtagsSlice(), m.HashtagsSlice()...)
	m.SetHashtags(hashtags)

	s.Update(m)

	feed := &Feed{}
	if err := sqlutil.SelectOneRelation(s, TableNameFeed, story.FeedID, feed); err != nil {
		return err
	}
	if story.Timestamp > feed.LastRetrieved {
		feed.LastRetrieved = story.Timestamp
		s.Update(feed)
	}
	return nil
}
开发者ID:nancyandrews,项目名称:MobileMainStreet,代码行数:24,代码来源:story.go

示例15: Update

func (user *User) Update(txn gorp.SqlExecutor) error {
	_, err := txn.Update(user)
	return err
}
开发者ID:kayac,项目名称:alphawing,代码行数:4,代码来源:user.go


注:本文中的github.com/coopernurse/gorp.SqlExecutor.Update方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。