forked from free-lancers/electricity_bill_calc_service
refactor(deps):将一些工具函数用工具库替换。
This commit is contained in:
@@ -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)
|
||||
|
Reference in New Issue
Block a user