- 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)