Bladeren bron

feat:查询限制

wangshan 2 jaren geleden
bovenliggende
commit
4c20e6d1c1
2 gewijzigde bestanden met toevoegingen van 12 en 3 verwijderingen
  1. 5 0
      src/jfw/front/searchOptimize.go
  2. 7 3
      src/jfw/front/swordfish.go

+ 5 - 0
src/jfw/front/searchOptimize.go

@@ -185,6 +185,11 @@ func (so *SearchOptimize) SearchParamsHandle() {
 	if so.PageNum <= 0 {
 		so.PageNum = 1
 	}
+	userCount := util.If(so.IsPay, bidsearch.SearchMaxPageCount_PAYED, bidsearch.SearchMaxPageCount_PC).(int)
+	if so.PageNum > userCount/so.PageSize {
+		so.PageNum = -1
+		so.PageSize = -1
+	}
 	//行业格式化
 	if so.Industry != "" {
 		so.Industry = strings.TrimSpace(so.Industry)

+ 7 - 3
src/jfw/front/swordfish.go

@@ -172,9 +172,13 @@ func (m *Front) PcAjaxReq() {
 		if isLimit == 1 {
 			searchTypeSwitch, _ := config.Sysconfig["searchTypeSwitch"].(bool)
 			so := NewSearchOptimize(userId, phone, area, city, subtype, toptype, publishtime, strings.Join(queryItems, ","), fmt.Sprintf("%s-%s", minprice, maxprice), industry, buyerclass, hasBuyerTel, hasWinnerTel, fileExists, s_word, additionalWords, notkey, "PC", territorialization, currentPage, pageSize, searchGroup, searchMode, wordsMode, *userInfo, searchTypeSwitch, m.Request)
-			m.SetSession("selectType", so.SelectType)
-			heightKeys = so.HeightKeys
-			count, total, list = so.GetBidSearchList(false)
+			if so.PageNum < 0 && so.PageSize < 0 {
+				log.Printf("查询参数超出范围,有可能是异常请求; 用户id:%s;用户手机号:%s \n", userId, phone)
+			} else {
+				m.SetSession("selectType", so.SelectType)
+				heightKeys = so.HeightKeys
+				count, total, list = so.GetBidSearchList(false)
+			}
 		}
 	} else {
 		searchTypeSwitch, _ := config.Sysconfig["searchTypeSwitch"].(bool)