- jxutils.IsLegalStoreID
This commit is contained in:
@@ -2,6 +2,7 @@ package cms
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"fmt"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
@@ -251,6 +252,9 @@ func GetVendorStore(ctx *jxcontext.Context, vendorStoreID string, vendorID int)
|
|||||||
if district, err2 := dao.GetPlaceByCode(db, result.DistrictCode); err2 == nil {
|
if district, err2 := dao.GetPlaceByCode(db, result.DistrictCode); err2 == nil {
|
||||||
retVal.DistrictName = district.Name
|
retVal.DistrictName = district.Name
|
||||||
}
|
}
|
||||||
|
if !jxutils.IsLegalStoreID(retVal.ID) {
|
||||||
|
retVal.ID = 0
|
||||||
|
}
|
||||||
return retVal, nil
|
return retVal, nil
|
||||||
}
|
}
|
||||||
return nil, err
|
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) {
|
func CreateStore(ctx *jxcontext.Context, storeExt *StoreExt, userName string) (id int, err error) {
|
||||||
globals.SugarLogger.Debugf("CreateStore storeExt:%s", utils.Format4Output(storeExt, false))
|
globals.SugarLogger.Debugf("CreateStore storeExt:%s", utils.Format4Output(storeExt, false))
|
||||||
|
|
||||||
store := &storeExt.Store
|
store := &storeExt.Store
|
||||||
|
if store.ID != 0 && !jxutils.IsLegalStoreID(store.ID) {
|
||||||
|
return 0, fmt.Errorf("ID:%d不是合法的京西门店编号")
|
||||||
|
}
|
||||||
|
|
||||||
existingID := store.ID
|
existingID := store.ID
|
||||||
store.Lng = jxutils.StandardCoordinate2Int(storeExt.FloatLng)
|
store.Lng = jxutils.StandardCoordinate2Int(storeExt.FloatLng)
|
||||||
store.Lat = jxutils.StandardCoordinate2Int(storeExt.FloatLat)
|
store.Lat = jxutils.StandardCoordinate2Int(storeExt.FloatLat)
|
||||||
|
|||||||
@@ -192,3 +192,7 @@ func Int2OneZero(value int) int {
|
|||||||
func IsMobileFake(mobile string) bool {
|
func IsMobileFake(mobile string) bool {
|
||||||
return utils.Str2Int64WithDefault(strings.Replace(strings.Replace(mobile, "-", "", -1), ",", "", -1), 0) == 0
|
return utils.Str2Int64WithDefault(strings.Replace(strings.Replace(mobile, "-", "", -1), ",", "", -1), 0) == 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsLegalStoreID(id int) bool {
|
||||||
|
return id >= 100000 && id < 200000
|
||||||
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ type PromotionController struct {
|
|||||||
// @Param limitPin formData int false "是否账号限购0-不限,1-限购"
|
// @Param limitPin formData int false "是否账号限购0-不限,1-限购"
|
||||||
// @Param limitCount formData int false "限购件数 0-不限,如账号限购、设备限购有一个为1,则限购件数必须大于0的整数"
|
// @Param limitCount formData int false "限购件数 0-不限,如账号限购、设备限购有一个为1,则限购件数必须大于0的整数"
|
||||||
// @Param isAsync formData bool false "是否异步,缺省否(暂时只支持同步)"
|
// @Param isAsync formData bool false "是否异步,缺省否(暂时只支持同步)"
|
||||||
// @Param isContinueWhenError formData bool false "单个同步失败是否继续,缺省false"
|
// @Param isContinueWhenError formData bool false "单个广告失败是否继续,缺省false"
|
||||||
// @Param advertising formData string false "广告语"
|
// @Param advertising formData string false "广告语"
|
||||||
// @Param vendorPromotionID formData string false "厂商活动id,设置此字段表示关联京东活动,并不会真正去创建"
|
// @Param vendorPromotionID formData string false "厂商活动id,设置此字段表示关联京东活动,并不会真正去创建"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
|||||||
Reference in New Issue
Block a user