chore: 并入 iotlcm-admin-svr 历史到 admin-svr/(原提交 49818c6)

This commit is contained in:
MiFaZhan
2026-11-02 13:27:59 +08:00
1250 changed files with 154111 additions and 0 deletions
@@ -0,0 +1,50 @@
package unsub
import (
"context"
"io"
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/batchimport"
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/library/batchinput/excel"
)
func ParseExcelFileRows(ctx context.Context, filePath string) ([]batchimport.Row, error) {
parsedRows, err := excel.ParseFile(ctx, filePath, excel.ParseOptions{
RequiredHeaders: []string{"ICCID"},
})
if err != nil {
return nil, err
}
return toBatchRows(parsedRows), nil
}
func ParseExcelRows(ctx context.Context, reader io.Reader) ([]*Row, error) {
parsedRows, err := excel.ParseReader(ctx, reader, excel.ParseOptions{
RequiredHeaders: []string{"ICCID"},
})
if err != nil {
return nil, err
}
return toRows(parsedRows), nil
}
func toBatchRows(parsedRows []excel.ParsedRow) []batchimport.Row {
rows := toRows(parsedRows)
result := make([]batchimport.Row, 0, len(rows))
for _, row := range rows {
result = append(result, row)
}
return result
}
func toRows(parsedRows []excel.ParsedRow) []*Row {
rows := make([]*Row, 0, len(parsedRows))
for _, parsed := range parsedRows {
rows = append(rows, &Row{
RowNo: parsed.RowNo,
Iccid: excel.Field(parsed, "ICCID"),
Msisdn: excel.Field(parsed, "MSISDN"),
Imsi: excel.Field(parsed, "IMSI"),
})
}
return rows
}