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

Merge branch 'dev/v1.1.48_wjh' of BaseService/jyMicroservices into feature/v1.1.48

wangjianghan 1 жил өмнө
parent
commit
c540e1c8f8

+ 3 - 3
jyBXSubscribe/rpc/etc/db.yaml

@@ -1,9 +1,9 @@
 mysql:
     main:
         dbName: jianyu
-        address: jymysql.jydev.jy360.cn:33066
-        userName: jianyu
-        password: Topnet123
+        address: 192.168.3.14:4000
+        userName: root
+        password: '=PDT49#80Z!RVv52_z'
         maxOpenConns: 5
         maxIdleConns: 5
     baseService:

+ 5 - 9
jyBXSubscribe/rpc/init/db.go

@@ -109,6 +109,11 @@ 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)
 }
 
@@ -127,12 +132,3 @@ func EsInit(es *entity.EsStruct) {
 		elastic.NewEs(es.Version, es.Addr, es.Size, es.UserName, es.Password)
 	}
 }
-
-// clickhouse init
-func CkInit(ck *entity.Mysql) {
-	if ck.JyCk.Address != "" {
-		logx.Info("--初始化 jy clickhouse--")
-		CkJy = mysql.NewInit(mysql.CLICKHOUSE, fmt.Sprintf("%s:%s@tcp(%s)/%s?charset=utf8mb4", ck.JyCk.UserName, ck.JyCk.Password, ck.JyCk.Address, ck.JyCk.DbName),
-			ck.JyCk.MaxOpenConns, ck.JyCk.MaxIdleConns)
-	}
-}

+ 0 - 1
jyBXSubscribe/rpc/init/init.go

@@ -26,7 +26,6 @@ func InitC() {
 	RedisInit(&DB.Redis)
 	//初始es
 	EsInit(&DB.Es)
-	CkInit(&DB.Mysql)
 	Middleground = middleground.NewMiddleground(C.CodeServiceConf.Etcd.Hosts).
 		RegUserCenter(C.UserCenterKey).
 		RegPowerCheckCenter(C.PowerCheckCenterKey).

+ 4 - 5
jyBXSubscribe/rpc/internal/config/config.go

@@ -25,9 +25,8 @@ type Config struct {
 }
 
 type Db struct {
-	Mysql      entity.Mysql      `json:"mysql"`
-	Redis      entity.RedisStuct `json:"redis"`
-	Es         entity.EsStruct   `json:"es"`
-	Mongo      entity.Mongo      `json:"mongo"`
-	ClickHouse entity.Mysql      `json:"clickhouse"`
+	Mysql entity.Mysql      `json:"mysql"`
+	Redis entity.RedisStuct `json:"redis"`
+	Es    entity.EsStruct   `json:"es"`
+	Mongo entity.Mongo      `json:"mongo"`
 }

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

@@ -2244,32 +2244,33 @@ 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)
-	if infos != nil && len(*infos) > 0 {
-		if ids, ok := (*infos)[0]["infoids"].([]interface{}); ok && len(ids) > 0 {
-			length := len(ids)
-			resultList = make([]*bxsubscribe.SubscribeInfo, length)
-			binfo, _ := IC.MgoBidding.Find("bidding", bson.M{"autoid": bson.M{"$in": ids}}, `{"publishtime": -1}`, bidField, false, -1, -1)
-			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)
-				}
-			}
-			total = int64(len(resultList))
-			if total > pageSize {
-				resultList = resultList[:pageSize]
-				hasNextPage = true
-			}
+	//sql := "select bitmapToArray(infoids) infoids, userid from jianyu.sub_recommend_list where userid = ?"
+	//infos := IC.CkJy.SelectBySql(sql, userId)
+	//if infos != nil && len(*infos) > 0 {
+	//if ids, ok := (*infos)[0]["infoids"].([]interface{}); ok && len(ids) > 0 {
+	ids := []int64{272269745, 272269067, 272268763}
+	length := len(ids)
+	resultList = make([]*bxsubscribe.SubscribeInfo, length)
+	binfo, _ := IC.MgoBidding.Find("bidding", bson.M{"autoid": bson.M{"$in": ids}}, `{"publishtime": -1}`, bidField, false, -1, -1)
+	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)
 		}
 	}
+	total = int64(len(resultList))
+	if total > pageSize {
+		resultList = resultList[:pageSize]
+		hasNextPage = true
+	}
+	//}
+	//}
 	return
 }