feat:完成企业和专家导入功能,缺少保存数据表中
This commit is contained in:
@ -10,8 +10,8 @@ import (
|
||||
config2 "SciencesServer/config"
|
||||
"SciencesServer/lib"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Company struct {
|
||||
@ -46,7 +46,21 @@ type (
|
||||
|
||||
// CompanyExcel 公司企业表格信息
|
||||
CompanyExcel struct {
|
||||
Name string `json:"name" xlsx:"名称"`
|
||||
Name string `json:"name" xlsx:"企业名称"`
|
||||
Province string `json:"province" xlsx:"所在省"`
|
||||
City string `json:"city" xlsx:"所在市"`
|
||||
District string `json:"district" xlsx:"所在区"`
|
||||
Address string `json:"address" xlsx:"详细地址"`
|
||||
Code string `json:"code" xlsx:"信用代码"`
|
||||
RegisterAt string `json:"register_at" xlsx:"注册时间"`
|
||||
Industry string `json:"industry" xlsx:"所属领域"`
|
||||
Url string `json:"url" xlsx:"企业网站"`
|
||||
Introduce string `json:"introduce" xlsx:"企业简介"`
|
||||
Kind string `json:"kind" xlsx:"企业类型"`
|
||||
TechnologyScene string `json:"technology_scene" xlsx:"核心技术与产品及应用场景"`
|
||||
Keyword string `json:"keyword" xlsx:"关键词"`
|
||||
Contact string `json:"contact" xlsx:"联系人"` // 联系人
|
||||
ContactMobile string `json:"contact_mobile" xlsx:"联系电话"` // 联系方式
|
||||
}
|
||||
)
|
||||
|
||||
@ -216,17 +230,20 @@ func (c *Company) Detail(id uint64) (*CompanyDetail, error) {
|
||||
// Import 导入数据
|
||||
func (c *Company) Import(file string) error {
|
||||
excel := lib.NewExcel()
|
||||
err := excel.Import(strings.Replace(file, "/", "", 1), 0, 0)
|
||||
err := excel.Import(strings.Replace(file, "/", "", 1), 1, 0)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data := excel.Analysis(&CompanyExcel{})
|
||||
|
||||
now := time.Now()
|
||||
//now := time.Now()
|
||||
|
||||
for _, v := range data {
|
||||
_data := v.(*CompanyExcel)
|
||||
// 所属领域
|
||||
//industrys := strings.Split(_data.Industry, "\n")
|
||||
fmt.Println(_data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user