Browse Source

Merge branch 'dev2.1' of ssh://192.168.3.207:10022/qmx/qfw into dev2.1

wangchuanjin 7 years ago
parent
commit
45c02be403
1 changed files with 21 additions and 0 deletions
  1. 21 0
      common/src/qfw/util/common.go

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

@@ -243,6 +243,9 @@ func Int64All(num interface{}) int64 {
 	} else if i7, ok7 := num.(*big.Int); ok7 {
 	} else if i7, ok7 := num.(*big.Int); ok7 {
 		in, _ := strconv.ParseInt(fmt.Sprint(i7), 10, 64)
 		in, _ := strconv.ParseInt(fmt.Sprint(i7), 10, 64)
 		return int64(in)
 		return int64(in)
+	} else if i8, ok8 := num.(*big.Float); ok8 {
+		in, _ := strconv.ParseInt(fmt.Sprint(i8), 10, 64)
+		return int64(in)
 	} else {
 	} else {
 		return 0
 		return 0
 	}
 	}
@@ -279,6 +282,9 @@ func Float64All(num interface{}) float64 {
 	} else if i7, ok7 := num.(*big.Float); ok7 {
 	} else if i7, ok7 := num.(*big.Float); ok7 {
 		in, _ := strconv.ParseFloat(fmt.Sprint(i7), 64)
 		in, _ := strconv.ParseFloat(fmt.Sprint(i7), 64)
 		return float64(in)
 		return float64(in)
+	} else if i8, ok8 := num.(*big.Int); ok8 {
+		in, _ := strconv.ParseFloat(fmt.Sprint(i8), 64)
+		return float64(in)
 	} else {
 	} else {
 		return 0
 		return 0
 	}
 	}
@@ -305,6 +311,9 @@ func IntAllDef(num interface{}, defaultNum int) int {
 	} else if i7, ok7 := num.(*big.Int); ok7 {
 	} else if i7, ok7 := num.(*big.Int); ok7 {
 		in, _ := strconv.Atoi(fmt.Sprint(i7))
 		in, _ := strconv.Atoi(fmt.Sprint(i7))
 		return int(in)
 		return int(in)
+	} else if i8, ok8 := num.(*big.Float); ok8 {
+		in, _ := strconv.Atoi(fmt.Sprint(i8))
+		return int(in)
 	} else {
 	} else {
 		return defaultNum
 		return defaultNum
 	}
 	}
@@ -319,6 +328,18 @@ func ObjToString(old interface{}) string {
 	}
 	}
 }
 }
 
 
+func ObjToStringDef(old interface{}, defaultstr string) string {
+	if nil == old {
+		return defaultstr
+	} else {
+		r, _ := old.(string)
+		if r == "" {
+			return defaultstr
+		}
+		return r
+	}
+}
+
 //对象数组转成string数组
 //对象数组转成string数组
 func ObjArrToStringArr(old []interface{}) []string {
 func ObjArrToStringArr(old []interface{}) []string {
 	if old != nil {
 	if old != nil {