wangchuanjin пре 8 месеци
родитељ
комит
c1c142a07e
3 измењених фајлова са 24 додато и 39 уклоњено
  1. 0 7
      jyBXSubscribe/rpc/etc/db.yaml
  2. 0 7
      jyBXSubscribe/rpc/init/db.go
  3. 24 25
      jyBXSubscribe/rpc/model/push.go

+ 0 - 7
jyBXSubscribe/rpc/etc/db.yaml

@@ -20,13 +20,6 @@ mysql:
         password: '=PDT49#80Z!RVv52_z'
         maxOpenConns: 5
         maxIdleConns: 5
-    jyCk:
-        address: 192.168.3.207:19000
-        dbName: jianyu
-        userName: jytop
-        password: 'pwdTopJy123'
-        maxOpenConns: 5
-        maxIdleConns: 5
 redis:
     addr:
         - other=192.168.3.149:1712

+ 0 - 7
jyBXSubscribe/rpc/init/db.go

@@ -4,7 +4,6 @@
 package init
 
 import (
-	"fmt"
 	"strings"
 
 	elastic "app.yhyue.com/moapp/jybase/es"
@@ -26,7 +25,6 @@ var (
 	MgoBidding       mongodb.MongodbSim
 	GlobalCommonData *mysql.Mysql
 	MgoLog           mongodb.MongodbSim
-	CkJy             *mysql.Mysql
 )
 var Middleground *middleground.Middleground
 var Compatible *compatible.Compatible
@@ -108,11 +106,6 @@ func MysqlInit(mm *entity.Mysql) {
 		}
 		GlobalCommonData.Init()
 	}
-	if mm.JyCk.Address != "" {
-		logx.Info("--初始化 jy clickhouse--")
-		CkJy = mysql.NewInit(mysql.CLICKHOUSE, fmt.Sprintf("clickhouse://%s:%s@%s/%s", mm.JyCk.UserName, mm.JyCk.Password, mm.JyCk.Address, mm.JyCk.DbName),
-			mm.JyCk.MaxOpenConns, mm.JyCk.MaxIdleConns)
-	}
 	P.BidCodeMapping.Init(BaseServiceMysql)
 }
 

+ 24 - 25
jyBXSubscribe/rpc/model/push.go

@@ -2454,32 +2454,31 @@ func (s *SubPushQueryParam) ExportPushFormat() (ids, keyWords []string) {
 // @Description	clickhouse获取推荐的列表数据
 // @Date 2024/3/11
 func (s *subscribePush) SubRecList(userId string, keyword []ViewKeyWord) (hasNextPage bool, total int64, resultList []*bxsubscribe.SubscribeInfo) {
-	sql := "select bitmapToArray(infoids) infoids, userid from jianyu.sub_recommend_list where userid = ?"
-	infos := IC.CkJy.SelectBySql(sql, userId)
+	infos := IC.BaseServiceMysql.SelectBySql(`select autoid from push.sub_recommend_list where userid=? order by create_time desc limit ?`, userId, pageSize)
+	ids := []int64{}
 	if infos != nil && len(*infos) > 0 {
-		if ids, ok := (*infos)[0]["infoids"].([]uint64); ok && len(ids) > 0 {
-			length := len(ids)
-			resultList = make([]*bxsubscribe.SubscribeInfo, length)
-			esq := `{"query": {"bool": {"must": [{"terms": {"autoid": [` + strings.Join(gconv.Strings(ids), ",") + ` ]}}]}}}`
-			binfo := elastic.GetAllByNgram(INDEX, TYPE, esq, findfields, bidSort, bidField, 0, 100, length, false)
-			if binfo != nil && len(*binfo) > 0 {
-				for i, m := range *binfo {
-					title := strings.Replace(common.ObjToString(m["title"]), " ", "", -1)
-					matchkeys := getKeys(title, keyword)
-					resultList[i] = s.InfoFormat(&PushCa{
-						InfoId:     mongodb.BsonIdToSId(m["_id"]),
-						Date:       time.Now().Unix(),
-						Keys:       matchkeys,
-						FileExists: m["filetext"] != nil,
-					}, &m, false, false)
-				}
-			}
-			total = int64(len(resultList))
-			if total > pageSize {
-				resultList = resultList[:pageSize]
-				hasNextPage = true
-			}
-		}
+		for _, v := range *infos {
+			ids = append(ids, common.Int64All(v["autoid"]))
+		}
+	}
+	if len(ids) > 0 {
+		length := len(ids)
+		resultList = []*bxsubscribe.SubscribeInfo{}
+		esq := `{"query": {"bool": {"must": [{"terms": {"autoid": [` + strings.Join(gconv.Strings(ids), ",") + ` ]}}]}}}`
+		binfo := elastic.GetAllByNgram(INDEX, TYPE, esq, findfields, bidSort, bidField, 0, pageSize, length, false)
+		if binfo != nil && len(*binfo) > 0 {
+			for _, m := range *binfo {
+				title := strings.Replace(common.ObjToString(m["title"]), " ", "", -1)
+				matchkeys := getKeys(title, keyword)
+				resultList = append(resultList, s.InfoFormat(&PushCa{
+					InfoId:     mongodb.BsonIdToSId(m["_id"]),
+					Date:       time.Now().Unix(),
+					Keys:       matchkeys,
+					FileExists: m["filetext"] != nil,
+				}, &m, false, false))
+			}
+		}
+		total = int64(len(resultList))
 	}
 	return
 }