refactor(deps):将一些工具函数用工具库替换。

This commit is contained in:
徐涛
2022-08-21 12:59:16 +08:00
parent 6edee68df6
commit dc9b0849e1
15 changed files with 84 additions and 151 deletions

View File

@@ -1,7 +1,7 @@
package excel
import (
"electricity_bill_calc/utils"
"electricity_bill_calc/tools"
"encoding/json"
"fmt"
"io"
@@ -9,6 +9,7 @@ import (
"strconv"
"strings"
"github.com/samber/lo"
"github.com/shopspring/decimal"
"github.com/xuri/excelize/v2"
)
@@ -52,9 +53,9 @@ func (r *ColumnRecognizer) Recognize(cellValue string) bool {
for _, p := range r.Pattern {
matches = append(matches, strings.Contains(cellValue, p))
}
return utils.Reduce(matches, true, func(acc, elem bool) bool {
return lo.Reduce(matches, func(acc, elem bool, index int) bool {
return acc && elem
})
}, true)
}
func NewExcelAnalyzer[T any](file io.Reader, recognizers []*ColumnRecognizer) (*ExcelAnalyzer[T], error) {
@@ -154,7 +155,7 @@ func (a *ExcelAnalyzer[T]) Analysis(bean T) ([]T, []ExcelAnalysisError) {
}
}
case "bool":
if utils.ContainsInsensitive(matchValue, []string{"是", "yes", "y", "true", "t"}) {
if tools.ContainsInsensitive(matchValue, []string{"是", "yes", "y", "true", "t"}) {
actualField.SetBool(true)
} else {
actualField.SetBool(false)