keyWordClass.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package controller
  2. import (
  3. "fmt"
  4. "github.com/gogf/gf/v2/frame/g"
  5. "github.com/gogf/gf/v2/net/ghttp"
  6. "github.com/gogf/gf/v2/util/gconv"
  7. "jyseo/internal/consts"
  8. "jyseo/internal/service"
  9. )
  10. func IndustryIndexHandler(r *ghttp.Request) {
  11. service.HtmlRender.Render(r, "industry_index.html",
  12. g.Map{
  13. "industryList": service.JySeoIndustryRoot.GetIndustry(),
  14. "tdk": service.JySeoTdk.GetIndustryTdk(r.Context(), ""),
  15. },
  16. )
  17. }
  18. func IndustryListHandler(r *ghttp.Request) {
  19. keyWordId := r.Get("keyWordId").Int64()
  20. industryClassId := r.Get("industryClassId").Int()
  21. //areaCode := r.Get("areaCode").String()
  22. //sTypeId := r.Get("sTypeId").String()
  23. pageNum := r.Get("pageNum", 1).Int() //页码
  24. keyWordStruct := service.JySeoIndustryRoot.GetKeyWordsById(keyWordId)
  25. if keyWordStruct == nil {
  26. service.HtmlRender.NotFound(r)
  27. return
  28. }
  29. query := service.NewBiddingQuery().EquipKeyWord(keyWordStruct.KeyWord)
  30. var (
  31. rData *service.ListResp
  32. err error
  33. )
  34. // 查询数据
  35. if keyWordStruct.State == 1 {
  36. rData, err = query.GetDataPageList(r.Context(), pageNum, consts.IndustryWordsListMaxTotal, "IndustryListHandler", service.JySeoIndustryRoot.GetData)
  37. } else {
  38. rData, err = query.GetDataPageList(r.Context(), pageNum, consts.IndustryWordsListMaxTotal, "IndustryListHandler", service.JySeoIndustryRoot.GetEsData)
  39. }
  40. if err != nil {
  41. g.Log().Errorf(r.Context(), err.Error())
  42. service.HtmlRender.RenderError(r, fmt.Errorf("获取列表数据异常"))
  43. return
  44. }
  45. service.HtmlRender.Render(r, "industry_list.html",
  46. g.Map{
  47. "tdk": service.JySeoTdk.GetIndustryTdk(r.Context(), keyWordStruct.KeyWord),
  48. "keywordsNode": keyWordStruct,
  49. "industryList": service.JySeoIndustryRoot.GetIndustry(),
  50. "list": rData.List,
  51. "pagination": service.GetLetterPaging(pageNum, gconv.Int(rData.Total), fmt.Sprintf("/tags/industry/%d_%s_%s_%d_%s.html", industryClassId, "all", "all", keyWordId, "%d")),
  52. },
  53. )
  54. }