Просмотр исходного кода

feat:增加关键词个数限制处理

zhangxinlei1996 2 лет назад
Родитель
Сommit
016a34dd67
1 измененных файлов с 8 добавлено и 4 удалено
  1. 8 4
      jyBXSubscribe/api/internal/logic/subscribeupdatelogic.go

+ 8 - 4
jyBXSubscribe/api/internal/logic/subscribeupdatelogic.go

@@ -7,7 +7,6 @@ import (
 	"jyBXSubscribe/api/internal/svc"
 	"jyBXSubscribe/api/internal/types"
 	"jyBXSubscribe/rpc/model/service"
-	"log"
 
 	"app.yhyue.com/moapp/jybase/common"
 
@@ -56,7 +55,7 @@ func (l *SubscribeUpdateLogic) SubscribeUpdate(req *types.SubscribeUpdateReq) (r
 		resp.Data = map[string]interface{}{
 			"status": -1,
 		}
-		resp.Err_code, resp.Err_msg = -1, "关键词重复"
+		resp.Err_code, resp.Err_msg = -1, "关键词设置异常"
 		return
 	}
 	if req.Items != nil {
@@ -92,10 +91,11 @@ func (l *SubscribeUpdateLogic) SubscribeUpdate(req *types.SubscribeUpdateReq) (r
 	return
 }
 
-//关键词是否有重复
+//判断关键词是否异常,
 func KeyWordsRepeat(aitems []map[string]interface{}) bool {
 	m := map[string]bool{} //去重的数组
 	// 录入的关键词
+	i := 0
 	for _, items := range aitems {
 		for kk, vv := range items {
 			if kk == "a_key" {
@@ -118,13 +118,17 @@ func KeyWordsRepeat(aitems []map[string]interface{}) bool {
 					}
 					key := fmt.Sprintf("%v%v%v%s", db_key, db_append, db_not, matchway)
 					if m[key] {
-						log.Println("关键词重复 不可提交")
 						return true //有重复 不可以提交
 					}
+					i++
 					m[key] = true
 				}
 			}
 		}
 	}
+	if i > 300 {
+		//关键词大于300异常
+		return true
+	}
 	return false
 }