|
@@ -18,11 +18,11 @@ import (
|
|
|
|
|
|
type CustomerRule struct {
|
|
|
*xweb.Action
|
|
|
- cuserRuleCreate xweb.Mapper `xweb:"/customerRule/cuser/rule/create"` //新建规则
|
|
|
- ruleImport xweb.Mapper `xweb:"/customerRule/rule/import"` //导入关键词 导入文件excel
|
|
|
- productData xweb.Mapper `xweb:"/customerRule/cuser/produce"` //生成预览数据
|
|
|
- demoData xweb.Mapper `xweb:"/customerRule/rule/preview"` //预览数据
|
|
|
- dataTest xweb.Mapper `xweb:"/customerRule/rule/dataTest/(.*)"` //规则测试
|
|
|
+ cuserRuleCreate xweb.Mapper `xweb:"/customerRule/cuser/rule/create"` //新建规则
|
|
|
+ ruleImport xweb.Mapper `xweb:"/customerRule/rule/import"` //导入关键词 导入文件excel
|
|
|
+ productData xweb.Mapper `xweb:"/customerRule/cuser/produce"` //生成预览数据
|
|
|
+ demoData xweb.Mapper `xweb:"/customerRule/rule/preview"` //预览数据
|
|
|
+ dataTest xweb.Mapper `xweb:"/customerRule/rule/dataTest/(.*)"` //规则测试
|
|
|
}
|
|
|
|
|
|
func (c *CustomerRule) CuserRuleCreate() {
|
|
@@ -151,7 +151,7 @@ func (c *CustomerRule) ProductData() {
|
|
|
// 限制multi_match 个数小于1000个
|
|
|
s_esquery := qu.ObjToString((*tag)["s_esquery"])
|
|
|
multi_match_count := strings.Count(s_esquery, "multi_match")
|
|
|
- //fmt.Println("multi_match", multi_match_count, s_esquery)
|
|
|
+ fmt.Println("multi_match",multi_match_count,s_esquery)
|
|
|
if multi_match_count > 1000 {
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"rep": false,
|
|
@@ -193,7 +193,7 @@ func (c *CustomerRule) ProductData() {
|
|
|
}
|
|
|
}
|
|
|
// 判断总数是否大于4000
|
|
|
- //fmt.Println(keyTotal, addKeyTotal)
|
|
|
+ fmt.Println(keyTotal,addKeyTotal)
|
|
|
if keyTotal > 4000 || addKeyTotal > 4000 {
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"rep": false,
|
|
@@ -215,7 +215,7 @@ func (c *CustomerRule) ProductData() {
|
|
|
c.ServeJson(map[string]interface{}{
|
|
|
"rep": rep,
|
|
|
"count": count,
|
|
|
- "msg": msg,
|
|
|
+ "msg":msg,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
@@ -252,18 +252,18 @@ func (this *CustomerRule) DataTest(id string) {
|
|
|
//获取数据
|
|
|
title := this.GetString("title")
|
|
|
detail := this.GetString("detail")
|
|
|
- //fmt.Println(title, detail)
|
|
|
+ fmt.Println(title,detail)
|
|
|
if title == "" && detail == "" {
|
|
|
this.ServeJson(map[string]interface{}{
|
|
|
- "status": false,
|
|
|
- "data": "",
|
|
|
- "message": "标题和正文至少要有一个",
|
|
|
+ "status":false,
|
|
|
+ "data":"",
|
|
|
+ "message":"标题和正文至少要有一个",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
- article := map[string]interface{}{
|
|
|
- "title": title,
|
|
|
- "detail": detail,
|
|
|
+ article :=map[string]interface{}{
|
|
|
+ "title":title,
|
|
|
+ "detail":detail,
|
|
|
}
|
|
|
|
|
|
log.Println("测试数据是否匹配开始...")
|
|
@@ -301,13 +301,14 @@ func (this *CustomerRule) DataTest(id string) {
|
|
|
//清理清理词
|
|
|
for _, cwm := range cwmArr {
|
|
|
if text := qu.ObjToString(article[cwm]); text != "" {
|
|
|
- for _, gcw_reg := range cwkArr {
|
|
|
+ for _, gcw_reg := range cwkArr{
|
|
|
text = gcw_reg.ReplaceAllString(text, "")
|
|
|
}
|
|
|
article[cwm] = text
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
o_rule, ok := c["o_rules"].([]interface{})
|
|
|
if !ok {
|
|
|
o_rule = []interface{}{}
|
|
@@ -319,13 +320,14 @@ func (this *CustomerRule) DataTest(id string) {
|
|
|
gKey := TestMactchKeys(s_globaladdkeymatch, s_globaladdkey, article)
|
|
|
if gKey == "" {
|
|
|
this.ServeJson(map[string]interface{}{
|
|
|
- "status": true,
|
|
|
- "data": map[string]interface{}{
|
|
|
- "result": false,
|
|
|
+ "status":true,
|
|
|
+ "data":map[string]interface{}{
|
|
|
+ "result": false,
|
|
|
"info": "全局附加词没有匹配成功",
|
|
|
"data": s_globaladdkey,
|
|
|
},
|
|
|
- "message": "测试成功",
|
|
|
+ "message":"测试成功",
|
|
|
+
|
|
|
})
|
|
|
return
|
|
|
} else {
|
|
@@ -336,13 +338,13 @@ func (this *CustomerRule) DataTest(id string) {
|
|
|
gNKey := TestMactchKeys(s_globalnotkeymatch, s_globalnotkey, article)
|
|
|
if gNKey != "" {
|
|
|
this.ServeJson(map[string]interface{}{
|
|
|
- "status": true,
|
|
|
- "data": map[string]interface{}{
|
|
|
- "result": false,
|
|
|
- "info": "被全局排除词排除",
|
|
|
- "data": gNKey,
|
|
|
+ "status":true,
|
|
|
+ "data":map[string]interface{}{
|
|
|
+ "result": false,
|
|
|
+ "info":"被全局排除词排除",
|
|
|
+ "data": gNKey,
|
|
|
},
|
|
|
- "message": "测试成功",
|
|
|
+ "message":"测试成功",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
@@ -350,7 +352,7 @@ func (this *CustomerRule) DataTest(id string) {
|
|
|
|
|
|
var resultList []interface{}
|
|
|
for _, v := range o_rules {
|
|
|
- matchKey = ""
|
|
|
+ matchKey=""
|
|
|
key := qu.ObjToString(v["s_matchkey"])
|
|
|
keymatch := qu.ObjToString(v["s_keymatch"])
|
|
|
addkey := qu.ObjToString(v["s_addkey"])
|
|
@@ -358,12 +360,12 @@ func (this *CustomerRule) DataTest(id string) {
|
|
|
notkey := qu.ObjToString(v["s_notkey"])
|
|
|
notkeymatch := qu.ObjToString(v["s_notkeymatch"])
|
|
|
var tempData = map[string]interface{}{
|
|
|
- "key": key,
|
|
|
- "keymatch": keymatch,
|
|
|
- "addkey": addkey,
|
|
|
- "addkeymatch": addkeymatch,
|
|
|
- "notkey": notkey,
|
|
|
- "notkeymatch": notkeymatch,
|
|
|
+ "key":key,
|
|
|
+ "keymatch":keymatch,
|
|
|
+ "addkey":addkey,
|
|
|
+ "addkeymatch":addkeymatch,
|
|
|
+ "notkey":notkey,
|
|
|
+ "notkeymatch":notkeymatch,
|
|
|
}
|
|
|
if notkey != "" {
|
|
|
nKey := TestMactchKeys(notkeymatch, notkey, article)
|
|
@@ -371,42 +373,34 @@ func (this *CustomerRule) DataTest(id string) {
|
|
|
tempData["status"] = false
|
|
|
tempData["info"] = "排除词排除"
|
|
|
tempData["data"] = nKey
|
|
|
- tempData["marknotkey"] = nKey
|
|
|
- resultList = append(resultList, tempData)
|
|
|
- if key != "" {
|
|
|
- tempData["markkey"] = TestMactchKeys(keymatch, key, article)
|
|
|
- }
|
|
|
- if addkey != "" {
|
|
|
- tempData["markaddkey"] = TestMactchKeys(addkeymatch, addkey, article)
|
|
|
- }
|
|
|
+ resultList = append(resultList,tempData)
|
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
if key != "" {
|
|
|
sKey := TestMactchKeys(keymatch, key, article)
|
|
|
- tempData["markkey"] = sKey
|
|
|
aKey := ""
|
|
|
if addkey != "" {
|
|
|
aKey = TestMactchKeys(addkeymatch, addkey, article)
|
|
|
- tempData["markaddkey"] = aKey
|
|
|
if aKey != "" && sKey != "" {
|
|
|
matchKey = aKey + "," + sKey
|
|
|
tempData["status"] = true
|
|
|
tempData["info"] = "匹配成功"
|
|
|
tempData["data"] = matchKey
|
|
|
- resultList = append(resultList, tempData)
|
|
|
+ resultList = append(resultList,tempData)
|
|
|
+
|
|
|
|
|
|
- } else if aKey == "" {
|
|
|
+ }else if aKey == "" {
|
|
|
tempData["status"] = false
|
|
|
tempData["info"] = "附加词匹配失败"
|
|
|
tempData["data"] = ""
|
|
|
- resultList = append(resultList, tempData)
|
|
|
+ resultList = append(resultList,tempData)
|
|
|
|
|
|
- } else if sKey == "" {
|
|
|
+ }else if sKey == "" {
|
|
|
tempData["status"] = false
|
|
|
tempData["info"] = "关键词匹配失败"
|
|
|
tempData["data"] = ""
|
|
|
- resultList = append(resultList, tempData)
|
|
|
+ resultList = append(resultList,tempData)
|
|
|
|
|
|
}
|
|
|
} else {
|
|
@@ -415,29 +409,30 @@ func (this *CustomerRule) DataTest(id string) {
|
|
|
tempData["status"] = true
|
|
|
tempData["info"] = "匹配成功"
|
|
|
tempData["data"] = matchKey
|
|
|
- resultList = append(resultList, tempData)
|
|
|
+ resultList = append(resultList,tempData)
|
|
|
|
|
|
- } else {
|
|
|
+ }else {
|
|
|
|
|
|
matchKey = sKey
|
|
|
tempData["status"] = false
|
|
|
tempData["info"] = "关键词匹配失败"
|
|
|
tempData["data"] = matchKey
|
|
|
- resultList = append(resultList, tempData)
|
|
|
+ resultList = append(resultList,tempData)
|
|
|
+
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if resultList == nil {
|
|
|
+ if resultList == nil{
|
|
|
this.ServeJson(map[string]interface{}{
|
|
|
- "status": true,
|
|
|
- "data": map[string]interface{}{
|
|
|
- "result": true,
|
|
|
- "info": "全局附加词匹配成功" + matchKey,
|
|
|
- "data": "",
|
|
|
+ "status":true,
|
|
|
+ "data":map[string]interface{}{
|
|
|
+ "result": true,
|
|
|
+ "info":"全局附加词匹配成功"+matchKey,
|
|
|
+ "data": "",
|
|
|
},
|
|
|
- "message": "测试成功",
|
|
|
+ "message":"测试成功",
|
|
|
})
|
|
|
return
|
|
|
|
|
@@ -451,13 +446,15 @@ func (this *CustomerRule) DataTest(id string) {
|
|
|
return
|
|
|
} else {
|
|
|
|
|
|
+
|
|
|
log.Println("初始化客户信息失败")
|
|
|
this.ServeJson(map[string]interface{}{
|
|
|
- "status": true,
|
|
|
- "data": "",
|
|
|
- "message": "初始化客户信息失败",
|
|
|
+ "status":true,
|
|
|
+ "data":"",
|
|
|
+ "message":"初始化客户信息失败",
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
log.Println("测试数据是否匹配结束...")
|
|
|
}
|
|
|
+
|