package controller import ( "fmt" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/util/gconv" "jyseo/internal/consts" "jyseo/internal/service" ) func IndustryIndexHandler(r *ghttp.Request) { service.HtmlRender.Render(r, "industry_index.html", g.Map{ "industryList": service.JySeoIndustryKeyWordRoot.GetIndustry(), "tdk": service.JySeoTdk.GetIndustryTdk(r.Context(), ""), }, ) } func IndustryListHandler(r *ghttp.Request) { keyWordId := r.Get("keyWordId").Int64() industryClassId := r.Get("industryClassId").Int() //areaCode := r.Get("areaCode").String() //sTypeId := r.Get("sTypeId").String() pageNum := r.Get("pageNum", 1).Int() //页码 keyWordStruct := service.JySeoIndustryKeyWordRoot.GetKeyWordsById(keyWordId) if keyWordStruct == nil { service.HtmlRender.NotFound(r) return } query := service.NewBiddingQuery().EquipKeyWord(keyWordStruct.KeyWord) var ( rData *service.ListResp err error ) // 查询数据 if keyWordStruct.State == 1 { rData, err = query.GetDataPageList(r.Context(), pageNum, 0, consts.IndustryWordsListMaxTotal, "IndustryListHandlerState", service.JySeoIndustryKeyWordRoot.GetData) } else { rData, err = query.GetDataPageList(r.Context(), pageNum, 0, consts.IndustryWordsListMaxTotal, "IndustryListHandler", service.JySeoIndustryKeyWordRoot.GetEsData) } if err != nil { g.Log().Errorf(r.Context(), err.Error()) service.HtmlRender.RenderError(r, fmt.Errorf("获取列表数据异常")) return } service.HtmlRender.Render(r, "industry_list.html", g.Map{ "tdk": service.JySeoTdk.GetIndustryTdk(r.Context(), keyWordStruct.KeyWord), "keywordsNode": keyWordStruct, "industryList": service.JySeoIndustryKeyWordRoot.GetIndustry(), "list": rData.List, "pagination": service.GetLetterPaging(pageNum, gconv.Int(rData.Total), fmt.Sprintf("/tags/industry/%d_%s_%s_%d_%s.html", industryClassId, "all", "all", keyWordId, "%d")), }, ) }