|
@@ -5,6 +5,7 @@ import (
|
|
"app.yhyue.com/moapp/jybase/redis"
|
|
"app.yhyue.com/moapp/jybase/redis"
|
|
IC "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXCore/rpc/init"
|
|
IC "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXCore/rpc/init"
|
|
"fmt"
|
|
"fmt"
|
|
|
|
+ "strings"
|
|
)
|
|
)
|
|
|
|
|
|
// 标讯搜索:全文搜索和附件搜索限制
|
|
// 标讯搜索:全文搜索和附件搜索限制
|
|
@@ -118,7 +119,7 @@ return -1 抱歉!由于系统繁忙暂时无法进行搜索,请1分钟后再
|
|
return -2 抱歉!由于系统繁忙暂时无法进行搜索,请稍后再试!
|
|
return -2 抱歉!由于系统繁忙暂时无法进行搜索,请稍后再试!
|
|
userIdent 未登录用户是;cookie 中存的标识;登录用户是UserId
|
|
userIdent 未登录用户是;cookie 中存的标识;登录用户是UserId
|
|
*/
|
|
*/
|
|
-func CheckLimit(userType int, userIdent string, isNew bool) (state int64) {
|
|
|
|
|
|
+func CheckLimit(userType int, userIdent string, isNew bool) (state int64, msg string) {
|
|
if !IC.C.LimitSearchText.Flag {
|
|
if !IC.C.LimitSearchText.Flag {
|
|
state = 1
|
|
state = 1
|
|
return
|
|
return
|
|
@@ -128,12 +129,14 @@ func CheckLimit(userType int, userIdent string, isNew bool) (state int64) {
|
|
case -2: //不限制
|
|
case -2: //不限制
|
|
state = 1
|
|
state = 1
|
|
return
|
|
return
|
|
- case -1:
|
|
|
|
|
|
+ case -1: //无条件限制
|
|
state = -2
|
|
state = -2
|
|
|
|
+ msg = fmt.Sprintf("筛选条件:%s,必限制。", strings.Join(IC.C.LimitSearchText.LimitItems, ","))
|
|
return
|
|
return
|
|
default:
|
|
default:
|
|
if limitCount <= 0 {
|
|
if limitCount <= 0 {
|
|
state = -1
|
|
state = -1
|
|
|
|
+ msg = fmt.Sprintf("并发通道总数:%d,\n未使用数量:%d", IC.C.LimitSearchText.Count, limitCount)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -144,6 +147,7 @@ func CheckLimit(userType int, userIdent string, isNew bool) (state int64) {
|
|
timeLimit, _ := redis.Exists("other", fmt.Sprintf(IC.C.LimitSearchText.LimitKey, userIdent))
|
|
timeLimit, _ := redis.Exists("other", fmt.Sprintf(IC.C.LimitSearchText.LimitKey, userIdent))
|
|
if timeLimit {
|
|
if timeLimit {
|
|
state = -1
|
|
state = -1
|
|
|
|
+ msg = fmt.Sprintf("当前用户筛选频次在%d秒内请求多次,并发通道-\n总数:%d,\n未使用数量:%d", IC.C.LimitSearchText.TimeOut, IC.C.LimitSearchText.Count, limitCount)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -158,21 +162,27 @@ func CheckLimit(userType int, userIdent string, isNew bool) (state int64) {
|
|
}
|
|
}
|
|
default:
|
|
default:
|
|
state = -2
|
|
state = -2
|
|
|
|
+ userStr := MC.If(userType == 2, "免费用户", "未登录用户").(string)
|
|
|
|
+ msg = fmt.Sprintf("%s 招投标重要字段筛选", userStr)
|
|
if limitCount > IC.C.LimitSearchText.ForPayer {
|
|
if limitCount > IC.C.LimitSearchText.ForPayer {
|
|
switch userType {
|
|
switch userType {
|
|
case 2:
|
|
case 2:
|
|
quota := limitCount * IC.C.LimitSearchText.Percentage / 100
|
|
quota := limitCount * IC.C.LimitSearchText.Percentage / 100
|
|
if quota > 0 {
|
|
if quota > 0 {
|
|
state = 1
|
|
state = 1
|
|
|
|
+ msg = ""
|
|
} else {
|
|
} else {
|
|
state = -1
|
|
state = -1
|
|
|
|
+ msg = fmt.Sprintf("%s,\n总并发量的百分之%d,", msg, IC.C.LimitSearchText.Percentage)
|
|
}
|
|
}
|
|
case 3:
|
|
case 3:
|
|
quota := limitCount * IC.C.LimitSearchText.NoLogin / 100
|
|
quota := limitCount * IC.C.LimitSearchText.NoLogin / 100
|
|
if quota > 0 {
|
|
if quota > 0 {
|
|
state = 1
|
|
state = 1
|
|
|
|
+ msg = ""
|
|
} else {
|
|
} else {
|
|
state = -1
|
|
state = -1
|
|
|
|
+ msg = fmt.Sprintf("%s,\n总并发量的百分之%d,", msg, IC.C.LimitSearchText.NoLogin)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -182,5 +192,8 @@ func CheckLimit(userType int, userIdent string, isNew bool) (state int64) {
|
|
if MC.IntAll(pollLimit) <= 0 {
|
|
if MC.IntAll(pollLimit) <= 0 {
|
|
state = -2
|
|
state = -2
|
|
}
|
|
}
|
|
|
|
+ if msg != "" {
|
|
|
|
+ msg = fmt.Sprintf("%s,\n并发通道总数:%d,\n未使用数量:%d", msg, IC.C.LimitSearchText.Count, limitCount)
|
|
|
|
+ }
|
|
return
|
|
return
|
|
}
|
|
}
|