Parcourir la source

fix:seo_id获取修改

duxin il y a 1 an
Parent
commit
b1cf3b28de

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

@@ -1,13 +1,10 @@
 package filter
 
 import (
-	"app.yhyue.com/moapp/jybase/encrypt"
 	"fmt"
 	"jy/src/jfw/config"
 	"jy/src/jfw/jyutil"
-	"log"
 	"net/http"
-	"net/url"
 	"strings"
 	"time"
 
@@ -83,41 +80,6 @@ func (this *pcFilter) Do() bool {
 	return false
 }
 
-// 画像页面未登录用户跳转302
-func PortraitSkip(urls, userid string) string {
-	var seoUrl string
-	if userid == "" {
-		log.Println("未登录用户", urls)
-		var sql string
-		if strings.Contains(urls, "swordfish/page_big_pc/unit_portrayal/") ||
-			strings.Contains(urls, "entpc/unit_portrayal/") {
-			urlArr := strings.Split(urls, "/")
-			//buyerName := urlArr[len(urlArr)-1]
-			// 解码 URL 编码的字符串
-			decodedString, _ := url.QueryUnescape(urlArr[len(urlArr)-1])
-			sql = fmt.Sprintf("SELECT  seo_id  FROM   dws_f_ent_baseinfo WHERE     name ='%s'  AND (identity_type &(1 << 0)) > 0", decodedString)
-			log.Println("未登录用户采购单位", sql)
-			data := public.GlobalCommonMysql.SelectBySql(sql)
-			if data != nil && len(*data) > 0 {
-				log.Println("未登录用户采购单位", *data)
-				seoUrl = fmt.Sprintf("/dw/%s.html", util.InterfaceToStr((*data)[0]["seo_id"]))
-			}
-		} else if strings.Contains(urls, "swordfish/page_big_pc/svip/ent_ser_portrait/") ||
-			strings.Contains(urls, "/swordfish/page_big_pc/ent_portrait/") {
-			urlArr := strings.Split(urls, "/")
-			entId := encrypt.DecodeArticleId2ByCheck(urlArr[len(urlArr)-1])[0]
-			sql = fmt.Sprintf("SELECT  seo_id  FROM   dws_f_ent_baseinfo WHERE     name_id ='%s'  AND (identity_type &(1 << 1)) > 0", entId)
-			log.Println("未登录用户企业单位", sql)
-			data := public.GlobalCommonMysql.SelectBySql(sql)
-			if data != nil && len(*data) > 0 {
-				log.Println("未登录用户企业单位", *data)
-				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天,单位秒

+ 6 - 5
src/jfw/front/classificationTag.go

@@ -3,6 +3,7 @@ package front
 import (
 	qu "app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/encrypt"
+	elastic "app.yhyue.com/moapp/jybase/es"
 	"app.yhyue.com/moapp/jybase/redis"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/bidsearch"
 	"app.yhyue.com/moapp/jypkg/public"
@@ -69,7 +70,7 @@ func GetWinnerInfo() (data []*BuyerList) {
 
 	for _, v := range *rs {
 		var vs BuyerList
-		id := qu.InterfaceToStr(v["seo_id"])
+		id := qu.InterfaceToStr(v["nseo_id"])
 		vs.Name = qu.InterfaceToStr(v["name"])
 		vs.Url = fmt.Sprintf("/qy/%s.html", id)
 		data = append(data, &vs)
@@ -116,11 +117,11 @@ func getEntBaseInfo(identityType, limit int) *[]map[string]interface{} {
 }
 
 func GetSeoId(identityType, limit int) *[]map[string]interface{} {
-	//q := fmt.Sprintf(`{"query": {"bool": {}},"sort": {"updatetime": "desc"},"from": 0,"size": %d,"_source": ["name","seo_id"]}`, config.HotWinnerConfig.Limit)
-	//index := qu.If(isWinner, "qyxy", "buyer").(string)
-	q := "SELECT  company_id AS id,name,name_id,seo_id  FROM   dws_f_ent_baseinfo WHERE     company_id !='' and company_id is not null  AND (identity_type &(1 << ?)) > 0 order by latest_time desc  limit ?"
-	return public.GlobalCommonMysql.SelectBySql(q, identityType, limit)
+	index := qu.If(identityType != 0, "qyxy", "buyer").(string)
+	seo := qu.If(identityType != 0, "nseo_id", "seo_id").(string)
+	q := fmt.Sprintf(`{"query": {"bool": {}},"sort": {"updatetime": "desc"},"from": 0,"size": %d,"_source": ["name","%s"]}`, limit, seo)
 
+	return elastic.Get(index, index, q)
 }
 
 // ContentRecommendation 实用内容推荐

+ 8 - 11
src/jfw/front/frontRouter.go

@@ -3,6 +3,7 @@ package front
 import (
 	"app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/encrypt"
+	elastic "app.yhyue.com/moapp/jybase/es"
 	"app.yhyue.com/moapp/jybase/redis"
 	"app.yhyue.com/moapp/jypkg/public"
 	"fmt"
@@ -253,19 +254,15 @@ func esSeoId(isWinner bool, idName string) string {
 	}
 
 	if isWinner {
-		//q := "SELECT  company_id AS id,name,name_id,seo_id  FROM   dws_f_ent_baseinfo WHERE    name_id =? and company_id !='' and company_id is not null  AND (identity_type &(1 << ?)) > 0 order by latest_time desc  limit ?"
-		//public.GlobalCommonMysql.SelectBySql(q, idName, 1, 1)
-		if data := public.GlobalCommonMysql.FindOne("dws_f_ent_baseinfo", map[string]interface{}{
-			"company_id": idName,
-		}, "seo_id", ""); data != nil && len(*data) > 0 {
-			seoId = common.InterfaceToStr((*data)["seo_id"])
+		winnerSeo := elastic.GetById("qyxy", "qyxy", idName)
+		if winnerSeo != nil && len(*winnerSeo) > 0 {
+			seoId = common.InterfaceToStr((*winnerSeo)[0]["nseo_id"])
 		}
-
 	} else {
-		if data := public.GlobalCommonMysql.FindOne("dws_f_ent_baseinfo", map[string]interface{}{
-			"name": idName,
-		}, "seo_id", ""); data != nil && len(*data) > 0 {
-			seoId = common.InterfaceToStr((*data)["seo_id"])
+		q := fmt.Sprintf(`{"query": {"bool": {"must": [{"match": {"buyer_name": "%s"}}]}},"from": 0,"size": 1,"_source":["seo_id"]}`, idName)
+		winnerSeo := elastic.Get("buyer", "buyer", q)
+		if winnerSeo != nil && len(*winnerSeo) > 0 {
+			seoId = common.InterfaceToStr((*winnerSeo)[0]["seo_id"])
 		}
 	}
 	if seoId != "" {

+ 8 - 8
src/jfw/modules/app/src/app/front/bigMember.go

@@ -3,6 +3,7 @@ package front
 import (
 	qutil "app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/encrypt"
+	elastic "app.yhyue.com/moapp/jybase/es"
 	"app.yhyue.com/moapp/jybase/go-xweb/xweb"
 	"app.yhyue.com/moapp/jybase/redis"
 	"app.yhyue.com/moapp/jypkg/common/src/qfw/util/jy"
@@ -88,16 +89,15 @@ func esSeoId(isWinner bool, idName string) string {
 		return seoId
 	}
 	if isWinner {
-		if data := public.GlobalCommonMysql.FindOne("dws_f_ent_baseinfo", map[string]interface{}{
-			"company_id": idName,
-		}, "seo_id", ""); data != nil && len(*data) > 0 {
-			seoId = qutil.InterfaceToStr((*data)["seo_id"])
+		winnerSeo := elastic.GetById("qyxy", "qyxy", idName)
+		if winnerSeo != nil && len(*winnerSeo) > 0 {
+			seoId = qutil.InterfaceToStr((*winnerSeo)[0]["nseo_id"])
 		}
 	} else {
-		if data := public.GlobalCommonMysql.FindOne("dws_f_ent_baseinfo", map[string]interface{}{
-			"name": idName,
-		}, "seo_id", ""); data != nil && len(*data) > 0 {
-			seoId = qutil.InterfaceToStr((*data)["seo_id"])
+		q := fmt.Sprintf(`{"query": {"bool": {"must": [{"match": {"buyer_name": "%s"}}]}},"from": 0,"size": 1,"_source":["seo_id"]}`, idName)
+		winnerSeo := elastic.Get("buyer", "buyer", q)
+		if winnerSeo != nil && len(*winnerSeo) > 0 {
+			seoId = qutil.InterfaceToStr((*winnerSeo)[0]["seo_id"])
 		}
 	}
 	if seoId != "" {