|
@@ -1,18 +1,20 @@
|
|
|
package model
|
|
|
|
|
|
import (
|
|
|
- IC "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/init"
|
|
|
- ms "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/model/service"
|
|
|
- "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/type/bxsubscribe"
|
|
|
- "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/util"
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"log"
|
|
|
+ "regexp"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
"sync"
|
|
|
"time"
|
|
|
|
|
|
+ IC "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/init"
|
|
|
+ ms "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/model/service"
|
|
|
+ "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/type/bxsubscribe"
|
|
|
+ "bp.jydev.jianyu360.cn/BaseService/jyMicroservices/jyBXSubscribe/rpc/util"
|
|
|
+
|
|
|
"go.mongodb.org/mongo-driver/bson"
|
|
|
|
|
|
"github.com/gogf/gf/v2/util/gconv"
|
|
@@ -229,6 +231,8 @@ func (s *subscribePush) InfoFormat(p *PushCa, info *map[string]interface{}, isPa
|
|
|
_id = common.ObjToString((*info)["_id"])
|
|
|
}
|
|
|
isValidFile, _ := (*info)["isValidFile"].(bool)
|
|
|
+ detail := common.InterfaceToStr(common.If(isDetail, (*info)["detail"], ""))
|
|
|
+ detail = s.subStrDetail(strings.Join(p.Keys, " "), detail)
|
|
|
formatInfo := &bxsubscribe.SubscribeInfo{
|
|
|
XId: encrypt.EncodeArticleId2ByCheck(_id),
|
|
|
Title: common.InterfaceToStr((*info)["title"]),
|
|
@@ -258,7 +262,7 @@ func (s *subscribePush) InfoFormat(p *PushCa, info *map[string]interface{}, isPa
|
|
|
IsValidFile: isValidFile,
|
|
|
SourceAll: p.SourceAll,
|
|
|
FiletextSearch: common.If(p.MatchWays == "3", true, false).(bool),
|
|
|
- Detail: common.InterfaceToStr(common.If(isDetail, (*info)["detail"], "")),
|
|
|
+ Detail: detail,
|
|
|
District: common.InterfaceToStr((*info)["district"]),
|
|
|
}
|
|
|
// 免费用户返回精简列表字段
|
|
@@ -295,7 +299,27 @@ func (s *subscribePush) InfoFormat(p *PushCa, info *map[string]interface{}, isPa
|
|
|
return formatInfo
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+func (s *subscribePush) subStrDetail(matchKey, detail string) string {
|
|
|
+ matchKeys := []string{}
|
|
|
+ for _, v := range regexp.MustCompile(`\s|\+`).Split(matchKey, -1) {
|
|
|
+ if v == "" {
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ matchKeys = append(matchKeys, regexp.QuoteMeta(v))
|
|
|
+ }
|
|
|
+ indexs := regexp.MustCompile(strings.Join(matchKeys, "|")).FindStringIndex(detail)
|
|
|
+ if len(indexs) > 0 {
|
|
|
+ start := string(detail[0:indexs[0]])
|
|
|
+ if len([]rune(start)) > 50 {
|
|
|
+ start = string([]rune(start)[len([]rune(start))-50:])
|
|
|
+ }
|
|
|
+ detail = start + string(detail[indexs[0]:])
|
|
|
+ }
|
|
|
+ if len([]rune(detail)) > 200 {
|
|
|
+ detail = string([]rune(detail)[:200])
|
|
|
+ }
|
|
|
+ return detail
|
|
|
+}
|
|
|
func (s *subscribePush) Datas(spqp *SubPushQueryParam, bsp *ViewCondition) (hasNextPage bool, total int64, result []*bxsubscribe.SubscribeInfo) {
|
|
|
logx.Info(spqp.UserId, spqp.NewUserId, s.ModuleFlag, "subscribePush query param:", "SelectTime:", spqp.SelectTime, "Area:", spqp.Area, "District:", spqp.District, "City:", spqp.City, "Subtype:", spqp.Subtype, "Subscopeclass:", spqp.Subscopeclass, "Buyerclass:", spqp.Buyerclass, "Key:", spqp.Key, "PageNum:", spqp.PageNum, "Price:", spqp.Price, "FileExists:", spqp.FileExists)
|
|
|
if spqp.UserId == "" {
|