Эх сурвалжийг харах

fix:企业画像pc退出302seo处理

duxin 1 жил өмнө
parent
commit
db31a94966

+ 32 - 0
src/jfw/filter/pcfilter.go

@@ -37,6 +37,11 @@ func (this *pcFilter) Do() bool {
 		//wx
 		return true
 	}
+	//画像页面未登录跳转seo
+	if seoUrl := PortraitSkip(this.R.RequestURI, util.InterfaceToStr(this.GetSession["userid"])); seoUrl != "" {
+		http.Redirect(this.W, this.R, seoUrl, 302)
+		return false
+	}
 	//企业搜索
 	if strings.Contains(this.R.RequestURI, "/jylab/entSearch/index.html") ||
 		strings.Contains(this.R.RequestURI, "/swordfish/page_big_pc/ent_portrait/") ||
@@ -80,6 +85,33 @@ func (this *pcFilter) Do() bool {
 	return false
 }
 
+// 画像页面未登录用户跳转302
+func PortraitSkip(url, userid string) string {
+	var seoUrl string
+	if userid == "" {
+		var sql string
+		if strings.Contains(url, "/swordfish/page_big_pc/unit_portrayal/") ||
+			strings.Contains(url, "/entpc/unit_portrayal/") {
+			urlArr := strings.Split(url, "/")
+			//buyerName := urlArr[len(urlArr)-1]
+			sql = fmt.Sprintf("SELECT  seo_id  FROM   dws_f_ent_baseinfo WHERE     name =='%s'  AND (identity_type &(1 << 0)) > 0", urlArr[len(urlArr)-1])
+			data := public.GlobalCommonMysql.SelectBySql(sql)
+			if data != nil && len(*data) > 0 {
+				seoUrl = fmt.Sprintf("/dw/%s.html", util.InterfaceToStr((*data)[0]["seo_id"]))
+			}
+		} else if strings.Contains(url, "swordfish/page_big_pc/svip/ent_ser_portrait/") ||
+			strings.Contains(url, "/swordfish/page_big_pc/ent_portrait/") {
+			urlArr := strings.Split(url, "/")
+			sql = fmt.Sprintf("SELECT  seo_id  FROM   dws_f_ent_baseinfo WHERE     name_id =='%s'  AND (identity_type &(1 << 1)) > 0", urlArr[len(urlArr)-1])
+			data := public.GlobalCommonMysql.SelectBySql(sql)
+			if data != nil && len(*data) > 0 {
+				seoUrl = fmt.Sprintf("/qy/%s.html", util.InterfaceToStr((*data)[0]["seo_id"]))
+			}
+		}
+	}
+	return seoUrl
+}
+
 // 生成cookie
 func (this *pcFilter) cookie(userid, keyname string) *http.Cookie {
 	maxAge := int(time.Hour * 72 / time.Second) //3天,单位秒