Browse Source

wip:订阅词

wangshan 5 months ago
parent
commit
7968970041

+ 16 - 0
src/jfw/modules/bigmember/src/service/use/use.go

@@ -8,6 +8,7 @@ import (
 	"jy/src/jfw/modules/bigmember/src/entity"
 	"jy/src/jfw/modules/bigmember/src/util"
 	"log"
+	"regexp"
 	"strconv"
 	"strings"
 	"time"
@@ -204,6 +205,8 @@ func (u *Use) Add() {
 	u.ServeJson(r)
 }
 
+var rx = regexp.MustCompile("\n+")
+
 // 用户大会员信息
 func (u *Use) Info() {
 	r := func() Result {
@@ -268,7 +271,20 @@ func (u *Use) Info() {
 						tmp := qu.ObjToMap(v.(map[string]interface{}))
 						a_key, _ := (*tmp)["a_key"].([]interface{})
 						for _, n := range a_key {
+							var keywords []string
 							ntmp := qu.ObjToMap(n.(interface{}))
+							keyS := qu.ObjArrToStringArr((*tmp)["key"].([]interface{}))
+							if len(keyS) > 0 {
+								for _, key := range keyS {
+									if key = strings.TrimSpace(rx.ReplaceAllString(key, " ")); key != "" {
+										keywords = append(keywords, key)
+									}
+								}
+							}
+							if len(keywords) == 0 {
+								continue
+							}
+							(*ntmp)["key"] = keywords
 							if (*ntmp)["appendkey"] != nil && (*ntmp)["updatetime"] == nil {
 								appendkey := qu.ObjArrToStringArr((*ntmp)["appendkey"].([]interface{}))
 								if len(appendkey) > 0 {

+ 22 - 9
src/jfw/modules/publicapply/src/subscribe/entity/entity.go

@@ -15,6 +15,7 @@ import (
 	"jy/src/jfw/modules/publicapply/src/config"
 	"jy/src/jfw/modules/publicapply/src/db"
 	"log"
+	"regexp"
 	"time"
 
 	// "reflect"
@@ -37,10 +38,11 @@ var stringArr = []string{}
 type ParamInfo struct {
 	UserId  string
 	Session *httpsession.Session
+	Rx      *regexp.Regexp
 }
 
 func NewParamInfo(userId string, session *httpsession.Session) *ParamInfo {
-	return &ParamInfo{userId, session}
+	return &ParamInfo{userId, session, regexp.MustCompile("\n+")}
 }
 
 // dev4.6.3.21 暂不调用
@@ -437,20 +439,31 @@ func (pi *ParamInfo) GetSubMsg() UserSubMsg {
 		a_key, _ := o_jy["a_key"].([]interface{})
 		if len(a_key) > 0 {
 			for _, v := range a_key {
+				var keywords []string
 				keyMap, _ := v.(map[string]interface{})
-				key := qutil.ObjArrToStringArr(keyMap["key"].([]interface{}))
-				appendkey := stringArr
+				keyS := qutil.ObjArrToStringArr(keyMap["key"].([]interface{}))
+				if len(keyS) > 0 {
+					for _, key := range keyS {
+						if key = strings.TrimSpace(pi.Rx.ReplaceAllString(key, " ")); key != "" {
+							keywords = append(keywords, key)
+						}
+					}
+				}
+				if len(keywords) == 0 {
+					continue
+				}
+				appendKey := stringArr
 				if keyMap["appendkey"] != nil {
-					appendkey = qutil.ObjArrToStringArr(keyMap["appendkey"].([]interface{}))
+					appendKey = qutil.ObjArrToStringArr(keyMap["appendkey"].([]interface{}))
 				}
-				notkey := stringArr
+				notKey := stringArr
 				if keyMap["notkey"] != nil {
-					notkey = qutil.ObjArrToStringArr(keyMap["notkey"].([]interface{}))
+					notKey = qutil.ObjArrToStringArr(keyMap["notkey"].([]interface{}))
 				}
 				res.Keys = append(res.Keys, ViewKeyWord{
-					Keyword:  key,
-					Appended: appendkey,
-					Exclude:  notkey,
+					Keyword:  keywords,
+					Appended: appendKey,
+					Exclude:  notKey,
 					MatchWay: 0,
 				})
 			}

+ 22 - 14
src/jfw/modules/subscribepay/src/service/afterPay.go

@@ -6,6 +6,7 @@ import (
 	"jy/src/jfw/modules/subscribepay/src/config"
 	"jy/src/jfw/modules/subscribepay/src/util"
 	"log"
+	"regexp"
 	"strconv"
 	"strings"
 	"sync"
@@ -23,7 +24,7 @@ type VIPLOCK struct {
 
 var VIP_user_lock = map[string]*VIPLOCK{}
 
-//完成支付数据交互接口
+// 完成支付数据交互接口
 type AfterPay struct {
 	*xweb.Action
 	getUserInfo        xweb.Mapper `xweb:"/afterPay/getUserInfo"`         //获取用户当前支付后的信息
@@ -61,7 +62,7 @@ func (a *AfterPay) Modification() error {
 	return nil
 }
 
-//快速导入普通订阅关键词
+// 快速导入普通订阅关键词
 func (a *AfterPay) FastImport() error {
 	defer qutil.Catch()
 	userId, _ := a.GetSession("userId").(string)
@@ -162,7 +163,6 @@ func (a *AfterPay) FastImport() error {
 	return nil
 }
 
-//
 func (a *AfterPay) CheckOrder() error {
 	defer qutil.Catch()
 	var flag = false
@@ -179,7 +179,7 @@ func (a *AfterPay) CheckOrder() error {
 	return nil
 }
 
-//搜索关键词直接订阅
+// 搜索关键词直接订阅
 func (a *AfterPay) DirectSubKWS() error {
 	defer qutil.Catch()
 	userId, _ := a.GetSession("userId").(string)
@@ -266,7 +266,6 @@ func (a *AfterPay) DirectSubKWS() error {
 	return nil
 }
 
-//
 func (a *AfterPay) UpdateUserTips() error {
 	defer qutil.Catch()
 	userId, _ := a.GetSession("userId").(string)
@@ -294,7 +293,6 @@ func (a *AfterPay) UpdateUserTips() error {
 	return nil
 }
 
-//
 func (a *AfterPay) GetPushView() error {
 	defer qutil.Catch()
 	userId, _ := a.GetSession("userId").(string)
@@ -313,7 +311,6 @@ func (a *AfterPay) GetPushView() error {
 	return nil
 }
 
-//
 func (a *AfterPay) GetPushCount() error {
 	defer qutil.Catch()
 	userId, _ := a.GetSession("userId").(string)
@@ -330,7 +327,6 @@ func (a *AfterPay) GetPushCount() error {
 	return nil
 }
 
-//
 func (a *AfterPay) KeysetGetPushCount() error {
 	defer qutil.Catch()
 	userId, _ := a.GetSession("userId").(string)
@@ -346,7 +342,6 @@ func (a *AfterPay) KeysetGetPushCount() error {
 	return nil
 }
 
-//
 func (a *AfterPay) SetUserInfo() error {
 	defer qutil.Catch()
 	userId, _ := a.GetSession("userId").(string)
@@ -648,10 +643,10 @@ func (a *AfterPay) SetUserInfo() error {
 	return nil
 }
 
-//
 var threeRemind = int64(3 * 24 * 60 * 60)
 var twoRemind = int64(2 * 24 * 60 * 60)
 var oneRemind = int64(1 * 24 * 60 * 60)
+var rx = regexp.MustCompile("\n+")
 
 func (a *AfterPay) GetUserInfo() error {
 	defer qutil.Catch()
@@ -703,7 +698,20 @@ func (a *AfterPay) GetUserInfo() error {
 					tmp := qutil.ObjToMap(v.(map[string]interface{}))
 					a_key := (*tmp)["a_key"].([]interface{})
 					for _, n := range a_key {
+						var keywords []string
 						ntmp := qutil.ObjToMap(n.(interface{}))
+						keyS := qutil.ObjArrToStringArr((*ntmp)["key"].([]interface{}))
+						if len(keyS) > 0 {
+							for _, key := range keyS {
+								if key = strings.TrimSpace(rx.ReplaceAllString(key, " ")); key != "" {
+									keywords = append(keywords, key)
+								}
+							}
+						}
+						if len(keywords) == 0 {
+							continue
+						}
+						(*ntmp)["key"] = keywords
 						if (*ntmp)["appendkey"] != nil && (*ntmp)["updatetime"] == nil {
 							appendkey := qutil.ObjArrToStringArr((*ntmp)["appendkey"].([]interface{}))
 							if len(appendkey) > 0 {
@@ -779,7 +787,7 @@ func (a *AfterPay) GetUserInfo() error {
 	return nil
 }
 
-//关键词判重
+// 关键词判重
 func KeyWordsRepeat(obj map[string]interface{}, aitems []interface{}, c_i, k_i int) bool {
 	// 录入的关键词
 	key, _ := obj["key"].([]string)
@@ -818,7 +826,7 @@ func KeyWordsRepeat(obj map[string]interface{}, aitems []interface{}, c_i, k_i i
 	return false
 }
 
-//判断同一个数组是否重复
+// 判断同一个数组是否重复
 func isRepeat(slice1 []string) bool {
 	m := make(map[string]int)
 	for _, v := range slice1 {
@@ -841,7 +849,7 @@ func JsonToMap(jsonStr string) (map[string]interface{}, error) {
 	return m, nil
 }
 
-//string数组排序
+// string数组排序
 func SelectSortSring(arr []string) []string {
 	length := len(arr)
 	if length <= 1 {
@@ -862,7 +870,7 @@ func SelectSortSring(arr []string) []string {
 	}
 }
 
-//判断stringArr相等方法
+// 判断stringArr相等方法
 func StringArrEqual(a, b []string) bool {
 	if (len(a) == 0) != (len(b) == 0) {
 		return false