正在显示
4 个修改的文件
包含
22 行增加
和
6 行删除
@@ -110,7 +110,7 @@ func (tableService *TableService) FieldOptionalValues(ctx *domain.Context, cmd * | @@ -110,7 +110,7 @@ func (tableService *TableService) FieldOptionalValues(ctx *domain.Context, cmd * | ||
110 | if err := transactionContext.CommitTransaction(); err != nil { | 110 | if err := transactionContext.CommitTransaction(); err != nil { |
111 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) | 111 | return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error()) |
112 | } | 112 | } |
113 | - values := dataTable.OptionalValue(cmd.Match) | 113 | + values := dataTable.OptionalValue(cmd.Match, field.SQLType) |
114 | return map[string]interface{}{ | 114 | return map[string]interface{}{ |
115 | "values": values, | 115 | "values": values, |
116 | "total": len(values), | 116 | "total": len(values), |
@@ -55,16 +55,24 @@ type Condition struct { | @@ -55,16 +55,24 @@ type Condition struct { | ||
55 | 55 | ||
56 | func (t *DataTable) OptionalValue(args ...string) []string { | 56 | func (t *DataTable) OptionalValue(args ...string) []string { |
57 | var values = make([]string, 0) | 57 | var values = make([]string, 0) |
58 | - match:="" | ||
59 | - if len(args)>0{ | 58 | + match := "" |
59 | + filedType := "" | ||
60 | + if len(args) > 0 { | ||
60 | match = args[0] | 61 | match = args[0] |
61 | } | 62 | } |
63 | + if len(args) > 1 { | ||
64 | + filedType = args[1] | ||
65 | + } | ||
62 | if len(t.Data) > 0 && len(t.Data[0]) == 1 { | 66 | if len(t.Data) > 0 && len(t.Data[0]) == 1 { |
63 | for i := range t.Data { | 67 | for i := range t.Data { |
64 | if len(t.Data[i]) == 0 { | 68 | if len(t.Data[i]) == 0 { |
65 | continue | 69 | continue |
66 | } | 70 | } |
67 | - if len(match)>0 && !strings.Contains(t.Data[i][0],match){ | 71 | + if len(match) > 0 && !strings.Contains(t.Data[i][0], match) { |
72 | + continue | ||
73 | + } | ||
74 | + if filedType == Float.ToString() { | ||
75 | + values = append(values, RoundFieldValue(&Field{SQLType: filedType}, t.Data[i][0])) | ||
68 | continue | 76 | continue |
69 | } | 77 | } |
70 | values = append(values, t.Data[i][0]) | 78 | values = append(values, t.Data[i][0]) |
@@ -125,8 +125,8 @@ var ( | @@ -125,8 +125,8 @@ var ( | ||
125 | Int SQLType = "INT" | 125 | Int SQLType = "INT" |
126 | BigInt SQLType = "BIGINT" | 126 | BigInt SQLType = "BIGINT" |
127 | Float SQLType = "FLOAT" | 127 | Float SQLType = "FLOAT" |
128 | - DECIMALV2 SQLType = "DECIMALV2" | ||
129 | - DECIMAL279 SQLType = "DECIMAL(27,9)" | 128 | + DECIMALV2 SQLType = "DECIMAL(20,15)" //"DECIMALV2" |
129 | + DECIMAL279 SQLType = "DECIMAL(20,15)" | ||
130 | Date SQLType = "DATE" | 130 | Date SQLType = "DATE" |
131 | Datetime SQLType = "DATETIME" | 131 | Datetime SQLType = "DATETIME" |
132 | ) | 132 | ) |
@@ -4,6 +4,7 @@ import ( | @@ -4,6 +4,7 @@ import ( | ||
4 | "fmt" | 4 | "fmt" |
5 | "github.com/linmadan/egglib-go/utils/xtime" | 5 | "github.com/linmadan/egglib-go/utils/xtime" |
6 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils" | 6 | "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils" |
7 | + "strconv" | ||
7 | "strings" | 8 | "strings" |
8 | ) | 9 | ) |
9 | 10 | ||
@@ -244,6 +245,13 @@ func ToFieldData(fields []*Field, data [][]string, byName bool, configs ...bool) | @@ -244,6 +245,13 @@ func ToFieldData(fields []*Field, data [][]string, byName bool, configs ...bool) | ||
244 | 245 | ||
245 | // RoundFieldValue 字段值精度处理 | 246 | // RoundFieldValue 字段值精度处理 |
246 | func RoundFieldValue(f *Field, v string) string { | 247 | func RoundFieldValue(f *Field, v string) string { |
248 | + if f.SQLType == Float.ToString() { | ||
249 | + fv, err := strconv.ParseFloat(v, 64) | ||
250 | + if err != nil { | ||
251 | + return v | ||
252 | + } | ||
253 | + return fmt.Sprintf("%v", fv) | ||
254 | + } | ||
247 | return v | 255 | return v |
248 | //if f.SQLType != DECIMALV2.ToString() { | 256 | //if f.SQLType != DECIMALV2.ToString() { |
249 | // return v | 257 | // return v |
-
请 注册 或 登录 后发表评论