...
|
...
|
@@ -4,6 +4,7 @@ import ( |
|
|
"fmt"
|
|
|
"github.com/linmadan/egglib-go/utils/xtime"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils"
|
|
|
"strconv"
|
|
|
"strings"
|
|
|
)
|
|
|
|
...
|
...
|
@@ -221,7 +222,8 @@ func ToFieldData(fields []*Field, data [][]string, byName bool, configs ...bool) |
|
|
continue
|
|
|
}
|
|
|
if len(d) >= j {
|
|
|
item[key] = d[j]
|
|
|
// 处理精度问题
|
|
|
item[key] = RoundFieldValue(f, d[j]) //d[j]
|
|
|
} else {
|
|
|
item[key] = ""
|
|
|
}
|
...
|
...
|
@@ -231,6 +233,19 @@ func ToFieldData(fields []*Field, data [][]string, byName bool, configs ...bool) |
|
|
return result
|
|
|
}
|
|
|
|
|
|
// RoundFieldValue 字段值精度处理
|
|
|
func RoundFieldValue(f *Field, v string) string {
|
|
|
if f.SQLType != Float.ToString() {
|
|
|
return v
|
|
|
}
|
|
|
fv, err := strconv.ParseFloat(v, 64)
|
|
|
if err != nil {
|
|
|
return v
|
|
|
}
|
|
|
fv = utils.Round(fv, 6)
|
|
|
return fmt.Sprintf("%v", fv)
|
|
|
}
|
|
|
|
|
|
func GripData(data []map[string]string, total int64) map[string]interface{} {
|
|
|
if len(data) == 0 {
|
|
|
data = make([]map[string]string, 0)
|
...
|
...
|
@@ -257,6 +272,10 @@ func MakeToInterfaces(fields []*Field) func([]string) []interface{} { |
|
|
output := make([]interface{}, len(input))
|
|
|
for i, v := range input {
|
|
|
if i < len(fields) {
|
|
|
// 处理精度问题
|
|
|
if fields[i].SQLType == Float.ToString() {
|
|
|
v = RoundFieldValue(fields[i], v)
|
|
|
}
|
|
|
convValue, err := ValueToType(v, fields[i].SQLType)
|
|
|
if err == nil {
|
|
|
output[i] = convValue
|
...
|
...
|
|