Browse Source

feat:修改

duxin 2 years ago
parent
commit
877c4ba00f

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

@@ -16,4 +16,12 @@ Core:
   Timeout: 12000
 AppId: 10000
 MgoLogsName: jybxcore_logs
-MgoLogsCount: 500
+MgoLogsCount: 500
+
+DetailMosaicTxt: 略
+SearchMosaic:
+  budget: true
+  bidamount: true
+  buyer: true
+  winner: true
+  bidopentime: true

+ 11 - 3
jyBXCore/api/internal/config/config.go

@@ -13,9 +13,17 @@ type Config struct {
 		ServerCode string
 		Etcd       []string
 	}
-	Core         zrpc.RpcClientConf
-	MgoLogsName  string
-	MgoLogsCount int
+	Core            zrpc.RpcClientConf
+	MgoLogsName     string
+	MgoLogsCount    int
+	DetailMosaicTxt string
+	SearchMosaic    struct {
+		Budget      bool `json:"budget"`
+		Bidamount   bool `json:"bidamount"`
+		Buyer       bool `json:"buyer"`
+		Winner      bool `json:"winner"`
+		Bidopentime bool `json:"bidopentime"`
+	}
 }
 
 type Db struct {

+ 28 - 0
jyBXCore/api/internal/logic/searchListLogic.go

@@ -1,8 +1,10 @@
 package logic
 
 import (
+	"app.yhyue.com/moapp/jybase/common"
 	"context"
 	"github.com/zeromicro/go-zero/core/logx"
+	IC "jyBXCore/api/init"
 	"jyBXCore/api/internal/svc"
 	"jyBXCore/api/internal/types"
 	"jyBXCore/api/internal/util"
@@ -66,6 +68,7 @@ func (l *SearchListLogic) SearchList(req *types.SearchReq) (resp *types.CommonRe
 		LimitFlag:       limitFlag,
 		IsNew:           isNew,
 	})
+
 	log.Println("请求接口耗时:", time.Since(t).Seconds())
 	if err != nil {
 		return &types.CommonResp{
@@ -74,6 +77,31 @@ func (l *SearchListLogic) SearchList(req *types.SearchReq) (resp *types.CommonRe
 			Data:     nil,
 		}, err
 	}
+	if req.UserId == "" {
+		var data []map[string]interface{}
+		detailMosaicTxt := IC.C.DetailMosaicTxt
+		sm := common.StructToMapMore(IC.C.SearchMosaic)
+		for _, v := range res.Data.List {
+			d := common.StructToMapMore(v)
+			for name, t1 := range sm {
+				ts, _ := t1.(bool)
+				if v1, ok := d[name]; ok && v1 != "" && v1 != 0 && ts {
+					d[name] = detailMosaicTxt
+				}
+			}
+
+			data = append(data, d)
+		}
+		dataAll := common.StructToMapMore(res.Data)
+		if v, ok := dataAll["data"]; ok && v != nil {
+			dataAll["data"].(map[string]interface{})["list"] = data
+		}
+		return &types.CommonResp{
+			Err_code: res.ErrCode,
+			Err_msg:  res.ErrMsg,
+			Data:     dataAll,
+		}, nil
+	}
 	return &types.CommonResp{
 		Err_code: res.ErrCode,
 		Err_msg:  res.ErrMsg,

+ 1 - 46
jyBXCore/rpc/etc/bxcore.yaml

@@ -42,49 +42,4 @@ DefaultTopTypes:
   - 拟建,采购意向
 JYKeyMark: " "
 ContextOldVipLimit: 1664553600
-DetailMosaicTxt: 略
-NeedMosaic:
-  projectname: true
-  projectcode: true
-  budget: true
-  bidamount: true
-  buyer: true
-  buyerperson: true
-  buyertel: true
-  buyeraddr: true
-  agency: true
-  agencyperson: true
-  agencytel: true
-  agencyaddr: true
-  winner: true
-  s_winner: true
-  winnerperson: true
-  winnertel: true
-  winneraddr: true
-  docstarttime: true
-  docendtime: true
-  bidendtime: true
-  bidstarttime: true
-  bidopentime: true
-  bidopenaddress: true
-  contractcode: true
-  signaturedate: true
-  purchasinglist: true
-  item: true
-  purchasing: true
-  itemname: true
-  brandname: true
-  specs: true
-  model: true
-  unitname: true
-  dimensions: true
-  number: true
-  unitprice: true
-  totalprice: true
-  guaranteetime: true
-  orderno: true
-  procurementlist: true
-  projectscope: true
-  reserved_amount: true
-  expurasingtime: true
-  winnerMap: true
+

+ 0 - 48
jyBXCore/rpc/internal/config/config.go

@@ -44,54 +44,6 @@ type Config struct {
 	DefaultTopTypes    []string //信息类型初始值
 	JYKeyMark          string   //关键词分组标识
 	ContextOldVipLimit int64    //老版超级订阅 超前项目权限
-
-	DetailMosaicTxt string
-	NeedMosaic      struct {
-		Projectname     bool `json:"projectname"`
-		Projectcode     bool `json:"projectcode"`
-		Budget          bool `json:"budget"`
-		Bidamount       bool `json:"bidamount"`
-		Buyer           bool `json:"buyer"`
-		Buyerperson     bool `json:"buyerperson"`
-		Buyertel        bool `json:"buyertel"`
-		Buyeraddr       bool `json:"buyeraddr"`
-		Agency          bool `json:"agency"`
-		Agencyperson    bool `json:"agencyperson"`
-		Agencytel       bool `json:"agencytel"`
-		Agencyaddr      bool `json:"agencyaddr"`
-		Winner          bool `json:"winner"`
-		SWinner         bool `json:"s_winner"`
-		Winnerperson    bool `json:"winnerperson"`
-		Winnertel       bool `json:"winnertel"`
-		Winneraddr      bool `json:"winneraddr"`
-		Docstarttime    bool `json:"docstarttime"`
-		Docendtime      bool `json:"docendtime"`
-		Bidendtime      bool `json:"bidendtime"`
-		Bidstarttime    bool `json:"bidstarttime"`
-		Bidopentime     bool `json:"bidopentime"`
-		Bidopenaddress  bool `json:"bidopenaddress"`
-		Contractcode    bool `json:"contractcode"`
-		Signaturedate   bool `json:"signaturedate"`
-		Purchasinglist  bool `json:"purchasinglist"`
-		Item            bool `json:"item"`
-		Purchasing      bool `json:"purchasing"`
-		Itemname        bool `json:"itemname"`
-		Brandname       bool `json:"brandname"`
-		Specs           bool `json:"specs"`
-		Model           bool `json:"model"`
-		Unitname        bool `json:"unitname"`
-		Dimensions      bool `json:"dimensions"`
-		Number          bool `json:"number"`
-		Unitprice       bool `json:"unitprice"`
-		Totalprice      bool `json:"totalprice"`
-		Guaranteetime   bool `json:"guaranteetime"`
-		Orderno         bool `json:"orderno"`
-		Procurementlist bool `json:"procurementlist"`
-		Projectscope    bool `json:"projectscope"`
-		ReservedAmount  bool `json:"reserved_amount"`
-		Expurasingtime  bool `json:"expurasingtime"`
-		WinnerMap       bool `json:"winnerMap"`
-	}
 }
 
 type Db struct {

+ 0 - 91
jyBXCore/rpc/util/search.go

@@ -3,10 +3,8 @@ package util
 import (
 	MC "app.yhyue.com/moapp/jybase/common"
 	ME "app.yhyue.com/moapp/jybase/encrypt"
-	"app.yhyue.com/moapp/jybase/fsw"
 	"crypto/rand"
 	"encoding/json"
-	"errors"
 	"fmt"
 	"github.com/zeromicro/go-zero/core/logx"
 	"io/ioutil"
@@ -16,7 +14,6 @@ import (
 	"math/big"
 	"net/http"
 	"net/url"
-	"reflect"
 	"regexp"
 	"strconv"
 	"strings"
@@ -257,9 +254,6 @@ func SearchListFormat(userid, industry string, repl *[]map[string]interface{}, b
 			}
 			searchList.Detail = detail
 		}
-		if userid == "" {
-			v = Filter(v)
-		}
 		searchList.Id = ME.EncodeArticleId2ByCheck(MC.ObjToString(v["_id"]))                                    //ME.EncodeArticleId2ByCheck(MC.ObjToString(v["_id"]))                                         //加密信息id
 		searchList.Area = MC.ObjToString(v["area"])                                                             //地区
 		searchList.AreaUrl = IC.LabelMap[searchList.Area].Url                                                   //地区分类链接
@@ -365,88 +359,3 @@ func GetPublishTime(y, m int, publishTime string) string {
 	}
 	return ""
 }
-
-// 未登录用户进行数据过滤
-func Filter(obj map[string]interface{}) map[string]interface{} {
-	detail := fmt.Sprint(obj["detail"])
-	mosaicText := IC.C.DetailMosaicTxt
-	for k, _ := range obj {
-		needMosaic := MC.StructToMapMore(IC.C.NeedMosaic)
-		if ok, _ := needMosaic[k].(bool); ok {
-			if MC.ObjToString(obj[k]) != "" {
-				detail = strings.ReplaceAll(detail, MC.ObjToString(obj[k]), mosaicText)
-				//敏感词过滤
-			}
-			if k == "winnerMap" {
-				winnerMap, _ := obj[k].(map[string]interface{})
-				mosaicMap := map[string]interface{}{}
-				for i := 0; i < len(winnerMap); i++ {
-					mosaicMap[mosaicText] = mosaicText
-				}
-				obj["winnerMap"] = mosaicMap
-			} else {
-				obj[k] = mosaicText
-			}
-		}
-	}
-	//数字打码
-	detail = RegDetail(detail)
-	detail = fsw.Repl(detail)
-	obj["detail"] = detail
-	return obj
-}
-
-// 分段匹配数字打码
-func RegDetail(html string) string {
-	mosaicText := IC.C.DetailMosaicTxt
-	reg := regexp.MustCompile("<[^<>]{1,1000}>") //分段正则
-	s := reg.FindAllStringIndex(html, -1)        //全文匹配分段
-	if len(s) > 0 {                              //走分段替换
-		arr := []string{}
-		index := 0
-		for _, v := range s {
-			if len(v) == 2 {
-				// log.Println(html[index:v[0]])
-				txt, _ := ReplaceStringByRegex(html[index:v[0]], "[0-9]+", mosaicText)
-				arr = append(arr, txt) //替换
-				arr = append(arr, html[v[0]:v[1]])
-				index = v[1]
-			}
-		}
-		return strings.Join(arr, "")
-	}
-	return ""
-}
-
-func ReplaceStringByRegex(str, rule, replace string) (string, error) {
-	reg, err := regexp.Compile(rule)
-	if reg == nil || err != nil {
-		return "", errors.New("正则MustCompile错误:" + err.Error())
-	}
-	return reg.ReplaceAllString(str, replace), nil
-}
-
-func Bind(data interface{}, ret interface{}) error {
-	v := reflect.ValueOf(ret)
-	if v.Kind() != reflect.Ptr {
-		return fmt.Errorf("ptr input ret needed as type as input type %s", v.Kind())
-	}
-	havdata := false
-	var bk interface{}
-	if v.Elem().Kind() == reflect.Slice {
-		t := reflect.Zero(reflect.TypeOf(v.Elem().Interface()))
-		bk = v.Elem().Interface()
-		v.Elem().Set(t)
-		havdata = true
-	}
-	_data, _ := json.MarshalIndent(data, "", "    ")
-	err := json.Unmarshal(_data, ret)
-	if err != nil {
-		fmt.Println(err)
-		if havdata {
-			v.Elem().Set(reflect.ValueOf(bk))
-		}
-		return err
-	}
-	return nil
-}