- 清理三个平台的门店商品批处理操作,部分失败返回失败条目
This commit is contained in:
@@ -247,6 +247,13 @@ func Int64ToStr(value int64) string {
|
||||
return strconv.FormatInt(value, 10)
|
||||
}
|
||||
|
||||
func Int64ToStrNoZero(value int64) string {
|
||||
if value == 0 {
|
||||
return ""
|
||||
}
|
||||
return strconv.FormatInt(value, 10)
|
||||
}
|
||||
|
||||
func Int2Str(value int) string {
|
||||
return strconv.Itoa(value)
|
||||
}
|
||||
@@ -469,11 +476,48 @@ func Struct2FlatMap(obj interface{}) map[string]interface{} {
|
||||
}
|
||||
|
||||
// !!! 此函数好像不支持struct是内嵌结构的
|
||||
func Map2StructByJson(inObj interface{}, outObjAddr interface{}, weaklyTypedInput bool) (err error) {
|
||||
func Map2Struct(inObj interface{}, outObjAddr interface{}, weaklyTypedInput bool, tagName string) (err error) {
|
||||
if tagName == "" {
|
||||
tagName = "json"
|
||||
}
|
||||
decoder, _ := mapstructure.NewDecoder(&mapstructure.DecoderConfig{
|
||||
TagName: "json",
|
||||
TagName: tagName,
|
||||
Result: outObjAddr,
|
||||
WeaklyTypedInput: weaklyTypedInput,
|
||||
})
|
||||
return decoder.Decode(inObj)
|
||||
}
|
||||
|
||||
func Map2StructByJson(inObj interface{}, outObjAddr interface{}, weaklyTypedInput bool) (err error) {
|
||||
return Map2Struct(inObj, outObjAddr, weaklyTypedInput, "")
|
||||
}
|
||||
|
||||
func Int64Slice2String(intList []int64) (outList []string) {
|
||||
if len(intList) > 0 {
|
||||
outList = make([]string, len(intList))
|
||||
for k, v := range intList {
|
||||
outList[k] = Int64ToStr(v)
|
||||
}
|
||||
}
|
||||
return outList
|
||||
}
|
||||
|
||||
func StringSlice2Int64(intList []string) (outList []int64) {
|
||||
if len(intList) > 0 {
|
||||
outList = make([]int64, len(intList))
|
||||
for k, v := range intList {
|
||||
outList[k] = Str2Int64WithDefault(v, 0)
|
||||
}
|
||||
}
|
||||
return outList
|
||||
}
|
||||
|
||||
func IntSlice2Int64(intList []int) (outList []int64) {
|
||||
if len(intList) > 0 {
|
||||
outList = make([]int64, len(intList))
|
||||
for k, v := range intList {
|
||||
outList[k] = int64(v)
|
||||
}
|
||||
}
|
||||
return outList
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user