Răsfoiți Sursa

主程序搜索敏感词修改

duxin 2 ani în urmă
părinte
comite
d380a6c820
3 a modificat fișierele cu 58 adăugiri și 28 ștergeri
  1. 34 3
      src/jfw/front/shorturl.go
  2. 22 20
      src/jfw/front/supsearch.go
  3. 2 5
      src/jfw/front/swordfish.go

+ 34 - 3
src/jfw/front/shorturl.go

@@ -893,11 +893,11 @@ func ReplaceStringByRegex(str, rule, replace string) (string, error) {
 }
 
 // 未登录用户进行数据过滤 name 配置文件
-func Filter(obj map[string]interface{}, name string) map[string]interface{} {
+func Filter(obj map[string]interface{}) map[string]interface{} {
 	detail := fmt.Sprint(obj["detail"])
 	mosaicText := util.ObjToString(config.Sysconfig["detailMosaicTxt"])
 	for k, _ := range obj {
-		needMosaic, _ := config.Sysconfig[name].(map[string]interface{})
+		needMosaic, _ := config.Sysconfig["needMosaic"].(map[string]interface{})
 		if ok, _ := needMosaic[k].(bool); ok {
 			if util.ObjToString(obj[k]) != "" {
 				detail = strings.ReplaceAll(detail, util.ObjToString(obj[k]), mosaicText)
@@ -923,6 +923,37 @@ func Filter(obj map[string]interface{}, name string) map[string]interface{} {
 	return obj
 }
 
+// 未登录用户进行数据过滤 name 配置文件
+func SearchFilter(obj map[string]interface{}) map[string]interface{} {
+	//detail := fmt.Sprint(obj["detail"])
+	mosaicText := util.ObjToString(config.Sysconfig["detailMosaicTxt"])
+	for k, _ := range obj {
+		needMosaic, _ := config.Sysconfig["searchMosaic"].(map[string]interface{})
+		if ok, _ := needMosaic[k].(bool); ok {
+			//if util.ObjToString(obj[k]) != "" {
+			//	detail = strings.ReplaceAll(detail, util.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 (s *Short) NologinArticle(stype, id string) error {
 	userId := util.ObjToString(s.GetSession("userId"))
 	sids := util.CommonDecodeArticle(stype, id)
@@ -968,7 +999,7 @@ func (s *Short) NologinArticle(stype, id string) error {
 				obj["projectnameTitle"] = obj["projectname"]
 				obj["projectcodeTitle"] = obj["projectcode"]
 				log.Println(time.Now().UnixNano())
-				obj = Filter(obj, "needMosaic")
+				obj = Filter(obj)
 				log.Println(time.Now().UnixNano())
 			}
 			s.T["obj"] = obj

+ 22 - 20
src/jfw/front/supsearch.go

@@ -1,24 +1,24 @@
 package front
 
 import (
-	"fmt"
-	"jfw/config"
-	"jfw/jylabutil"
-	"jfw/public"
-	"log"
-	"math/rand"
-	"qfw/util"
-	"qfw/util/bidsearch"
-	"qfw/util/elastic"
-	"qfw/util/jy"
-	"qfw/util/redis"
-	"strconv"
-	"strings"
-	"sync"
-	"time"
+    "fmt"
+    "jfw/config"
+    "jfw/jylabutil"
+    "jfw/public"
+    "log"
+    "math/rand"
+    "qfw/util"
+    "qfw/util/bidsearch"
+    "qfw/util/elastic"
+    "qfw/util/jy"
+    "qfw/util/redis"
+    "strconv"
+    "strings"
+    "sync"
+    "time"
 
-	"github.com/SKatiyar/qr"
-	"github.com/go-xweb/xweb"
+    "github.com/SKatiyar/qr"
+    "github.com/go-xweb/xweb"
 )
 
 type Pcsearch struct {
@@ -279,9 +279,6 @@ func (p *Pcsearch) GetNewBids() error {
 	list, count, total = so.GetBidSearchListByCache()
 	if pageType == "" { //最新招标信息仅第一页条展示表格多字段
 		for k, v := range list {
-			if userId == "" {
-				*v = Filter(*v, "searchMosaic")
-			}
 			if pagenum == 1 && k < 20 {
 				continue
 			}
@@ -297,6 +294,11 @@ func (p *Pcsearch) GetNewBids() error {
 			delete((*v), "toptype")
 		}
 	}
+	if userId == "" {
+		for _, v := range list {
+			*v = SearchFilter(*v)
+		}
+	}
 	p.ServeJson(map[string]interface{}{
 		"list":      list,
 		"count":     count,

+ 2 - 5
src/jfw/front/swordfish.go

@@ -6,8 +6,6 @@ import (
 	"fmt"
 	"html/template"
 	"jfw/config"
-	"qfw/util/bidsearch"
-
 	"jfw/jyutil"
 	"jfw/public"
 	"jfw/wx"
@@ -16,6 +14,7 @@ import (
 	. "mongodb"
 	"net/url"
 	"qfw/util"
+	"qfw/util/bidsearch"
 	"qfw/util/elastic"
 	"qfw/util/redis"
 	"reflect"
@@ -175,9 +174,7 @@ func (m *Front) PcAjaxReq() {
 	}
 	if userId == "" {
 		for _, v := range list {
-			if userId == "" {
-				*v = Filter(*v, "searchMosaic")
-			}
+			*v = SearchFilter(*v)
 		}
 	}