- jxutils.IsLegalStoreID

This commit is contained in:
gazebo
2018-11-16 11:25:14 +08:00
parent 42f4c01c1e
commit 28b6689c56
3 changed files with 13 additions and 2 deletions

View File

@@ -2,6 +2,7 @@ package cms
import (
"errors"
"fmt"
"strconv"
"strings"
@@ -251,6 +252,9 @@ func GetVendorStore(ctx *jxcontext.Context, vendorStoreID string, vendorID int)
if district, err2 := dao.GetPlaceByCode(db, result.DistrictCode); err2 == nil {
retVal.DistrictName = district.Name
}
if !jxutils.IsLegalStoreID(retVal.ID) {
retVal.ID = 0
}
return retVal, nil
}
return nil, err
@@ -296,8 +300,11 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (id int, err error) {
globals.SugarLogger.Debugf("CreateStore storeExt:%s", utils.Format4Output(storeExt, false))
store := &storeExt.Store
if store.ID != 0 && !jxutils.IsLegalStoreID(store.ID) {
return 0, fmt.Errorf("ID:%d不是合法的京西门店编号")
}
existingID := store.ID
store.Lng = jxutils.StandardCoordinate2Int(storeExt.FloatLng)
store.Lat = jxutils.StandardCoordinate2Int(storeExt.FloatLat)

View File

@@ -192,3 +192,7 @@ func Int2OneZero(value int) int {
func IsMobileFake(mobile string) bool {
return utils.Str2Int64WithDefault(strings.Replace(strings.Replace(mobile, "-", "", -1), ",", "", -1), 0) == 0
}
func IsLegalStoreID(id int) bool {
return id >= 100000 && id < 200000
}

View File

@@ -29,7 +29,7 @@ type PromotionController struct {
// @Param limitPin formData int false "是否账号限购0-不限1-限购"
// @Param limitCount formData int false "限购件数 0-不限如账号限购、设备限购有一个为1则限购件数必须大于0的整数"
// @Param isAsync formData bool false "是否异步,缺省否(暂时只支持同步)"
// @Param isContinueWhenError formData bool false "单个同步失败是否继续缺省false"
// @Param isContinueWhenError formData bool false "单个广告失败是否继续缺省false"
// @Param advertising formData string false "广告语"
// @Param vendorPromotionID formData string false "厂商活动id设置此字段表示关联京东活动并不会真正去创建"
// @Success 200 {object} controllers.CallResult