package controllers import ( "hongze/hongze_api/models" "hongze/hongze_api/services" ) //首页 type HomeController struct { BaseAuthController } type HomeCommonController struct { BaseCommonController } // @Title 首页列表接口 // @Description 首页列表接口 // @Success 200 {object} models.HomeList // @router /list [get] func (this *HomeController) 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 } list, err := services.HomeList(user.UserId, user.CompanyId) if err != nil { br.Msg = "获取数据失败" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } for i := 0; i < len(list); i++ { item := list[i] for k := 0; k < len(item.Child); k++ { if item.ClassifyName == "权益研报" { if item.Child[k].Child.ClassifyNameSecond == "近期路演精华" { list[i].Child[k].TitleType = "路演精华" } else { list[i].Child[k].TitleType = "权益" } } else { list[i].Child[k].TitleType = "FICC" } } } br.Ret = 200 br.Success = true br.Msg = "获取数据成功" br.Data = list } // @Title 首页列表接口 // @Description 首页列表接口 // @Success 200 {object} models.Banner // @router /banner [get] func (this *HomeController) ListBanner() { br := new(models.BaseResponse).Init() defer func() { this.Data["json"] = br this.ServeJSON() }() list, err := models.GetHomeBannerList("") if err != nil { br.Msg = "获取数据失败" br.ErrMsg = "获取数据失败,Err:" + err.Error() return } br.Ret = 200 br.Success = true br.Msg = "获取数据成功" br.Data = list }