fix(excel):修正部分文案,增加对于错误信息的JSON输出定义。

This commit is contained in:
徐涛 2022-08-17 14:05:38 +08:00
parent 592e93b2c9
commit 21803bf832

View File

@ -25,9 +25,9 @@ type ExcelAnalyzer[T any] struct {
}
type ExcelAnalysisError struct {
Row int
Col int
Err error
Row int `json:"row"`
Col int `json:"col"`
Err error `json:"error"`
}
func NewColumnRecognizer(tag string, patterns ...string) ColumnRecognizer {
@ -137,7 +137,7 @@ func (a *ExcelAnalyzer[T]) Analysis(bean T) ([]T, []ExcelAnalysisError) {
} else {
v, err := strconv.Atoi(matchValue)
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)
} else {
actualField.SetInt(int64(v))