瀏覽代碼

多个关键词处理

WH01243 2 年之前
父節點
當前提交
dfd540895f

+ 2 - 2
jyBXSubscribe/api/internal/logic/byPushHistoryLogic.go

@@ -37,9 +37,9 @@ func (l *ByPushHistoryLogic) ByPushHistory(req *types.SubscribeReq) (resp *types
 	if req.PositionType == 0 {
 		for k, v := range req.Item {
 			if common.InterfaceToStr(v) == "" {
-				matchitemsArr = append(matchitemsArr, common.InterfaceToStr(v))
+				matchitemsArr = append(matchitemsArr, common.InterfaceToStr(k))
 			} else {
-				matchkeysArr = append(matchkeysArr, common.InterfaceToStr(k))
+				matchkeysArr = append(matchkeysArr, common.InterfaceToStr(v))
 			}
 		}
 		if len(matchitemsArr) == 0 {

+ 2 - 2
jyBXSubscribe/api/internal/logic/subscribeListLogic.go

@@ -39,9 +39,9 @@ func (l *SubscribeListLogic) SubscribeList(req *types.SubscribeReq) (resp *types
 	if req.PositionType == 0 {
 		for k, v := range req.Item {
 			if common.InterfaceToStr(v) == "" {
-				matchitemsArr = append(matchitemsArr, common.InterfaceToStr(v))
+				matchitemsArr = append(matchitemsArr, common.InterfaceToStr(k))
 			} else {
-				matchkeysArr = append(matchkeysArr, common.InterfaceToStr(k))
+				matchkeysArr = append(matchkeysArr, common.InterfaceToStr(v))
 			}
 		}
 		if len(matchitemsArr) == 0 {

+ 5 - 8
jyBXSubscribe/rpc/model/push.go

@@ -496,14 +496,11 @@ func (s *subscribePush) getDatasFromMysql(spqp *SubPushQueryParam, starttime, en
 		//关键词
 		find_in_set := []string{}
 		if spqp.PositionType == 0 {
-			if spqp.Item == "" {
-				for _, v := range strings.Split(spqp.Key, ",") {
-					find_in_set = append(find_in_set, fmt.Sprintf("find_in_set('%s',replace(replace(a.matchkeys,'+',','),' ',','))", v))
-				}
-			} else {
-				for _, v := range strings.Split(spqp.Item, ",") {
-					find_in_set = append(find_in_set, fmt.Sprintf("find_in_set('%s',replace(replace(a.matchitems,'+',','),' ',','))", v))
-				}
+			for _, v := range strings.Split(spqp.Key, ",") {
+				find_in_set = append(find_in_set, fmt.Sprintf("find_in_set('%s',replace(replace(a.matchkeys,'+',','),' ',','))", v))
+			}
+			for _, v := range strings.Split(spqp.Item, ",") {
+				find_in_set = append(find_in_set, fmt.Sprintf("find_in_set('%s',replace(replace(a.matchitems,'+',','),' ',','))", v))
 			}
 		} else {
 			if spqp.Key != "" {