格式化页面传入的cartIds 方法提取

master
shenzhuan 2 years ago
parent 210da4c8a1
commit 226a537337

@ -3,6 +3,7 @@ package common
import ( import (
"math" "math"
"strconv" "strconv"
"strings"
) )
/* /*
@ -63,3 +64,21 @@ func ConverToBinary(n int) string {
} }
return res return res
} }
// 格式化页面传入的cartIds 方法提取
func SplitToInt32List(str string, sep string) (int32List []int32) {
tempStr := strings.Split(str, sep)
if len(tempStr) > 0 {
for _, item := range tempStr {
if item == "" {
continue
}
val, err := strconv.ParseInt(item, 10, 32)
if err != nil {
continue
}
int32List = append(int32List, int32(val))
}
}
return int32List
}

Loading…
Cancel
Save