Преглед на файлове

feat:缓存搜索&限制搜索属性

wangshan преди 3 години
родител
ревизия
75fea9d5ea

+ 1 - 1
jyBXBase/api/etc/logs.yaml

@@ -3,4 +3,4 @@ Path: ./logs
 Level:
   - info
   - error
-KeepDays: 10
+KeepDays: 1

+ 1 - 1
jyBXBase/rpc/bxcollection/etc/logs.yaml

@@ -3,4 +3,4 @@ Path: ./logs
 Level:
   - info
   - error
-KeepDays: 10
+KeepDays: 1

+ 11 - 0
jyBXCore/api/bxcore.api

@@ -34,8 +34,19 @@ type (
 		Err_msg  string      `json:"error_msg"`
 		Data     interface{} `json:"data"`
 	}
+	//
+	searchLimitReq {
+		AppId      string `json:"appId"`      //appid
+		TimeOut    int64  `json:"timeOut"`    //过滤过期时间
+		Count      int64  `json:"count"`      //并发量
+		Flag       int64  `json:"flag"`       //开关 1:打开;-1:关闭;-2:重置
+		Percentage int64  `json:"percentage"` //付费用户占比
+		SearchType string `path:"searchType"` //get|update|
+	}
 )
 service bxcore-api {
 	@handler searchList
 	post /jybx/core/:userType/searchList(searchReq) returns (commonResp)
+	@handler limitSearchContent
+	post /jybx/core/:searchType/searchLimit(searchLimitReq) returns (commonResp)
 }

+ 1 - 1
jyBXCore/api/etc/bxcore-api.yaml

@@ -12,4 +12,4 @@ Core:
     Hosts:
       - 127.0.0.1:2379
     Key: bxcore.rpc
-AppId: 10000
+AppId: 10000

+ 1 - 1
jyBXCore/api/etc/logs.yaml

@@ -3,4 +3,4 @@ Path: ./logs
 Level:
   - info
   - error
-KeepDays: 10
+KeepDays: 1

+ 28 - 0
jyBXCore/api/internal/handler/limitSearchContentHandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"github.com/zeromicro/go-zero/rest/httpx"
+	"jyBXCore/api/internal/logic"
+	"jyBXCore/api/internal/svc"
+	"jyBXCore/api/internal/types"
+)
+
+func limitSearchContentHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.SearchLimitReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewLimitSearchContentLogic(r.Context(), svcCtx, r)
+		resp, err := l.LimitSearchContent(&req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 5 - 0
jyBXCore/api/internal/handler/routes.go

@@ -17,6 +17,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/jybx/core/:userType/searchList",
 				Handler: searchListHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/jybx/core/:searchType/searchLimit",
+				Handler: limitSearchContentHandler(serverCtx),
+			},
 		},
 	)
 }

+ 52 - 0
jyBXCore/api/internal/logic/limitSearchContentLogic.go

@@ -0,0 +1,52 @@
+package logic
+
+import (
+	"context"
+	"jyBXCore/rpc/type/bxcore"
+	"net/http"
+
+	"jyBXCore/api/internal/svc"
+	"jyBXCore/api/internal/types"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type LimitSearchContentLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	r      *http.Request
+}
+
+func NewLimitSearchContentLogic(ctx context.Context, svcCtx *svc.ServiceContext, r *http.Request) *LimitSearchContentLogic {
+	return &LimitSearchContentLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		r:      r,
+	}
+}
+
+func (l *LimitSearchContentLogic) LimitSearchContent(req *types.SearchLimitReq) (resp *types.CommonResp, err error) {
+	res, err := l.svcCtx.BxCore.SearchLimit(l.ctx, &bxcore.SearchLimitReq{
+		Appid:      req.AppId,
+		TimeOut:    req.TimeOut,
+		Count:      req.Count,
+		Flag:       req.Flag,
+		Percentage: req.Percentage,
+		UserId:     l.r.Header.Get("userId"),
+		SearchType: req.SearchType,
+	})
+	if err != nil {
+		return &types.CommonResp{
+			Err_code: res.ErrCode,
+			Err_msg:  res.ErrMsg,
+			Data:     nil,
+		}, nil
+	}
+	return &types.CommonResp{
+		Err_code: res.ErrCode,
+		Err_msg:  res.ErrMsg,
+		Data:     res.Data,
+	}, nil
+}

+ 3 - 6
jyBXCore/api/internal/logic/searchListLogic.go

@@ -2,14 +2,12 @@ package logic
 
 import (
 	"context"
+	"github.com/zeromicro/go-zero/core/logx"
+	"jyBXCore/api/internal/svc"
+	"jyBXCore/api/internal/types"
 	"jyBXCore/api/internal/util"
 	"jyBXCore/rpc/type/bxcore"
 	"net/http"
-
-	"jyBXCore/api/internal/svc"
-	"jyBXCore/api/internal/types"
-
-	"github.com/zeromicro/go-zero/core/logx"
 )
 
 type SearchListLogic struct {
@@ -52,7 +50,6 @@ func (l *SearchListLogic) SearchList(req *types.SearchReq) (resp *types.CommonRe
 		EntId:          l.r.Header.Get("entId"),
 		Platform:       util.CheckPlatform(l.r),
 	})
-	logx.Info("api: ", len(res.Data.List))
 	if err != nil {
 		return &types.CommonResp{
 			Err_code: res.ErrCode,

+ 9 - 0
jyBXCore/api/internal/types/types.go

@@ -27,3 +27,12 @@ type CommonResp struct {
 	Err_msg  string      `json:"error_msg"`
 	Data     interface{} `json:"data"`
 }
+
+type SearchLimitReq struct {
+	AppId      string `json:"appId"`      //appid
+	TimeOut    int64  `json:"timeOut"`    //过滤过期时间
+	Count      int64  `json:"count"`      //并发量
+	Flag       int64  `json:"flag"`       //开关 1:打开;-1:关闭;-2:重置
+	Percentage int64  `json:"percentage"` //付费用户占比
+	SearchType string `path:"searchType"` //get|update|
+}

+ 3 - 1
jyBXCore/rpc/bxcore.go

@@ -5,6 +5,7 @@ import (
 	"app.yhyue.com/moapp/jybase/endless"
 	"fmt"
 	"jyBXCore/rpc/type/bxcore"
+	"jyBXCore/rpc/util"
 	"log"
 
 	"github.com/zeromicro/go-zero/core/service"
@@ -19,7 +20,8 @@ import (
 func main() {
 	//
 	go func() {
-		//IC.InitLimitSearchText(true)
+		//正文、附件搜索限制
+		util.LimitSearchInit()
 		err := endless.ListenAndServe(":"+MC.InterfaceToStr(IC.C.Webrpcport), nil, func() {})
 		if err != nil {
 			log.Println("ListenAndServe: ", err)

+ 18 - 0
jyBXCore/rpc/bxcore.proto

@@ -59,7 +59,25 @@ message  SearchList {
   bool isCollected = 14;
 }
 
+//
+message SearchLimitReq {
+  string appid = 1;
+  int64 timeOut = 2;
+  int64 count = 3;
+  int64 flag = 4;
+  int64  percentage = 5;
+  string  userId = 6;
+  string  searchType = 7;
+}
+//
+message SearchLimitResp {
+  int64 err_code = 1;
+  string err_msg = 2;
+  string data = 3;
+}
 service BxCore {
   //标讯搜索结果列表数据
   rpc GetSearchList(SearchReq) returns(SearchResp);
+  //标讯搜索限制内容
+  rpc SearchLimit(SearchLimitReq) returns(SearchLimitResp);
 }

+ 14 - 4
jyBXCore/rpc/bxcore/bxcore.go

@@ -13,14 +13,18 @@ import (
 )
 
 type (
-	SearchData = bxcore.SearchData
-	SearchList = bxcore.SearchList
-	SearchReq  = bxcore.SearchReq
-	SearchResp = bxcore.SearchResp
+	SearchData      = bxcore.SearchData
+	SearchLimitReq  = bxcore.SearchLimitReq
+	SearchLimitResp = bxcore.SearchLimitResp
+	SearchList      = bxcore.SearchList
+	SearchReq       = bxcore.SearchReq
+	SearchResp      = bxcore.SearchResp
 
 	BxCore interface {
 		// 标讯搜索结果列表数据
 		GetSearchList(ctx context.Context, in *SearchReq, opts ...grpc.CallOption) (*SearchResp, error)
+		// 标讯搜索限制内容
+		SearchLimit(ctx context.Context, in *SearchLimitReq, opts ...grpc.CallOption) (*SearchLimitResp, error)
 	}
 
 	defaultBxCore struct {
@@ -39,3 +43,9 @@ func (m *defaultBxCore) GetSearchList(ctx context.Context, in *SearchReq, opts .
 	client := bxcore.NewBxCoreClient(m.cli.Conn())
 	return client.GetSearchList(ctx, in, opts...)
 }
+
+// 标讯搜索限制内容
+func (m *defaultBxCore) SearchLimit(ctx context.Context, in *SearchLimitReq, opts ...grpc.CallOption) (*SearchLimitResp, error) {
+	client := bxcore.NewBxCoreClient(m.cli.Conn())
+	return client.SearchLimit(ctx, in, opts...)
+}

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

@@ -12,11 +12,10 @@ LabelUrl:
   Industry: /list/industry/%s.html
 PCSTime: 24
 LimitSearchText:
-  Flag: false
+  Flag: true
   Count: 3
-  Timeout: 60
-  TotalPage: 10
+  TimeOut: 60
   Percentage: 80
   UserIds:
-    - 123456
-  Msg: f 开关状态:%s //-2 从配置文件重置,-1 关闭,1 打开<br><br>c 并发数:%d //-2 不限制并发数,-1 无条件直接限制,>0 限制并发数<br><br>t 个人查询限制时间:%ds //-1 不限制<br><br>p 限制页数:%d
+    - 60f4f01156bf6da1bcbbcff6
+  Msg: f 开关状态:%s //-2 从配置文件重置,-1 关闭,1 打开<br><br>c 并发数:%d //-2 不限制并发数,-1 无条件直接限制,>0 限制并发数<br><br>t 个人查询限制时间:%ds //-1 不限制<br><br>

+ 1 - 1
jyBXCore/rpc/etc/logs.yaml

@@ -3,4 +3,4 @@ Path: ./logs
 Level:
   - info
   - error
-KeepDays: 10
+KeepDays: 1

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

@@ -14,7 +14,15 @@ type Config struct {
 		Stype    string
 		Industry string
 	}
-	PCSTime int //清除搜索列表内存缓存 间隔时间
+	PCSTime         int //清除搜索列表内存缓存 间隔时间
+	LimitSearchText struct {
+		Flag       bool
+		Count      int
+		TimeOut    int
+		Percentage int
+		UserIds    []string
+		Msg        string
+	}
 }
 
 type Db struct {

+ 7 - 6
jyBXCore/rpc/internal/logic/getsearchlistlogic.go

@@ -70,7 +70,7 @@ func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.Search
 		in.City = ""
 	}
 	in.KeyWords = strings.TrimSpace(in.KeyWords)
-	searchLimit := true
+	searchLimit := util.IsSearchLimit(strings.Split(in.SelectType, ","))
 	in.SelectType = strings.Join(queryItems, ",")
 	//b_word, s_word := "", ""
 	res.IsLimit = 1
@@ -82,11 +82,10 @@ func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.Search
 		//查询数据
 		//全文检索限制
 		if searchLimit {
-			//limitFlag = public.Lst.Flag
-			//isLimit = public.Lst.IsLimited(m.Request, m.ResponseWriter, m.Session(), isPayedUser)
-			//if isLimit == 1 { //没有被限制
-			//	defer public.Lst.Limit()
-			//}
+			res.IsLimit = util.IsLimited(in.UserId, in.UserType != "fType")
+			if res.IsLimit == 1 { //没有被限制
+				defer util.Limit()
+			}
 		}
 		//无限制
 		if res.IsLimit == 1 {
@@ -113,6 +112,8 @@ func (l *GetSearchListLogic) GetSearchList(in *bxcore.SearchReq) (*bxcore.Search
 			if count > limitCount {
 				count = limitCount
 			}
+			//是否收藏
+			util.MakeCollection(in.UserId, list)
 			res.TotalPage = MC.If(in.PageNum == 1, (count+int64(util.SearchPageSize)-1)/int64(util.SearchPageSize), res.TotalPage).(int64)
 			res.Count = count
 			res.List = list

+ 72 - 0
jyBXCore/rpc/internal/logic/searchlimitlogic.go

@@ -0,0 +1,72 @@
+package logic
+
+import (
+	MC "app.yhyue.com/moapp/jybase/common"
+	"context"
+	"fmt"
+	IC "jyBXCore/rpc/init"
+	"jyBXCore/rpc/util"
+
+	"jyBXCore/rpc/internal/svc"
+	"jyBXCore/rpc/type/bxcore"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type SearchLimitLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewSearchLimitLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SearchLimitLogic {
+	return &SearchLimitLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 标讯搜索限制内容
+func (l *SearchLimitLogic) SearchLimit(in *bxcore.SearchLimitReq) (*bxcore.SearchLimitResp, error) {
+	if in.UserId == "" || !util.IsCanLogin(in.UserId) {
+		return &bxcore.SearchLimitResp{
+			Data: fmt.Sprintf("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">需要登录!"),
+		}, nil
+	}
+	status := MC.If(IC.C.LimitSearchText.Flag, "打开", "关闭").(string)
+	if in.SearchType == "update" {
+		if in.TimeOut > 0 || in.TimeOut == -1 {
+			IC.C.LimitSearchText.TimeOut = int(in.TimeOut)
+		}
+		if (in.Count > 0 || in.Count == -1 || in.Count == -2) && int(in.Count) != IC.C.LimitSearchText.Count && IC.C.LimitSearchText.Flag {
+			IC.C.LimitSearchText.Count = int(in.Count)
+			util.LimitSearchInit()
+		}
+		if in.Flag == -2 { //重置
+			status = "重置"
+			util.LimitSearchInit()
+		} else if in.Flag == -1 && IC.C.LimitSearchText.Flag { //关闭
+			status = "关闭"
+			IC.C.LimitSearchText.Flag = false
+			util.LimitSearchClear()
+		} else if in.Flag == 1 && !IC.C.LimitSearchText.Flag { //打开
+			status = "打开"
+			IC.C.LimitSearchText.Flag = true
+			util.LimitSearchInit()
+		} else {
+			if IC.C.LimitSearchText.Flag {
+				status = "打开"
+			} else {
+				status = "关闭"
+			}
+		}
+		//vip 大会员等用户 单独通道占比
+		if in.Percentage > 0 && IC.C.LimitSearchText.Flag {
+			IC.C.LimitSearchText.Percentage = int(in.Percentage)
+		}
+	}
+	return &bxcore.SearchLimitResp{
+		Data: fmt.Sprint("<meta name=\"viewport\" content=\"width=device-width, initial-scale=1, user-scalable=no\">" + fmt.Sprintf(IC.C.LimitSearchText.Msg, status, IC.C.LimitSearchText.Count, IC.C.LimitSearchText.TimeOut)),
+	}, nil
+}

+ 6 - 0
jyBXCore/rpc/internal/server/bxcoreserver.go

@@ -27,3 +27,9 @@ func (s *BxCoreServer) GetSearchList(ctx context.Context, in *bxcore.SearchReq)
 	l := logic.NewGetSearchListLogic(ctx, s.svcCtx)
 	return l.GetSearchList(in)
 }
+
+// 标讯搜索限制内容
+func (s *BxCoreServer) SearchLimit(ctx context.Context, in *bxcore.SearchLimitReq) (*bxcore.SearchLimitResp, error) {
+	l := logic.NewSearchLimitLogic(ctx, s.svcCtx)
+	return l.SearchLimit(in)
+}

+ 225 - 15
jyBXCore/rpc/type/bxcore/bxcore.pb.go

@@ -541,6 +541,166 @@ func (x *SearchList) GetIsCollected() bool {
 	return false
 }
 
+//
+type SearchLimitReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Appid      string `protobuf:"bytes,1,opt,name=appid,proto3" json:"appid,omitempty"`
+	TimeOut    int64  `protobuf:"varint,2,opt,name=timeOut,proto3" json:"timeOut,omitempty"`
+	Count      int64  `protobuf:"varint,3,opt,name=count,proto3" json:"count,omitempty"`
+	Flag       int64  `protobuf:"varint,4,opt,name=flag,proto3" json:"flag,omitempty"`
+	Percentage int64  `protobuf:"varint,5,opt,name=percentage,proto3" json:"percentage,omitempty"`
+	UserId     string `protobuf:"bytes,6,opt,name=userId,proto3" json:"userId,omitempty"`
+	SearchType string `protobuf:"bytes,7,opt,name=searchType,proto3" json:"searchType,omitempty"`
+}
+
+func (x *SearchLimitReq) Reset() {
+	*x = SearchLimitReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_bxcore_proto_msgTypes[4]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *SearchLimitReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*SearchLimitReq) ProtoMessage() {}
+
+func (x *SearchLimitReq) ProtoReflect() protoreflect.Message {
+	mi := &file_bxcore_proto_msgTypes[4]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use SearchLimitReq.ProtoReflect.Descriptor instead.
+func (*SearchLimitReq) Descriptor() ([]byte, []int) {
+	return file_bxcore_proto_rawDescGZIP(), []int{4}
+}
+
+func (x *SearchLimitReq) GetAppid() string {
+	if x != nil {
+		return x.Appid
+	}
+	return ""
+}
+
+func (x *SearchLimitReq) GetTimeOut() int64 {
+	if x != nil {
+		return x.TimeOut
+	}
+	return 0
+}
+
+func (x *SearchLimitReq) GetCount() int64 {
+	if x != nil {
+		return x.Count
+	}
+	return 0
+}
+
+func (x *SearchLimitReq) GetFlag() int64 {
+	if x != nil {
+		return x.Flag
+	}
+	return 0
+}
+
+func (x *SearchLimitReq) GetPercentage() int64 {
+	if x != nil {
+		return x.Percentage
+	}
+	return 0
+}
+
+func (x *SearchLimitReq) GetUserId() string {
+	if x != nil {
+		return x.UserId
+	}
+	return ""
+}
+
+func (x *SearchLimitReq) GetSearchType() string {
+	if x != nil {
+		return x.SearchType
+	}
+	return ""
+}
+
+//
+type SearchLimitResp struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	ErrCode int64  `protobuf:"varint,1,opt,name=err_code,json=errCode,proto3" json:"err_code,omitempty"`
+	ErrMsg  string `protobuf:"bytes,2,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"`
+	Data    string `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"`
+}
+
+func (x *SearchLimitResp) Reset() {
+	*x = SearchLimitResp{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_bxcore_proto_msgTypes[5]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *SearchLimitResp) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*SearchLimitResp) ProtoMessage() {}
+
+func (x *SearchLimitResp) ProtoReflect() protoreflect.Message {
+	mi := &file_bxcore_proto_msgTypes[5]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use SearchLimitResp.ProtoReflect.Descriptor instead.
+func (*SearchLimitResp) Descriptor() ([]byte, []int) {
+	return file_bxcore_proto_rawDescGZIP(), []int{5}
+}
+
+func (x *SearchLimitResp) GetErrCode() int64 {
+	if x != nil {
+		return x.ErrCode
+	}
+	return 0
+}
+
+func (x *SearchLimitResp) GetErrMsg() string {
+	if x != nil {
+		return x.ErrMsg
+	}
+	return ""
+}
+
+func (x *SearchLimitResp) GetData() string {
+	if x != nil {
+		return x.Data
+	}
+	return ""
+}
+
 var File_bxcore_proto protoreflect.FileDescriptor
 
 var file_bxcore_proto_rawDesc = []byte{
@@ -629,12 +789,34 @@ var file_bxcore_proto_rawDesc = []byte{
 	0x74, 0x6c, 0x65, 0x18, 0x0d, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, 0x65,
 	0x12, 0x20, 0x0a, 0x0b, 0x69, 0x73, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18,
 	0x0e, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73, 0x43, 0x6f, 0x6c, 0x6c, 0x65, 0x63, 0x74,
-	0x65, 0x64, 0x32, 0x40, 0x0a, 0x06, 0x42, 0x78, 0x43, 0x6f, 0x72, 0x65, 0x12, 0x36, 0x0a, 0x0d,
-	0x47, 0x65, 0x74, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x11, 0x2e,
-	0x62, 0x78, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71,
-	0x1a, 0x12, 0x2e, 0x62, 0x78, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68,
-	0x52, 0x65, 0x73, 0x70, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x62, 0x78, 0x63, 0x6f, 0x72, 0x65,
-	0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x65, 0x64, 0x22, 0xc2, 0x01, 0x0a, 0x0e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x4c, 0x69, 0x6d,
+	0x69, 0x74, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x18, 0x01,
+	0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x61, 0x70, 0x70, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x74,
+	0x69, 0x6d, 0x65, 0x4f, 0x75, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x74, 0x69,
+	0x6d, 0x65, 0x4f, 0x75, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x03,
+	0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x66,
+	0x6c, 0x61, 0x67, 0x18, 0x04, 0x20, 0x01, 0x28, 0x03, 0x52, 0x04, 0x66, 0x6c, 0x61, 0x67, 0x12,
+	0x1e, 0x0a, 0x0a, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x18, 0x05, 0x20,
+	0x01, 0x28, 0x03, 0x52, 0x0a, 0x70, 0x65, 0x72, 0x63, 0x65, 0x6e, 0x74, 0x61, 0x67, 0x65, 0x12,
+	0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52,
+	0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x65, 0x61, 0x72, 0x63,
+	0x68, 0x54, 0x79, 0x70, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x73, 0x65, 0x61,
+	0x72, 0x63, 0x68, 0x54, 0x79, 0x70, 0x65, 0x22, 0x59, 0x0a, 0x0f, 0x53, 0x65, 0x61, 0x72, 0x63,
+	0x68, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x19, 0x0a, 0x08, 0x65, 0x72,
+	0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x65, 0x72,
+	0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x65, 0x72, 0x72, 0x5f, 0x6d, 0x73, 0x67,
+	0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x72, 0x72, 0x4d, 0x73, 0x67, 0x12, 0x12,
+	0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x64, 0x61,
+	0x74, 0x61, 0x32, 0x80, 0x01, 0x0a, 0x06, 0x42, 0x78, 0x43, 0x6f, 0x72, 0x65, 0x12, 0x36, 0x0a,
+	0x0d, 0x47, 0x65, 0x74, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x11,
+	0x2e, 0x62, 0x78, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65,
+	0x71, 0x1a, 0x12, 0x2e, 0x62, 0x78, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63,
+	0x68, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3e, 0x0a, 0x0b, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x4c,
+	0x69, 0x6d, 0x69, 0x74, 0x12, 0x16, 0x2e, 0x62, 0x78, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x65,
+	0x61, 0x72, 0x63, 0x68, 0x4c, 0x69, 0x6d, 0x69, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x17, 0x2e, 0x62,
+	0x78, 0x63, 0x6f, 0x72, 0x65, 0x2e, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x4c, 0x69, 0x6d, 0x69,
+	0x74, 0x52, 0x65, 0x73, 0x70, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x62, 0x78, 0x63, 0x6f, 0x72,
+	0x65, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
 }
 
 var (
@@ -649,20 +831,24 @@ func file_bxcore_proto_rawDescGZIP() []byte {
 	return file_bxcore_proto_rawDescData
 }
 
-var file_bxcore_proto_msgTypes = make([]protoimpl.MessageInfo, 4)
+var file_bxcore_proto_msgTypes = make([]protoimpl.MessageInfo, 6)
 var file_bxcore_proto_goTypes = []interface{}{
-	(*SearchReq)(nil),  // 0: bxcore.SearchReq
-	(*SearchResp)(nil), // 1: bxcore.SearchResp
-	(*SearchData)(nil), // 2: bxcore.SearchData
-	(*SearchList)(nil), // 3: bxcore.SearchList
+	(*SearchReq)(nil),       // 0: bxcore.SearchReq
+	(*SearchResp)(nil),      // 1: bxcore.SearchResp
+	(*SearchData)(nil),      // 2: bxcore.SearchData
+	(*SearchList)(nil),      // 3: bxcore.SearchList
+	(*SearchLimitReq)(nil),  // 4: bxcore.SearchLimitReq
+	(*SearchLimitResp)(nil), // 5: bxcore.SearchLimitResp
 }
 var file_bxcore_proto_depIdxs = []int32{
 	2, // 0: bxcore.SearchResp.data:type_name -> bxcore.SearchData
 	3, // 1: bxcore.SearchData.list:type_name -> bxcore.SearchList
 	0, // 2: bxcore.BxCore.GetSearchList:input_type -> bxcore.SearchReq
-	1, // 3: bxcore.BxCore.GetSearchList:output_type -> bxcore.SearchResp
-	3, // [3:4] is the sub-list for method output_type
-	2, // [2:3] is the sub-list for method input_type
+	4, // 3: bxcore.BxCore.SearchLimit:input_type -> bxcore.SearchLimitReq
+	1, // 4: bxcore.BxCore.GetSearchList:output_type -> bxcore.SearchResp
+	5, // 5: bxcore.BxCore.SearchLimit:output_type -> bxcore.SearchLimitResp
+	4, // [4:6] is the sub-list for method output_type
+	2, // [2:4] is the sub-list for method input_type
 	2, // [2:2] is the sub-list for extension type_name
 	2, // [2:2] is the sub-list for extension extendee
 	0, // [0:2] is the sub-list for field type_name
@@ -722,6 +908,30 @@ func file_bxcore_proto_init() {
 				return nil
 			}
 		}
+		file_bxcore_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*SearchLimitReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_bxcore_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*SearchLimitResp); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
 	}
 	type x struct{}
 	out := protoimpl.TypeBuilder{
@@ -729,7 +939,7 @@ func file_bxcore_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_bxcore_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   4,
+			NumMessages:   6,
 			NumExtensions: 0,
 			NumServices:   1,
 		},

+ 38 - 0
jyBXCore/rpc/type/bxcore/bxcore_grpc.pb.go

@@ -24,6 +24,8 @@ const _ = grpc.SupportPackageIsVersion7
 type BxCoreClient interface {
 	//标讯搜索结果列表数据
 	GetSearchList(ctx context.Context, in *SearchReq, opts ...grpc.CallOption) (*SearchResp, error)
+	//标讯搜索限制内容
+	SearchLimit(ctx context.Context, in *SearchLimitReq, opts ...grpc.CallOption) (*SearchLimitResp, error)
 }
 
 type bxCoreClient struct {
@@ -43,12 +45,23 @@ func (c *bxCoreClient) GetSearchList(ctx context.Context, in *SearchReq, opts ..
 	return out, nil
 }
 
+func (c *bxCoreClient) SearchLimit(ctx context.Context, in *SearchLimitReq, opts ...grpc.CallOption) (*SearchLimitResp, error) {
+	out := new(SearchLimitResp)
+	err := c.cc.Invoke(ctx, "/bxcore.BxCore/SearchLimit", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // BxCoreServer is the server API for BxCore service.
 // All implementations must embed UnimplementedBxCoreServer
 // for forward compatibility
 type BxCoreServer interface {
 	//标讯搜索结果列表数据
 	GetSearchList(context.Context, *SearchReq) (*SearchResp, error)
+	//标讯搜索限制内容
+	SearchLimit(context.Context, *SearchLimitReq) (*SearchLimitResp, error)
 	mustEmbedUnimplementedBxCoreServer()
 }
 
@@ -59,6 +72,9 @@ type UnimplementedBxCoreServer struct {
 func (UnimplementedBxCoreServer) GetSearchList(context.Context, *SearchReq) (*SearchResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method GetSearchList not implemented")
 }
+func (UnimplementedBxCoreServer) SearchLimit(context.Context, *SearchLimitReq) (*SearchLimitResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method SearchLimit not implemented")
+}
 func (UnimplementedBxCoreServer) mustEmbedUnimplementedBxCoreServer() {}
 
 // UnsafeBxCoreServer may be embedded to opt out of forward compatibility for this service.
@@ -90,6 +106,24 @@ func _BxCore_GetSearchList_Handler(srv interface{}, ctx context.Context, dec fun
 	return interceptor(ctx, in, info, handler)
 }
 
+func _BxCore_SearchLimit_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(SearchLimitReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(BxCoreServer).SearchLimit(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/bxcore.BxCore/SearchLimit",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(BxCoreServer).SearchLimit(ctx, req.(*SearchLimitReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // BxCore_ServiceDesc is the grpc.ServiceDesc for BxCore service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -101,6 +135,10 @@ var BxCore_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "GetSearchList",
 			Handler:    _BxCore_GetSearchList_Handler,
 		},
+		{
+			MethodName: "SearchLimit",
+			Handler:    _BxCore_SearchLimit_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "bxcore.proto",

+ 94 - 0
jyBXCore/rpc/util/limitSearchText.go

@@ -0,0 +1,94 @@
+package util
+
+import (
+	MC "app.yhyue.com/moapp/jybase/common"
+	"app.yhyue.com/moapp/jybase/redis"
+	"fmt"
+	IC "jyBXCore/rpc/init"
+)
+
+var SearchLimitKey = "jy_limitSearchText_new"
+var SearchLimitFlag = "jy_limitSearchText_%s"
+
+//
+func IsSearchLimit(searchItems []string) bool {
+	for _, searchItem := range searchItems {
+		if searchItem == "detail" || searchItem == "filetext" {
+			return true
+		}
+	}
+	return false
+}
+
+//
+func LimitSearchInit() {
+	if IC.C.LimitSearchText.Flag {
+		LimitSearchClear()
+		for i := 0; i < IC.C.LimitSearchText.Count; i++ {
+			redis.RPUSH("other", SearchLimitKey, 1)
+		}
+	}
+}
+
+//
+func LimitSearchClear() {
+	redis.Del("other", SearchLimitKey)
+}
+
+//限制正文、附件查询
+//return 1 正常
+//return -1 抱歉!由于系统繁忙暂时无法进行搜索,请1分钟后再试!
+//return -2 抱歉!由于系统繁忙暂时无法进行搜索,请稍后再试!
+func IsLimited(userId string, isPayedUser bool) int64 {
+	if !IC.C.LimitSearchText.Flag {
+		return 1
+	}
+	var llen = int(redis.LLEN("other", SearchLimitKey))
+	if IC.C.LimitSearchText.TimeOut > 0 {
+		if llen <= IC.C.LimitSearchText.Count/2 {
+			timeLimit, _ := redis.Exists("other", fmt.Sprintf(SearchLimitFlag, userId))
+			if timeLimit {
+				return -1
+			}
+		}
+		redis.Put("other", fmt.Sprintf(SearchLimitFlag, userId), 1, IC.C.LimitSearchText.TimeOut)
+	}
+
+	if IC.C.LimitSearchText.Count == -2 { //不限制
+		return 1
+	} else if IC.C.LimitSearchText.Count == -1 { //无条件限制
+		return -2
+	}
+	//免费和付费用户 使用并发的80%(默认)通道|| 保留一条通道给付费用户使用
+	if !isPayedUser {
+		if llen <= IC.C.LimitSearchText.Count*IC.C.LimitSearchText.Percentage/100 || llen == 1 {
+			return -1
+		}
+	}
+	//
+	pollLimit := redis.LPOP("other", SearchLimitKey)
+	if MC.IntAll(pollLimit) <= 0 {
+		return -2
+	}
+	return 1
+}
+
+//
+func Limit() {
+	if !IC.C.LimitSearchText.Flag {
+		return
+	}
+	if int(redis.LLEN("other", SearchLimitKey)) < IC.C.LimitSearchText.Count {
+		redis.RPUSH("other", SearchLimitKey, 1)
+	}
+}
+
+//
+func IsCanLogin(userId string) bool {
+	for _, v := range IC.C.LimitSearchText.UserIds {
+		if v == userId {
+			return true
+		}
+	}
+	return false
+}

+ 2 - 2
jyBXCore/rpc/util/search.go

@@ -175,10 +175,10 @@ func GetBidSearchData(in *bxcore.SearchReq) (count int64, list []*bxcore.SearchL
 	qstr := GetSearchQuery(in, GetBidSearchQuery(in))
 	var start = int((in.PageNum - 1) * in.PageSize)
 	//首页
-	if qstr != "" && start == 1 {
+	if qstr != "" && start == 0 {
 		count = elastic.Count(INDEX, TYPE, qstr)
 	}
-	if count > 0 || start > 0 {
+	if count > 0 || start > 1 {
 		field := bidSearch_field_1
 		if start == 1 {
 			field = bidSearch_field

+ 1 - 1
jyBXSubscribe/api/etc/logs.yaml

@@ -3,4 +3,4 @@ Path: ./logs
 Level:
   - info
   - error
-KeepDays: 10
+KeepDays: 1

+ 1 - 1
jyBXSubscribe/rpc/etc/logs.yaml

@@ -3,4 +3,4 @@ Path: ./logs
 Level:
   - info
   - error
-KeepDays: 10
+KeepDays: 1