本文整理匯總了Golang中github.com/beego/wetalk/utils.ToStr函數的典型用法代碼示例。如果您正苦於以下問題:Golang ToStr函數的具體用法?Golang ToStr怎麽用?Golang ToStr使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了ToStr函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: postsFilter
func (this *PostListRouter) postsFilter(qs orm.QuerySeter) orm.QuerySeter {
args := []string{utils.ToStr(this.Locale.Index())}
if this.isLogin {
args = append(args, this.user.LangAdds...)
args = append(args, utils.ToStr(this.user.Lang))
}
qs = qs.Filter("Lang__in", args)
return qs
}
示例2: 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
}
示例3: 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
}
示例4: LangSelectData
func (form *PostForm) LangSelectData() [][]string {
langs := utils.Langs
data := make([][]string, 0, len(langs))
for i, lang := range langs {
data = append(data, []string{lang, utils.ToStr(i)})
}
return data
}
示例5: CreateUserResetPwdCode
// create a time limit code for user reset password
func CreateUserResetPwdCode(user *User, startInf interface{}) string {
hours := utils.ResetPwdCodeLives
data := utils.ToStr(user.Id) + user.Email + user.UserName + user.Password + user.Rands + user.Updated.String()
code := utils.CreateTimeLimitCode(data, hours, startInf)
// add tail hex username
code += hex.EncodeToString([]byte(user.UserName))
return code
}
示例6: GenImageFilePath
func GenImageFilePath(img *Image, width int) string {
var size string
if width == 0 {
size = "full"
} else {
size = utils.ToStr(width)
}
return GenImagePath(img) + size + img.GetExt()
}
示例7: 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
}
示例8: VerifyUserResetPwdCode
// verify code when reset password
func VerifyUserResetPwdCode(user *User, code string) bool {
hours := utils.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, hours, prefix)
}
return false
}
示例9: 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 utils.ImageSizeSmall, utils.ImageSizeMiddle:
size = utils.ToStr(width)
default:
size = "full"
}
return "/img/" + m.GetToken() + "." + size + m.GetExt()
}
示例10: PostBrowsersAdd
func PostBrowsersAdd(uid int, ip string, post *Post) {
var key string
if uid == 0 {
key = ip
} else {
key = utils.ToStr(uid)
}
key = fmt.Sprintf("PCA.%d.%s", post.Id, key)
if utils.Cache.Get(key) != nil {
return
}
_, err := Posts().Filter("Id", post.Id).Update(orm.Params{
"Browsers": orm.ColValue(orm.Col_Add, 1),
})
if err != nil {
beego.Error("PostCounterAdd ", err)
}
utils.Cache.Put(key, true, 60)
}
示例11: String
func (m *Category) String() string {
return utils.ToStr(m.Id)
}
示例12: String
func (m *Article) String() string {
return utils.ToStr(m.Id)
}
示例13: GenImagePath
func GenImagePath(img *Image) string {
return "upload/img/" + beego.Date(img.Created, "y/m/d/s/") + utils.ToStr(img.Id) + "/"
}
示例14: String
func (m *Post) String() string {
return utils.ToStr(m.Id)
}
示例15: String
func (m *User) String() string {
return utils.ToStr(m.Id)
}