()
| 15 | } |
| 16 | |
| 17 | func (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 | } |
nothing calls this directly
no test coverage detected