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