banner.go 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "hongze/hongze_mfyx/models"
  5. )
  6. // Banner
  7. type BannerController struct {
  8. BaseAuthController
  9. }
  10. // @Title 首页banner图片
  11. // @Description 研选banner列表接口
  12. // @Success Ret=200 {object} cygx.BannerUrHomeListResp
  13. // @router /listhome [get]
  14. func (this *BannerController) ListHome() {
  15. br := new(models.BaseResponse).Init()
  16. defer func() {
  17. this.Data["json"] = br
  18. this.ServeJSON()
  19. }()
  20. user := this.User
  21. if user == nil {
  22. br.Msg = "请登录"
  23. br.ErrMsg = "请登录,用户信息为空"
  24. br.Ret = 408
  25. return
  26. }
  27. resp := new(models.BannerUrHomeListResp)
  28. //var list []*models.BannerUrlYxResp
  29. list := new(models.BannerUrHomeListResp)
  30. //list = []*models.BannerUrlYxResp{
  31. // &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"},
  32. // &models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/2.png", Path: "pages-purchaser/survey/surveySubmit"},
  33. // &models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/4.png", Path: "pages-purchaser/specialColumn/specialColumn"},
  34. // &models.BannerUrlYxResp{IndexImg: "https://hzstatic.hzinsights.com/banner/yx/3_long.png", Path: "pages-purchaser/researchList/researchList"},
  35. //}
  36. key := "mfyx_banner_list"
  37. conf, e := models.GetConfigByCode(key)
  38. if e != nil {
  39. br.Msg = "获取失败"
  40. br.ErrMsg = "获取首页头部导航失败, Err: " + e.Error()
  41. return
  42. }
  43. if conf.ConfigValue == "" {
  44. br.Msg = "获取失败"
  45. br.ErrMsg = "首页头部导航配置值有误"
  46. return
  47. }
  48. //list := new(*models.BannerUrlYxResp)
  49. if e = json.Unmarshal([]byte(conf.ConfigValue), &list); e != nil {
  50. br.Msg = "获取失败"
  51. br.ErrMsg = "首页头部导航配置值解析失败, Err: " + e.Error()
  52. return
  53. }
  54. //resp.List := list
  55. //if searchPage == 1 {
  56. // resp = list.SearchPage
  57. //}
  58. resp.List = list.List
  59. br.Ret = 200
  60. br.Success = true
  61. br.Msg = "获取成功"
  62. br.Data = resp
  63. }