fix: 配置导表部分未填写的字段导致整个表被截断问题处理
This commit is contained in:
parent
e0c63d569d
commit
65aac67cf4
|
@ -260,13 +260,19 @@ func (slf *Config) initData() error {
|
|||
continue
|
||||
}
|
||||
var value any
|
||||
var zero bool
|
||||
if slf.horizontal {
|
||||
c := slf.matrix.Get(x+i, y)
|
||||
if c == nil || (currentIndex < slf.IndexCount && len(strings.TrimSpace(c.String())) == 0) {
|
||||
if c == nil {
|
||||
value = getValueZero(field.SourceType)
|
||||
zero = true
|
||||
} else if currentIndex < slf.IndexCount && len(strings.TrimSpace(c.String())) == 0 {
|
||||
stop = true
|
||||
break
|
||||
}
|
||||
value = getValueWithType(field.SourceType, c.String())
|
||||
if !zero {
|
||||
value = getValueWithType(field.SourceType, c.String())
|
||||
}
|
||||
} else {
|
||||
c := slf.matrix.Get(x, y+i+offset)
|
||||
for c == nil {
|
||||
|
|
|
@ -54,6 +54,44 @@ var basicType = map[string]func(fieldValue string) any{
|
|||
"boolean": withBoolType,
|
||||
}
|
||||
|
||||
func getValueZero(fileType string) any {
|
||||
switch basicTypeName[fileType] {
|
||||
case "string":
|
||||
return getValueWithType(fileType, "")
|
||||
case "int":
|
||||
return getValueWithType(fileType, "0")
|
||||
case "int8":
|
||||
return getValueWithType(fileType, "0")
|
||||
case "int16":
|
||||
return getValueWithType(fileType, "0")
|
||||
case "int32":
|
||||
return getValueWithType(fileType, "0")
|
||||
case "int64":
|
||||
return getValueWithType(fileType, "0")
|
||||
case "uint":
|
||||
return getValueWithType(fileType, "0")
|
||||
case "uint8":
|
||||
return getValueWithType(fileType, "0")
|
||||
case "uint16":
|
||||
return getValueWithType(fileType, "0")
|
||||
case "uint32":
|
||||
return getValueWithType(fileType, "0")
|
||||
case "uint64":
|
||||
return getValueWithType(fileType, "0")
|
||||
case "float32":
|
||||
return getValueWithType(fileType, "0")
|
||||
case "float64":
|
||||
return getValueWithType(fileType, "0")
|
||||
case "byte":
|
||||
return getValueWithType(fileType, "0")
|
||||
case "rune":
|
||||
return getValueWithType(fileType, "0")
|
||||
case "bool":
|
||||
return getValueWithType(fileType, "false")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getValueWithType(fieldType string, fieldValue string) any {
|
||||
fieldType = strings.ToLower(strings.TrimSpace(fieldType))
|
||||
handle, exist := basicType[fieldType]
|
||||
|
|
Loading…
Reference in New Issue