ソースを参照

修改工具类,支持big转换

zhangjinkun 7 年 前
コミット
b6d3da87ab

+ 5 - 1
common/src/github.com/donnie4w/go-logger/logger/logw.go

@@ -221,7 +221,11 @@ func (this *logBean) console(v ...interface{}) {
 
 func (this *logBean) log(level string, v ...interface{}) {
 	defer catchError()
-	s := fmt.Sprint(v...)
+	//s := fmt.Sprint(v...)
+	s := ""
+	for _, val := range v {
+		s += " " + fmt.Sprint(val)
+	}
 	length := len([]byte(s))
 	var lg *fileBean = fbf.get(this.id)
 	var _level = ALL

+ 10 - 0
common/src/qfw/util/common.go

@@ -9,6 +9,7 @@ import (
 	"io"
 	"log"
 	"math"
+	"math/big"
 	mathRand "math/rand"
 	"net/url"
 	"regexp"
@@ -239,6 +240,9 @@ func Int64All(num interface{}) int64 {
 		return int64(i5)
 	} else if i6, ok6 := num.(int8); ok6 {
 		return int64(i6)
+	} else if i7, ok7 := num.(*big.Int); ok7 {
+		in, _ := strconv.ParseInt(fmt.Sprint(i7), 10, 64)
+		return int64(in)
 	} else {
 		return 0
 	}
@@ -272,6 +276,9 @@ func Float64All(num interface{}) float64 {
 		return float64(i6)
 	} else if i6, ok6 := num.(uint64); ok6 {
 		return float64(i6)
+	} else if i7, ok7 := num.(*big.Float); ok7 {
+		in, _ := strconv.ParseFloat(fmt.Sprint(i7), 64)
+		return float64(in)
 	} else {
 		return 0
 	}
@@ -295,6 +302,9 @@ func IntAllDef(num interface{}, defaultNum int) int {
 		return int(i5)
 	} else if i6, ok6 := num.(int8); ok6 {
 		return int(i6)
+	} else if i7, ok7 := num.(*big.Int); ok7 {
+		in, _ := strconv.Atoi(fmt.Sprint(i7))
+		return int(in)
 	} else {
 		return defaultNum
 	}