فهرست منبع

feat:路由修改

wangkaiyue 9 ماه پیش
والد
کامیت
95a4d0b150
2فایلهای تغییر یافته به همراه19 افزوده شده و 8 حذف شده
  1. 5 5
      internal/cmd/cmd.go
  2. 14 3
      internal/controller/keywordSite.go

+ 5 - 5
internal/cmd/cmd.go

@@ -36,11 +36,11 @@ var (
 					group.GET("/{signCode}/", controller.SignPageHandler)           //项目标签列表
 					group.GET("/{signCode}/p{pageNum}", controller.SignPageHandler) //项目标签列表
 
-					group.GET("/area/", controller.SiteAreaIndexHandler)                   //site省份汇总页
-					group.GET("/city/", controller.SiteCityIndexHandler)                   //site城市汇总页
-					group.GET("/area/{areaCode}_S{siteCode}/", controller.SiteHandler)     //site关键词列表页面-省
-					group.GET("/city/{areaCode}_S{siteCode}/", controller.SiteHandler)     //site关键词列表页面-市
-					group.GET("/city/{areaCode}_S{siteCode}.html", controller.SiteHandler) //site关键词列表页面-区县
+					group.GET("/area/", controller.SiteAreaIndexHandler)                                             //site省份汇总页
+					group.GET("/city/", controller.SiteCityIndexHandler)                                             //site城市汇总页
+					group.GET("/area/{areaCode}_S{siteCode}/", controller.SiteHandler)                               //site关键词列表页面-省
+					group.GET("/city/{areaCode}_{cityCode}_S{siteCode}/", controller.SiteHandler)                    //site关键词列表页面-市
+					group.GET("/city/{areaCode}_{cityCode}_{districtCode}_S{siteCode}.html", controller.SiteHandler) //site关键词列表页面-区县
 
 					group.GET("/", controller.PinyinIndexHandler)                      //行业拼音关键词聚合页
 					group.GET("/keywords/{pinyinCode}.html", controller.PinyinHandler) //行业拼音关键词列表页面

+ 14 - 3
internal/controller/keywordSite.go

@@ -20,10 +20,21 @@ func SiteCityIndexHandler(r *ghttp.Request) {
 
 // SiteHandler 地区站首页
 func SiteHandler(r *ghttp.Request) {
-	areaCode := r.Get("areaCode").String()
-	siteCode := fmt.Sprintf("S%s", r.Get("siteCode").String())
+	var (
+		areaCode            = r.Get("areaCode").String()
+		cityCode            = r.Get("cityCode").String()
+		districtCode        = r.Get("districtCode").String()
+		siteCode            = fmt.Sprintf("S%s", r.Get("siteCode").String())
+		fullCode     string = areaCode
+	)
+	if cityCode != "" {
+		fullCode += fmt.Sprintf("_%s", cityCode)
+		if districtCode != "" {
+			fullCode += fmt.Sprintf("_%s", districtCode)
+		}
+	}
 
-	areaNode := service.JySeoAreaRoot.GetNodeByCode(areaCode)
+	areaNode := service.JySeoAreaRoot.GetNodeByCode(fullCode)
 	if areaNode == nil {
 		service.HtmlRender.NotFound(r)
 		return