本文整理匯總了Golang中OnlineJudge/models.User.GetByUsername方法的典型用法代碼示例。如果您正苦於以下問題:Golang User.GetByUsername方法的具體用法?Golang User.GetByUsername怎麽用?Golang User.GetByUsername使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OnlineJudge/models.User
的用法示例。
在下文中一共展示了User.GetByUsername方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Show
// To-do: Show programs solved by the user
func (this *UserController) Show() {
if this.Ctx.Input.Param("0") == "" {
this.Abort("404")
}
user := models.User{Username: this.Ctx.Input.Param("0")}
if user.GetByUsername() {
this.Data["title"] = user.Username
this.Data["userDetails"] = user
log := models.Problemlogs{Uid: user.Uid}
logs, count := log.GetByUid()
problems := make(map[int]models.Problem)
if count == 0 {
this.Data["solvedProblemsExist"] = false
} else {
this.Data["solvedProblemsExist"] = true
for index, element := range logs {
p := models.Problem{Pid: element.Pid}
p.GetByPid()
problems[index] = p
}
}
this.Data["solvedProblems"] = problems
this.Layout = "layout.tpl"
this.TplNames = "user/show.tpl"
this.LayoutSections = make(map[string]string)
this.LayoutSections["HtmlHead"] = ""
this.LayoutSections["Sidebar"] = ""
} else {
this.Abort("404")
}
}