|
@@ -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)
|
|
|
}
|
|
|
}
|
|
|
|