123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- package controllers
- import (
- "cc-officialweb/service"
- beego "github.com/beego/beego/v2/server/web"
- )
- type MainController struct {
- beego.Controller
- }
- func (c *MainController) Get() {
- var banner []string
- var success []string
- var honor []string
- //获取轮播图
- resource := service.GetResource("banner")
- for _, v := range resource {
- banner = append(banner, v.Url)
- }
- //获取成功案例轮播图
- exams := service.GetResource("example")
- for _, v := range exams {
- success = append(success, v.Url)
- }
- //资质荣耀
- honors := service.GetResource("honor")
- for _, v := range honors {
- honor = append(honor, v.Url)
- }
- //产品服务
- products := service.GetIndexProductServe("product")
- serve := service.GetIndexProductServe("serve")
- //数据大屏展示
- getData, err := service.GetData(true)
- if err == nil {
- c.Data["Datas"] = getData
- } else {
- c.Data["Datas"] = "未获得数据"
- }
- //友情链接
- links := service.GetAllLinks()
- if links != nil {
- c.Data["Links"] = links
- }
- //获取产品分类
- productType := service.GetProductType()
- if len(productType) == 0 {
- c.Data["productFirst"] = "暂无产品分类"
- } else {
- c.Data["productFirst"] = productType[0].Name
- }
- c.Data["productType"] = productType
- c.Data["honor"] = honor
- c.Data["banner"] = banner
- c.Data["example"] = success
- c.Data["Products"] = products
- c.Data["Serves"] = serve
- c.TplName = "index.html"
- }
|