MCPcopy Index your code
hub / github.com/TruthHun/DocHub / Get

Method Get

controllers/HomeControllers/IndexController.go:17–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

15}
16
17func (this *IndexController) Get() {
18
19 //获取横幅
20 this.Data["Banners"], _, _ = models.GetList(models.GetTableBanner(), 1, 100, orm.NewCondition().And("status", 1), "Sort")
21
22 //判断用户是否已登录,如果已登录,则返回用户信息
23 if this.IsLogin > 0 {
24 users, rows, err := models.NewUser().UserList(1, 1, "", "*", "i.`Id`=?", this.IsLogin)
25 if err != nil {
26 helper.Logger.Error(err.Error())
27 }
28 if rows > 0 {
29 this.Data["User"] = users[0]
30 } else {
31 //如果用户不存在,则重置cookie
32 this.IsLogin = 0
33 this.ResetCookie()
34 }
35 this.Data["LoginUid"] = this.IsLogin
36 } else {
37 this.Xsrf()
38 }
39
40 modelCate := models.NewCategory()
41 //首页分类显示
42 _, this.Data["Cates"] = modelCate.GetAll(true)
43 this.Data["Latest"], _, _ = models.NewDocument().SimpleList(fmt.Sprintf("d.`Id` in(%v)", strings.Trim(this.Sys.Trends, ",")), 5)
44 this.Data["Seo"] = models.NewSeo().GetByPage("PC-Index", "文库首页", "文库首页", "文库首页", this.Sys.Site)
45 this.Data["IsHome"] = true
46 this.Data["PageId"] = "wenku-index"
47 this.TplName = "index.html"
48}

Callers

nothing calls this directly

Calls 6

GetAllMethod · 0.95
UserListMethod · 0.80
ResetCookieMethod · 0.80
SimpleListMethod · 0.80
GetByPageMethod · 0.80
XsrfMethod · 0.45

Tested by

no test coverage detected