diff --git a/business/jxstore/cms/store.go b/business/jxstore/cms/store.go index 44205af0a..0e80ac1d2 100644 --- a/business/jxstore/cms/store.go +++ b/business/jxstore/cms/store.go @@ -617,7 +617,9 @@ func UpdateStore(ctx *jxcontext.Context, storeID int, payload map[string]interfa if err = dao.GetEntity(db, store); err != nil { return 0, err } - valid := dao.StrictMakeMapByStructObject(payload, store, userName) + outStore := &model.Store{} + valid := dao.StrictMakeMapByStructObject2(payload, store, outStore, userName) + fmt.Println(outStore) if err = checkStoreDeliveryRange(utils.Interface2String(valid["deliveryRange"])); err != nil { return 0, err } diff --git a/business/model/dao/dao_utils.go b/business/model/dao/dao_utils.go index b45b4386c..736a463c7 100644 --- a/business/model/dao/dao_utils.go +++ b/business/model/dao/dao_utils.go @@ -13,7 +13,7 @@ import ( func IDCULDFilterMapByStructObject(mapData map[string]interface{}, obj interface{}, isCheckValue bool) (valid map[string]interface{}, invalid map[string]interface{}) { // 这里必须用首字母小写,因为是用于访问map,是需要完全匹配的 - return refutil.FilterMapByStructObject(mapData, obj, []string{"id", "createdAt", "updatedAt", "finishedAt", "deletedAt", "syncStatus", "lastOperator"}, isCheckValue) + return refutil.FilterMapByStructObject(mapData, obj, nil, []string{"id", "createdAt", "updatedAt", "finishedAt", "deletedAt", "syncStatus", "lastOperator"}, isCheckValue) } func NormalMakeMapByStructObject(mapData map[string]interface{}, obj interface{}, userName string) (retVal map[string]interface{}) { @@ -26,6 +26,16 @@ func StrictMakeMapByStructObject(mapData map[string]interface{}, obj interface{} return retVal } +func IDCULDFilterMapByStructObject2(mapData map[string]interface{}, obj interface{}, objPtr interface{}, isCheckValue bool) (valid map[string]interface{}, invalid map[string]interface{}) { + return refutil.FilterMapByStructObject(mapData, obj, objPtr, []string{"id", "createdAt", "updatedAt", "finishedAt", "deletedAt", "syncStatus", "lastOperator"}, isCheckValue) +} + +//根据传进来的objPtr去修改它的值 +func StrictMakeMapByStructObject2(mapData map[string]interface{}, obj interface{}, objPtr interface{}, userName string) (retVal map[string]interface{}) { + retVal, _ = IDCULDFilterMapByStructObject2(mapData, obj, objPtr, true) + return retVal +} + func NormalMakeMapByFieldList(mapData map[string]interface{}, fields []string, userName string) (retVal map[string]interface{}) { retVal, _ = refutil.FilterMapByFieldList(mapData, fields) return retVal diff --git a/globals/refutil/refutil.go b/globals/refutil/refutil.go index 23900f2c3..c28475bc2 100644 --- a/globals/refutil/refutil.go +++ b/globals/refutil/refutil.go @@ -53,7 +53,7 @@ func DeSerializeData(strValue string, dataPtr interface{}) (err error) { } // todo 这里看是否需要将key值转换成标准格式(即字母大写),因为beego orm不区分,不转换也可以 -func FilterMapByStructObject(mapData map[string]interface{}, obj interface{}, excludedFields []string, isCheckValue bool) (valid map[string]interface{}, invalid map[string]interface{}) { +func FilterMapByStructObject(mapData map[string]interface{}, obj interface{}, objPtr interface{}, excludedFields []string, isCheckValue bool) (valid map[string]interface{}, invalid map[string]interface{}) { excludedMap := make(map[string]int) for _, v := range excludedFields { excludedMap[v] = 1 @@ -69,7 +69,9 @@ func FilterMapByStructObject(mapData map[string]interface{}, obj interface{}, ex invalid[k] = v } } - utils.Map2StructByJson(m, obj, true) + if objPtr != nil { + utils.Map2StructByJson(m, objPtr, true) + } return valid, invalid }