- trim store deliveryRange(possible additional ;)

This commit is contained in:
gazebo
2018-11-14 12:11:43 +08:00
parent ec1a3deee6
commit f9e8e4745a
2 changed files with 18 additions and 7 deletions

View File

@@ -259,10 +259,11 @@ func GetVendorStore(ctx *jxcontext.Context, vendorStoreID string, vendorID int)
}
func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interface{}, userName string) (num int64, err error) {
globals.SugarLogger.Debugf("UpdateStore storeID:%d, payload:%s", storeID, utils.Format4Output(payload, false))
store := &model.Store{}
store.ID = storeID
valid := dao.NormalMakeMapByStructObject(payload, store, userName)
globals.SugarLogger.Debug(utils.Format4Output(valid, false))
if valid["name"] != nil {
valid["name"] = jxutils.FormalizeName(valid["name"].(string))
}
@@ -270,6 +271,9 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa
valid["lng"] = jxutils.StandardCoordinate2Int(utils.Interface2FloatWithDefault(payload["lng"], 0.0))
valid["lat"] = jxutils.StandardCoordinate2Int(utils.Interface2FloatWithDefault(payload["lat"], 0.0))
}
if valid["deliveryRange"] != nil {
valid["deliveryRange"] = strings.Trim(valid["deliveryRange"].(string), ";")
}
if len(valid) > 0 {
db := dao.GetDB()
dao.Begin(db)
@@ -291,11 +295,14 @@ 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
existingID := store.ID
store.Lng = jxutils.StandardCoordinate2Int(storeExt.FloatLng)
store.Lat = jxutils.StandardCoordinate2Int(storeExt.FloatLat)
store.Name = jxutils.FormalizeName(store.Name)
store.DeliveryRange = strings.Trim(store.DeliveryRange, ";")
dao.WrapAddIDCULDEntity(store, userName)
store.ID = existingID
if err = dao.CreateEntity(nil, store); err == nil {