- GetAndStoreCitiesShops添加参数isShuffle
This commit is contained in:
@@ -2,6 +2,7 @@ package netspider
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
|
||||
"git.rosy.net.cn/jx-callback/globals"
|
||||
"git.rosy.net.cn/jx-callback/globals/api"
|
||||
@@ -124,7 +125,7 @@ func getStoreListByCoordinates(ctx *jxcontext.Context, parentTask tasksch.ITask,
|
||||
return storeList, err
|
||||
}
|
||||
|
||||
func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeList []int, radius, gridWith int, isAsync bool) (hint string, err error) {
|
||||
func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeList []int, radius, gridWith int, isShuffle, isAsync bool) (hint string, err error) {
|
||||
db := dao.GetDB()
|
||||
if len(cityCodeList) == 0 {
|
||||
placeList, err2 := dao.GetPlacesByCond(db, dao.EnableCondAll)
|
||||
@@ -134,7 +135,11 @@ func GetAndStoreCitiesShops(ctx *jxcontext.Context, vendorIDs []int, cityCodeLis
|
||||
for _, v := range placeList {
|
||||
cityCodeList = append(cityCodeList, v.Code)
|
||||
}
|
||||
// cityCodeList = []int{510100}
|
||||
}
|
||||
if isShuffle {
|
||||
rand.Shuffle(len(cityCodeList), func(i, j int) {
|
||||
cityCodeList[i], cityCodeList[j] = cityCodeList[j], cityCodeList[i]
|
||||
})
|
||||
}
|
||||
if len(vendorIDs) == 0 {
|
||||
vendorIDs = []int{model.VendorIDJD, model.VendorIDEBAI}
|
||||
|
||||
@@ -11,13 +11,14 @@ type NetSpiderController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
// @Title 同步商家商品信息
|
||||
// @Description 同步商家商品信息
|
||||
// @Title 从网页拉取平台门店信息
|
||||
// @Description 从网页拉取平台门店信息
|
||||
// @Param token header string true "认证token"
|
||||
// @Param vendorIDs formData string false "厂商ID列表"
|
||||
// @Param cityCodes formData string false "城市列表,缺省为后台启用了的城市"
|
||||
// @Param radius formData int false "区域半径(市或街道的半径会自动增加或缩小),单位为米,缺省8000米"
|
||||
// @Param gridWith formData int false "网格大小,单位为米,缺省为2000米"
|
||||
// @Param isShuffle formData bool false "是否将城市列表随机打乱"
|
||||
// @Param isAsync formData bool false "是否异步"
|
||||
// @Success 200 {object} controllers.CallResult
|
||||
// @Failure 200 {object} controllers.CallResult
|
||||
@@ -27,7 +28,7 @@ func (c *NetSpiderController) GetAndStoreCitiesShops() {
|
||||
var vendorIDs, cityCodes []int
|
||||
err = jxutils.Strings2Objs(params.VendorIDs, &vendorIDs, params.CityCodes, &cityCodes)
|
||||
if err == nil {
|
||||
retVal, err = netspider.GetAndStoreCitiesShops(params.Ctx, vendorIDs, cityCodes, params.Radius, params.GridWith, params.IsAsync)
|
||||
retVal, err = netspider.GetAndStoreCitiesShops(params.Ctx, vendorIDs, cityCodes, params.Radius, params.GridWith, params.IsShuffle, params.IsAsync)
|
||||
}
|
||||
return retVal, "", err
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user