From 226a537337fbdc570a7e18769b090181b3c01846 Mon Sep 17 00:00:00 2001 From: shenzhuan Date: Mon, 7 Nov 2022 11:01:19 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BC=A0=E5=85=A5=E7=9A=84cartIds=20=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=8F=90=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/utils.go b/utils.go index d5a923f..c05e113 100644 --- a/utils.go +++ b/utils.go @@ -3,6 +3,7 @@ package common import ( "math" "strconv" + "strings" ) /* @@ -63,3 +64,21 @@ func ConverToBinary(n int) string { } 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 +}