Browse Source

unicode字符

wangshan 1 tháng trước cách đây
mục cha
commit
189f3ad8e0

+ 7 - 7
jyBXCore/api/internal/logic/searchListLogic.go

@@ -70,9 +70,9 @@ func (l *SearchListLogic) SearchList(req *types.SearchReq) (resp *types.CommonRe
 		SearchGroup:     req.SearchGroup,
 		SearchMode:      req.SearchMode,
 		WordsMode:       req.WordsMode,
-		KeyWords:        req.KeyWords,
-		AdditionalWords: req.AdditionalWords,
-		ExclusionWords:  req.ExclusionWords,
+		KeyWords:        util.RemoveInvisibleChars(req.KeyWords),
+		AdditionalWords: util.RemoveInvisibleChars(req.AdditionalWords),
+		ExclusionWords:  util.RemoveInvisibleChars(req.ExclusionWords),
 		UserType:        req.UserType,
 		Platform:        util.CheckPlatform(l.r),
 		BidField:        req.BidField,
@@ -84,9 +84,9 @@ func (l *SearchListLogic) SearchList(req *types.SearchReq) (resp *types.CommonRe
 		LimitFlag:       limitFlag,
 		IsNew:           isNew,
 		District:        req.District,
-		Buyer:           req.Buyer,
-		Winner:          req.Winner,
-		Agency:          req.Agency,
+		Buyer:           util.RemoveInvisibleChars(req.Buyer),
+		Winner:          util.RemoveInvisibleChars(req.Winner),
+		Agency:          util.RemoveInvisibleChars(req.Agency),
 		PropertyForm:    req.PropertyForm,
 		ExpireTime:      req.ExpireTime,
 		SubInformation:  req.SubInformation,
@@ -162,7 +162,7 @@ func (l *SearchListLogic) SearchList(req *types.SearchReq) (resp *types.CommonRe
 				return "超前项目"
 			}
 			return ""
-		}(req.SearchGroup), //搜索分组:默认0:全部;1:招标采购公告;2:超前项目
+		}(req.SearchGroup),                                                   //搜索分组:默认0:全部;1:招标采购公告;2:超前项目
 		"searchMode":         common.If(req.SearchMode == 1, "模糊搜索", "精准搜索"), //搜索模式:0:精准搜索;1:模糊搜索
 		"wordsMode":          common.If(req.WordsMode == 1, "包含任意", "包含所有"),  //搜索关键词模式;默认0:包含所有,1:包含任意
 		"search_word":        req.KeyWords,

+ 12 - 0
jyBXCore/api/internal/util/util.go

@@ -9,6 +9,7 @@ import (
 	"sort"
 	"strings"
 	"time"
+	"unicode"
 )
 
 var (
@@ -131,3 +132,14 @@ func GenerateRandomNumber(start int, end int, count int) []int {
 	sort.Ints(nums)
 	return nums
 }
+
+// RemoveInvisibleChars 移除控制字符和不可见字符
+func RemoveInvisibleChars(s string) string {
+	return strings.Map(func(r rune) rune {
+		// 保留普通字符、中文、标点等可见字符
+		if unicode.IsGraphic(r) && !unicode.IsControl(r) {
+			return r
+		}
+		return -1
+	}, s)
+}