|
@@ -7,7 +7,7 @@ import (
|
|
|
IC "jyBXCore/rpc/init"
|
|
|
)
|
|
|
|
|
|
-//标讯搜索:全文搜索和附件搜索限制
|
|
|
+// 标讯搜索:全文搜索和附件搜索限制
|
|
|
func IsSearchLimit(searchItems []string) bool {
|
|
|
for _, searchItem := range searchItems {
|
|
|
if searchItem == "detail" || searchItem == "filetext" {
|
|
@@ -17,7 +17,6 @@ func IsSearchLimit(searchItems []string) bool {
|
|
|
return false
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
func LimitSearchInit() {
|
|
|
if IC.C.LimitSearchText.Flag {
|
|
|
LimitSearchClear()
|
|
@@ -27,28 +26,30 @@ func LimitSearchInit() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
func LimitSearchClear() {
|
|
|
redis.Del("other", IC.SearchLimitKey)
|
|
|
}
|
|
|
|
|
|
-//限制正文、附件查询
|
|
|
-//return 1 正常
|
|
|
-//return -1 抱歉!由于系统繁忙暂时无法进行搜索,请1分钟后再试!
|
|
|
-//return -2 抱歉!由于系统繁忙暂时无法进行搜索,请稍后再试!
|
|
|
-func IsLimited(userId string, isPayedUser bool) int64 {
|
|
|
+// 限制正文、附件查询
|
|
|
+// return 1 正常
|
|
|
+// return -1 抱歉!由于系统繁忙暂时无法进行搜索,请1分钟后再试!
|
|
|
+// return -2 抱歉!由于系统繁忙暂时无法进行搜索,请稍后再试!
|
|
|
+func IsLimited(limitFlag, userid string, isPayedUser, isNew bool) int64 {
|
|
|
if !IC.C.LimitSearchText.Flag {
|
|
|
return 1
|
|
|
}
|
|
|
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(IC.C.LimitSearchText.LimitKey, userId))
|
|
|
- if timeLimit {
|
|
|
- return -1
|
|
|
+ //limitFlag, isNew := getFlag(r, w, userid)
|
|
|
+ if isNew {
|
|
|
+ if llen <= IC.C.LimitSearchText.Count/2 {
|
|
|
+ timeLimit, _ := redis.Exists("other", fmt.Sprintf(IC.C.LimitSearchText.LimitKey, limitFlag))
|
|
|
+ if timeLimit {
|
|
|
+ return -1
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- redis.Put("other", fmt.Sprintf(IC.C.LimitSearchText.LimitKey, userId), 1, IC.C.LimitSearchText.TimeOut)
|
|
|
+ redis.Put("other", fmt.Sprintf(IC.C.LimitSearchText.LimitKey, limitFlag), 1, IC.C.LimitSearchText.TimeOut)
|
|
|
}
|
|
|
|
|
|
if IC.C.LimitSearchText.Count == -2 { //不限制
|
|
@@ -57,7 +58,11 @@ func IsLimited(userId string, isPayedUser bool) int64 {
|
|
|
return -2
|
|
|
}
|
|
|
//免费和付费用户 使用并发的80%(默认)通道|| 保留一条通道给付费用户使用
|
|
|
- if !isPayedUser {
|
|
|
+ if userid == "" { //未登录用户,2个并发数限制
|
|
|
+ if IC.C.LimitSearchText.Count-IC.C.LimitSearchText.NoLogin <= 0 || llen <= IC.C.LimitSearchText.Count-IC.C.LimitSearchText.NoLogin || llen == 1 {
|
|
|
+ return -2
|
|
|
+ }
|
|
|
+ } else if !isPayedUser {
|
|
|
if llen <= IC.C.LimitSearchText.Count*IC.C.LimitSearchText.Percentage/100 || llen == 1 {
|
|
|
return -1
|
|
|
}
|
|
@@ -70,7 +75,6 @@ func IsLimited(userId string, isPayedUser bool) int64 {
|
|
|
return 1
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
func Limit() {
|
|
|
if !IC.C.LimitSearchText.Flag {
|
|
|
return
|
|
@@ -80,7 +84,6 @@ func Limit() {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-//
|
|
|
func IsCanLogin(userId string) bool {
|
|
|
for _, v := range IC.C.LimitSearchText.UserIds {
|
|
|
if v == userId {
|