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


Golang utils.ToStr函數代碼示例

本文整理匯總了Golang中github.com/beego/wetalk/modules/utils.ToStr函數的典型用法代碼示例。如果您正苦於以下問題:Golang ToStr函數的具體用法?Golang ToStr怎麽用?Golang ToStr使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


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

示例1: AvatarTypeSelectData

func (form *UserAvatarForm) AvatarTypeSelectData() [][]string {
	var data = make([][]string, 0, 2)
	data = append(data, []string{"auth.user_avatar_use_gravatar", utils.ToStr(setting.AvatarTypeGravatar)})
	data = append(data, []string{"auth.user_avatar_use_personal", utils.ToStr(setting.AvatarTypePersonalized)})

	return data
}
開發者ID:netxfly,項目名稱:wetalk,代碼行數:7,代碼來源:form.go

示例2: NewSubmit

func (this *PostRouter) NewSubmit() {
	this.TplName = "post/new.html"

	if this.CheckActiveRedirect() {
		return
	}

	form := post.PostForm{Locale: this.Locale}
	slug := this.GetString("topic")
	if len(slug) > 0 {
		topic := models.Topic{Slug: slug}
		topic.Read("Slug")
		form.Topic = topic.Id
		this.Data["Topic"] = &topic
	}

	post.ListCategories(&form.Categories)
	post.ListTopics(&form.Topics)
	if !this.ValidFormSets(&form) {
		return
	}

	var post models.Post
	if err := form.SavePost(&post, &this.User); err == nil {

		this.Ctx.SetCookie("post_topic", utils.ToStr(form.Topic), 1<<31-1, "/")
		this.Ctx.SetCookie("post_cat", utils.ToStr(form.Category), 1<<31-1, "/")
		this.Ctx.SetCookie("post_lang", utils.ToStr(form.Lang), 1<<31-1, "/")

		this.JsStorage("deleteKey", "post/new")
		this.Redirect(post.Link(), 302)
	}
}
開發者ID:wildex,項目名稱:wetalk,代碼行數:33,代碼來源:post.go

示例3: TypeSelectData

func (form *BulletinAdminForm) TypeSelectData() [][]string {
	data := [][]string{
		[]string{"model.bulletin_friend_link", utils.ToStr(setting.BULLETIN_FRIEND_LINK)},
		[]string{"model.bulletin_new_comer", utils.ToStr(setting.BULLETIN_NEW_COMER)},
		[]string{"model.bulletin_mobile_app", utils.ToStr(setting.BULLETIN_MOBILE_APP)},
		[]string{"model.bulletin_open_source", utils.ToStr(setting.BULLETIN_OPEN_SOURCE)},
	}
	return data
}
開發者ID:netxfly,項目名稱:wetalk,代碼行數:9,代碼來源:form.go

示例4: postsFilter

func (this *PostListRouter) postsFilter(qs orm.QuerySeter) orm.QuerySeter {
	if !this.IsLogin {
		return qs
	}
	args := []string{utils.ToStr(this.Locale.Index())}
	args = append(args, this.User.LangAdds...)
	args = append(args, utils.ToStr(this.User.Lang))
	qs = qs.Filter("Lang__in", args)
	return qs
}
開發者ID:wildex,項目名稱:wetalk,代碼行數:10,代碼來源:post.go

示例5: TopicSelectData

func (form *PostForm) TopicSelectData() [][]string {
	data := make([][]string, 0, len(form.Topics))
	for _, topic := range form.Topics {
		data = append(data, []string{topic.GetName(form.Locale.Lang), utils.ToStr(topic.Id)})
	}
	return data
}
開發者ID:oyoy8629,項目名稱:XWetalk,代碼行數:7,代碼來源:form.go

示例6: CategorySelectData

func (form *PostForm) CategorySelectData() [][]string {
	data := make([][]string, 0, len(form.Categories))
	for _, cat := range form.Categories {
		data = append(data, []string{"category." + cat.Name, utils.ToStr(cat.Id)})
	}
	return data
}
開發者ID:oyoy8629,項目名稱:XWetalk,代碼行數:7,代碼來源:form.go

示例7: LangAddsSelectData

func (form *UserAdminForm) LangAddsSelectData() [][]string {
	langs := setting.Langs
	data := make([][]string, 0, len(langs))
	for i, lang := range langs {
		data = append(data, []string{lang, utils.ToStr(i)})
	}
	return data
}
開發者ID:JessonChan,項目名稱:wetalk,代碼行數:8,代碼來源:form.go

示例8: CreateUserResetPwdCode

// create a time limit code for user reset password
func CreateUserResetPwdCode(user *models.User, startInf interface{}) string {
	minutes := setting.ResetPwdCodeLives
	data := utils.ToStr(user.Id) + user.Email + user.UserName + user.Password + user.Rands + user.Updated.String()
	code := utils.CreateTimeLimitCode(data, minutes, startInf)

	// add tail hex username
	code += hex.EncodeToString([]byte(user.UserName))
	return code
}
開發者ID:wildex,項目名稱:wetalk,代碼行數:10,代碼來源:auth.go

示例9: GenImageFilePath

func GenImageFilePath(img *models.Image, width int) string {
	var size string
	if width == 0 {
		size = "full"
	} else {
		size = utils.ToStr(width)
	}
	return GenImagePath(img) + size + img.GetExt()
}
開發者ID:netxfly,項目名稱:wetalk,代碼行數:9,代碼來源:storage.go

示例10: CategorySelectData

func (form *TopicAdminForm) CategorySelectData() [][]string {
	var cats []models.Category
	ListCategories(&cats)
	data := make([][]string, 0, len(cats))
	for _, cat := range cats {
		data = append(data, []string{cat.Name, utils.ToStr(cat.Id)})
	}
	return data
}
開發者ID:netxfly,項目名稱:wetalk,代碼行數:9,代碼來源:topic_form.go

示例11: avatarLink

func (m *User) avatarLink(size int) string {
	if m.AvatarType == setting.AvatarTypePersonalized {
		if m.AvatarKey != "" {
			return fmt.Sprintf("%s", utils.GetQiniuZoomViewUrl(utils.GetQiniuPublicDownloadUrl(setting.QiniuAvatarDomain, m.AvatarKey), size, size))
		} else {
			return fmt.Sprintf("http://golanghome-public.qiniudn.com/golang_avatar.png?imageView/0/w/%s/h/%s/q/100", utils.ToStr(size), utils.ToStr(size))
		}
	} else {
		return fmt.Sprintf("%s%s?size=%s", setting.AvatarURL, m.GrEmail, utils.ToStr(size))
	}
}
開發者ID:netxfly,項目名稱:wetalk,代碼行數:11,代碼來源:auth.go

示例12: CheckFlashRedirect

// check flash redirect, ensure browser redirect to uri and display flash message.
func (this *BaseRouter) CheckFlashRedirect(value string) (match bool, redirect bool) {
	v := this.GetSession("on_redirect")
	if params, ok := v.([]interface{}); ok {
		if len(params) != 5 {
			this.EndFlashRedirect()
			goto end
		}
		uri := utils.ToStr(params[0])
		code := 302
		if c, ok := params[1].(int); ok {
			if c/100 == 3 {
				code = c
			}
		}
		flag := utils.ToStr(params[2])
		flagVal := utils.ToStr(params[3])
		times := 0
		if v, ok := params[4].(int); ok {
			times = v
		}

		times += 1
		if times > 3 {
			// if max retry times reached then end
			this.EndFlashRedirect()
			goto end
		}

		// match uri or flash flag
		if uri == value || flag == value {
			match = true
		} else {
			// if no match then continue redirect
			this.FlashRedirect(uri, code, flag, flagVal, times)
			redirect = true
		}
	}
end:
	return match, redirect
}
開發者ID:wildex,項目名稱:wetalk,代碼行數:41,代碼來源:base.go

示例13: VerifyUserResetPwdCode

// verify code when reset password
func VerifyUserResetPwdCode(user *models.User, code string) bool {
	minutes := setting.ResetPwdCodeLives

	if getVerifyUser(user, code) {
		// time limit code
		prefix := code[:utils.TimeLimitCodeLength]
		data := utils.ToStr(user.Id) + user.Email + user.UserName + user.Password + user.Rands + user.Updated.String()

		return utils.VerifyTimeLimitCode(data, minutes, prefix)
	}

	return false
}
開發者ID:wildex,項目名稱:wetalk,代碼行數:14,代碼來源:auth.go

示例14: LinkSize

func (m *Image) LinkSize(width int) string {
	if m.Ext == 3 {
		// if image is gif then return full size
		width = 0
	}
	var size string
	switch width {
	case setting.ImageSizeSmall, setting.ImageSizeMiddle:
		size = utils.ToStr(width)
	default:
		size = "full"
	}
	return "/img/" + m.GetToken() + "." + size + m.GetExt()
}
開發者ID:JessonChan,項目名稱:wetalk,代碼行數:14,代碼來源:attachment.go

示例15: PostBrowsersAdd

func PostBrowsersAdd(uid int, ip string, post *models.Post) {
	var key string
	if uid == 0 {
		key = ip
	} else {
		key = utils.ToStr(uid)
	}
	key = fmt.Sprintf("PCA.%d.%s", post.Id, key)
	if setting.Cache.Get(key) != nil {
		return
	}
	_, err := models.Posts().Filter("Id", post.Id).Update(orm.Params{
		"Browsers": orm.ColValue(orm.Col_Add, 1),
	})
	if err != nil {
		beego.Error("PostCounterAdd ", err)
	}
	setting.Cache.Put(key, true, 60)
}
開發者ID:netxfly,項目名稱:wetalk,代碼行數:19,代碼來源:util.go


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