fix(excel):修正部分文案,增加对于错误信息的JSON输出定义。
This commit is contained in:
parent
592e93b2c9
commit
21803bf832
|
@ -25,9 +25,9 @@ type ExcelAnalyzer[T any] struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type ExcelAnalysisError struct {
|
type ExcelAnalysisError struct {
|
||||||
Row int
|
Row int `json:"row"`
|
||||||
Col int
|
Col int `json:"col"`
|
||||||
Err error
|
Err error `json:"error"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewColumnRecognizer(tag string, patterns ...string) ColumnRecognizer {
|
func NewColumnRecognizer(tag string, patterns ...string) ColumnRecognizer {
|
||||||
|
@ -137,7 +137,7 @@ func (a *ExcelAnalyzer[T]) Analysis(bean T) ([]T, []ExcelAnalysisError) {
|
||||||
} else {
|
} else {
|
||||||
v, err := strconv.Atoi(matchValue)
|
v, err := strconv.Atoi(matchValue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, ExcelAnalysisError{Row: rowIndex + 1, Col: recognizer.MatchIndex + 1, Err: fmt.Errorf("单元格内容应为不带小鼠的整数。%w", err)})
|
errs = append(errs, ExcelAnalysisError{Row: rowIndex + 1, Col: recognizer.MatchIndex + 1, Err: fmt.Errorf("单元格内容应为不带小数的整数。%w", err)})
|
||||||
actualField.SetInt(0)
|
actualField.SetInt(0)
|
||||||
} else {
|
} else {
|
||||||
actualField.SetInt(int64(v))
|
actualField.SetInt(int64(v))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user