package controllers import ( "encoding/json" "hongze/hongze_mfyx/models" ) // Banner type BannerController struct { BaseAuthController } // @Title 首页banner图片 // @Description 研选banner列表接口 // @Success Ret=200 {object} cygx.BannerUrHomeListResp // @router /listhome [get] func (this *BannerController) ListHome() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() user := this.User if user == nil { br.Msg = "请登录" br.ErrMsg = "请登录,用户信息为空" br.Ret = 408 return } resp := new(models.BannerUrHomeListResp) //var list []*models.BannerUrlYxResp list := new(models.BannerUrHomeListResp) //list = []*models.BannerUrlYxResp{ // &models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/1.png", Path: "pages-purchaser/leaflet/leaflet?leafletImage=https%3A%2F%2Fhzstatic.hzinsights.com%2Fcygx%2Fconfig%2Fresearch_11_0.png"}, // &models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/2.png", Path: "pages-purchaser/survey/surveySubmit"}, // &models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/4.png", Path: "pages-purchaser/specialColumn/specialColumn"}, // &models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/3_long.png", Path: "pages-purchaser/researchList/researchList"}, //} key := "mfyx_banner_list" conf, e := models.GetConfigByCode(key) if e != nil { br.Msg = "获取失败" br.ErrMsg = "获取首页头部导航失败, Err: " + e.Error() return } if conf.ConfigValue == "" { br.Msg = "获取失败" br.ErrMsg = "首页头部导航配置值有误" return } //list := new(*models.BannerUrlYxResp) if e = json.Unmarshal([]byte(conf.ConfigValue), &list); e != nil { br.Msg = "获取失败" br.ErrMsg = "首页头部导航配置值解析失败, Err: " + e.Error() return } //resp.List := list //if searchPage == 1 { // resp = list.SearchPage //} resp.List = list.List br.Ret = 200 br.Success = true br.Msg = "获取成功" br.Data = resp }