Sfoglia il codice sorgente

Merge branch 'master' into feature/v1.1

123456 3 anni fa
parent
commit
e64c4e7fc8

+ 1 - 1
jyBXCore/go.mod

@@ -3,7 +3,7 @@ module jyBXCore
 go 1.16
 
 require (
-	app.yhyue.com/moapp/jybase v0.0.0-20220617085837-48c1bf245c2f
+	app.yhyue.com/moapp/jybase v0.0.0-20220701093636-1a2604e6265f
 	bp.jydev.jianyu360.cn/BaseService/gateway v0.0.0-20220505015640-56e56f06bc5c
 	github.com/go-sql-driver/mysql v1.6.0
 	github.com/golang/protobuf v1.5.2

+ 2 - 2
jyBXCore/go.sum

@@ -4,8 +4,8 @@ app.yhyue.com/moapp/jybase v0.0.0-20220415064050-37ce64b3e2d4/go.mod h1:qNRA0sHu
 app.yhyue.com/moapp/jybase v0.0.0-20220418104200-46c3fff161c7/go.mod h1:qNRA0sHuYqcLoYoP8irpaWnW9YsXixe6obBIkwaXpD0=
 app.yhyue.com/moapp/jybase v0.0.0-20220420032112-668025915ee4/go.mod h1:qNRA0sHuYqcLoYoP8irpaWnW9YsXixe6obBIkwaXpD0=
 app.yhyue.com/moapp/jybase v0.0.0-20220421060131-a1001013ba46/go.mod h1:qNRA0sHuYqcLoYoP8irpaWnW9YsXixe6obBIkwaXpD0=
-app.yhyue.com/moapp/jybase v0.0.0-20220617085837-48c1bf245c2f h1:U8sVqWn/JH2gcsJqQcHFaCx/MtY1pGUwbUAc5dVkwto=
-app.yhyue.com/moapp/jybase v0.0.0-20220617085837-48c1bf245c2f/go.mod h1:qNRA0sHuYqcLoYoP8irpaWnW9YsXixe6obBIkwaXpD0=
+app.yhyue.com/moapp/jybase v0.0.0-20220701093636-1a2604e6265f h1:FXXQc+p6IN4YWRR8/onMOLmHLrsvTa2lO4W/ATv7cK0=
+app.yhyue.com/moapp/jybase v0.0.0-20220701093636-1a2604e6265f/go.mod h1:qNRA0sHuYqcLoYoP8irpaWnW9YsXixe6obBIkwaXpD0=
 bp.jydev.jianyu360.cn/BP/jynsq v0.0.0-20220222052708-ebc43af90698/go.mod h1:ojo/AUH9Yr1wzarEjOaNMkj1Cet/9r8IgLyba64Z52E=
 bp.jydev.jianyu360.cn/BaseService/gateway v0.0.0-20220419090715-88ddb32961be/go.mod h1:Yj4oabIGItuMoF0BXYLz2XAnF581kxgXBrvlUtIJrkI=
 bp.jydev.jianyu360.cn/BaseService/gateway v0.0.0-20220505015640-56e56f06bc5c h1:p2WctRqfE6wdLPHnACIO983CfYV2LLaaLC2ADpSaNn0=

+ 4 - 2
jyBXCore/rpc/etc/bxcore.yaml

@@ -14,11 +14,13 @@ LabelUrl:
 PCSTime: 24
 LimitSearchText:
   Flag: true
-  Count: 3
+  Count: 40
   TimeOut: 60
   Percentage: 80
   UserIds:
-    - 60f4f01156bf6da1bcbbcff6
+    - 581858dbc9ebc2132200002e
+    - 5cc02842c9ebc2227593893d
   Msg: f 开关状态:%s //-2 从配置文件重置,-1 关闭,1 打开<br><br>c 并发数:%d //-2 不限制并发数,-1 无条件直接限制,>0 限制并发数<br><br>t 个人查询限制时间:%ds //-1 不限制<br><br>
+  LimitKey: mobile_limit_%s
 SearchTypeSwitch: true
 FileSignBool: true

+ 7 - 0
jyBXCore/rpc/init/init.go

@@ -2,6 +2,7 @@ package init
 
 import (
 	"flag"
+	"fmt"
 	_ "github.com/go-sql-driver/mysql"
 	"github.com/zeromicro/go-zero/core/conf"
 	"github.com/zeromicro/go-zero/core/logx"
@@ -21,6 +22,10 @@ var DB config.Db
 var logFile = flag.String("lf", "etc/logs.yaml", "the logs file")
 var logc entity.Logc
 
+//全文或附件搜索限制
+var SearchLimitKey = "jy_limitSearchText_new"
+var SearchLimitFlag = "jy_limitSearchText_%s"
+
 func init() {
 	//基本配置
 	conf.MustLoad(*configFile, &C)
@@ -49,4 +54,6 @@ func init() {
 	}
 	//初始化标签
 	LabelInit()
+	//
+	SearchLimitKey = fmt.Sprintf(C.LimitSearchText.LimitKey, "jy_limitSearchText")
 }

+ 1 - 0
jyBXCore/rpc/internal/config/config.go

@@ -22,6 +22,7 @@ type Config struct {
 		Percentage int
 		UserIds    []string
 		Msg        string
+		LimitKey   string
 	}
 	SearchTypeSwitch bool
 	FileSignBool     bool

+ 8 - 11
jyBXCore/rpc/util/limitSearchText.go

@@ -7,9 +7,6 @@ import (
 	IC "jyBXCore/rpc/init"
 )
 
-var SearchLimitKey = "jy_limitSearchText_new"
-var SearchLimitFlag = "jy_limitSearchText_%s"
-
 //标讯搜索:全文搜索和附件搜索限制
 func IsSearchLimit(searchItems []string) bool {
 	for _, searchItem := range searchItems {
@@ -25,14 +22,14 @@ func LimitSearchInit() {
 	if IC.C.LimitSearchText.Flag {
 		LimitSearchClear()
 		for i := 0; i < IC.C.LimitSearchText.Count; i++ {
-			redis.RPUSH("other", SearchLimitKey, 1)
+			redis.RPUSH("other", IC.SearchLimitKey, 1)
 		}
 	}
 }
 
 //
 func LimitSearchClear() {
-	redis.Del("other", SearchLimitKey)
+	redis.Del("other", IC.SearchLimitKey)
 }
 
 //限制正文、附件查询
@@ -43,15 +40,15 @@ func IsLimited(userId string, isPayedUser bool) int64 {
 	if !IC.C.LimitSearchText.Flag {
 		return 1
 	}
-	var llen = int(redis.LLEN("other", SearchLimitKey))
+	var llen = int(redis.LLEN("other", IC.SearchLimitKey))
 	if IC.C.LimitSearchText.TimeOut > 0 {
 		if llen <= IC.C.LimitSearchText.Count/2 {
-			timeLimit, _ := redis.Exists("other", fmt.Sprintf(SearchLimitFlag, userId))
+			timeLimit, _ := redis.Exists("other", fmt.Sprintf(IC.C.LimitSearchText.LimitKey, userId))
 			if timeLimit {
 				return -1
 			}
 		}
-		redis.Put("other", fmt.Sprintf(SearchLimitFlag, userId), 1, IC.C.LimitSearchText.TimeOut)
+		redis.Put("other", fmt.Sprintf(IC.C.LimitSearchText.LimitKey, userId), 1, IC.C.LimitSearchText.TimeOut)
 	}
 
 	if IC.C.LimitSearchText.Count == -2 { //不限制
@@ -66,7 +63,7 @@ func IsLimited(userId string, isPayedUser bool) int64 {
 		}
 	}
 	//
-	pollLimit := redis.LPOP("other", SearchLimitKey)
+	pollLimit := redis.LPOP("other", IC.SearchLimitKey)
 	if MC.IntAll(pollLimit) <= 0 {
 		return -2
 	}
@@ -78,8 +75,8 @@ func Limit() {
 	if !IC.C.LimitSearchText.Flag {
 		return
 	}
-	if int(redis.LLEN("other", SearchLimitKey)) < IC.C.LimitSearchText.Count {
-		redis.RPUSH("other", SearchLimitKey, 1)
+	if int(redis.LLEN("other", IC.SearchLimitKey)) < IC.C.LimitSearchText.Count {
+		redis.RPUSH("other", IC.SearchLimitKey, 1)
 	}
 }