|
|
@@ -199,6 +199,9 @@ func (s PartnerCompanyContactService) ExcelUpload(ctx context.Context, req *mode
|
|
|
return myerrors.TipsError(fmt.Sprintf("下载 excel 异常 %s", err.Error()))
|
|
|
}
|
|
|
contact, err := s.ParseExcel(req.PartnerId, b)
|
|
|
+ // err = ioutil.WriteFile("text.xlsx", b, 777)
|
|
|
+ // fmt.Println(err)
|
|
|
+
|
|
|
if err != nil {
|
|
|
return myerrors.TipsError(fmt.Sprintf("解析 excel 异常 %s", err.Error()))
|
|
|
}
|
|
|
@@ -220,15 +223,18 @@ func (s PartnerCompanyContactService) ParseExcel(partnerId int, b []byte) ([]mod
|
|
|
contact := []model.PartnerCompanyContact{}
|
|
|
for rown, row := range rows[1:] {
|
|
|
rown += 1
|
|
|
- if len(row) < 5 {
|
|
|
- return nil, fmt.Errorf("excel 格式错误:列数小于5列")
|
|
|
+ if len(row) < 4 {
|
|
|
+ return nil, fmt.Errorf("excel 格式错误:列数小于4列")
|
|
|
}
|
|
|
|
|
|
name := strings.TrimSpace(row[0])
|
|
|
post := strings.TrimSpace(row[1])
|
|
|
contactWay := strings.TrimSpace(row[2])
|
|
|
territory := strings.TrimSpace(row[3])
|
|
|
- remark := strings.TrimSpace(row[4])
|
|
|
+ var remark string
|
|
|
+ if len(row) > 4 {
|
|
|
+ remark = strings.TrimSpace(row[4])
|
|
|
+ }
|
|
|
contact = append(contact, model.PartnerCompanyContact{
|
|
|
PartnerId: partnerId,
|
|
|
Name: name,
|