1 Star 0 Fork 720

兴博软件/DocHub

forked from 进击的皇虫/DocHub 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
IndexController.go 1.27 KB
一键复制 编辑 原始数据 按行查看 历史
TruthHun 提交于 2019-06-12 21:26 +08:00 . 修复导航栏高亮和sitemap报404的问题
package HomeControllers
import (
"fmt"
"strings"
"github.com/TruthHun/DocHub/helper"
"github.com/TruthHun/DocHub/models"
"github.com/astaxie/beego/orm"
)
type IndexController struct {
BaseController
}
func (this *IndexController) Get() {
//获取横幅
this.Data["Banners"], _, _ = models.GetList(models.GetTableBanner(), 1, 100, orm.NewCondition().And("status", 1), "Sort")
//判断用户是否已登录,如果已登录,则返回用户信息
if this.IsLogin > 0 {
users, rows, err := models.NewUser().UserList(1, 1, "", "*", "i.`Id`=?", this.IsLogin)
if err != nil {
helper.Logger.Error(err.Error())
}
if rows > 0 {
this.Data["User"] = users[0]
} else {
//如果用户不存在,则重置cookie
this.IsLogin = 0
this.ResetCookie()
}
this.Data["LoginUid"] = this.IsLogin
} else {
this.Xsrf()
}
modelCate := models.NewCategory()
//首页分类显示
_, this.Data["Cates"] = modelCate.GetAll(true)
this.Data["Latest"], _, _ = models.NewDocument().SimpleList(fmt.Sprintf("d.`Id` in(%v)", strings.Trim(this.Sys.Trends, ",")), 5)
this.Data["Seo"] = models.NewSeo().GetByPage("PC-Index", "文库首页", "文库首页", "文库首页", this.Sys.Site)
this.Data["IsHome"] = true
this.Data["PageId"] = "wenku-index"
this.TplName = "index.html"
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/lalbe/DocHub.git
git@gitee.com:lalbe/DocHub.git
lalbe
DocHub
DocHub
dd28a31bcdb3

搜索帮助