feat:完成企业和专家导入功能,缺少保存数据表中
This commit is contained in:
@ -396,7 +396,7 @@ func (*Manage) EnterpriseDelete(c *gin.Context) {
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
// ImportCompany 导入公司
|
||||
// ImportCompany 导入公司模板信息
|
||||
func (*Manage) ImportCompany(c *gin.Context) {
|
||||
file, err := c.FormFile("file")
|
||||
|
||||
@ -407,20 +407,41 @@ func (*Manage) ImportCompany(c *gin.Context) {
|
||||
resp := new(lib.UploadHandle)
|
||||
|
||||
if resp, err = lib.Upload(config2.SystemConfig[config2.UploadPath], []string{"xlsx"},
|
||||
0, true).Handle()(file, config2.SystemConfig[config2.SysImageDomain]); err != nil {
|
||||
0, false).Handle()(file, config2.SystemConfig[config2.SysImageDomain]); err != nil {
|
||||
api.APIFailure(err)(c)
|
||||
return
|
||||
}
|
||||
fmt.Println(resp)
|
||||
return
|
||||
if err = c.SaveUploadedFile(file, resp.RelativePath); err != nil {
|
||||
api.APIFailure(err)(c)
|
||||
return
|
||||
}
|
||||
api.APIResponse(nil)(c)
|
||||
fmt.Println(resp)
|
||||
//err := manage.NewCompany()(api.GetSession()(c).(*session.Admin)).Import(resp.RelativePath)
|
||||
err = manage.NewCompany()(nil).Import(resp.Filepath)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
||||
// ImportExpert 导入专家
|
||||
func (*Manage) ImportExpert(c *gin.Context) {
|
||||
file, err := c.FormFile("file")
|
||||
|
||||
if err != nil {
|
||||
api.APIFailure(err)(c)
|
||||
return
|
||||
}
|
||||
resp := new(lib.UploadHandle)
|
||||
|
||||
if resp, err = lib.Upload(config2.SystemConfig[config2.UploadPath], []string{"xlsx"},
|
||||
0, false).Handle()(file, config2.SystemConfig[config2.SysImageDomain]); err != nil {
|
||||
api.APIFailure(err)(c)
|
||||
return
|
||||
}
|
||||
if err = c.SaveUploadedFile(file, resp.RelativePath); err != nil {
|
||||
api.APIFailure(err)(c)
|
||||
return
|
||||
}
|
||||
fmt.Println(resp)
|
||||
//err := manage.NewCompany()(api.GetSession()(c).(*session.Admin)).Import(resp.RelativePath)
|
||||
err = manage.NewExpert()(nil).Import(resp.Filepath)
|
||||
api.APIResponse(err)(c)
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -8,8 +8,10 @@ import (
|
||||
"SciencesServer/app/service"
|
||||
"SciencesServer/app/session"
|
||||
config2 "SciencesServer/config"
|
||||
"SciencesServer/lib"
|
||||
"SciencesServer/utils"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
@ -53,6 +55,38 @@ type (
|
||||
*model.ManageExpertPatent
|
||||
IsBind bool `json:"is_bind"`
|
||||
}
|
||||
|
||||
// ExpertExcel 专家表格数据
|
||||
ExpertExcel struct {
|
||||
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:"详细地址"`
|
||||
Site string `json:"site" form:"所属站点"`
|
||||
Industry string `json:"industry" xlsx:"所属领域"`
|
||||
Research string `json:"research" xlsx:"所属单位"`
|
||||
Laboratory string `json:"laboratory" xlsx:"所属实验室"`
|
||||
School string `json:"school" xlsx:"毕业院校"`
|
||||
Keyword string `json:"keyword" xlsx:"关键词"`
|
||||
Education string `json:"education" xlsx:"最高学历"`
|
||||
Major string `json:"major" xlsx:"主修专业"`
|
||||
Job string `json:"job" xlsx:"职务"`
|
||||
WorkAt string `json:"work_at" xlsx:"从业时间"`
|
||||
Gender string `json:"gender" xlsx:"性别"`
|
||||
ResearchWhere string `json:"research_where" xlsx:"研究方向"`
|
||||
Mobile string `json:"mobile" xlsx:"手机号"`
|
||||
Introduce string `json:"introduce" xlsx:"个人简介"`
|
||||
Technology string `json:"technology" xlsx:"核心技术及产品"`
|
||||
Scene string `json:"scene" xlsx:"应用场景"`
|
||||
Tag1 string `json:"tag_1" xlsx:"代表成果及合作模式"`
|
||||
Tag2 string `json:"tag_2" xlsx:"承担科研项目"`
|
||||
Tag3 string `json:"tag_3" xlsx:"代表专利"`
|
||||
Tag4 string `json:"tag_4" xlsx:"代表论文"`
|
||||
Tag5 string `json:"tag_5" xlsx:"已合作企业"`
|
||||
Tag6 string `json:"tag_6" xlsx:"想合作企业"`
|
||||
Tag7 string `json:"tag_7" xlsx:"我的需求"`
|
||||
}
|
||||
)
|
||||
|
||||
// Instance 首页信息
|
||||
@ -307,6 +341,27 @@ func (c *Expert) PatentUnbind(id uint64, patentID []uint64) error {
|
||||
})
|
||||
}
|
||||
|
||||
// Import 导入数据
|
||||
func (c *Expert) Import(file string) error {
|
||||
excel := lib.NewExcel()
|
||||
err := excel.Import(strings.Replace(file, "/", "", 1), 1, 0)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
data := excel.Analysis(&ExpertExcel{})
|
||||
|
||||
//now := time.Now()
|
||||
|
||||
for _, v := range data {
|
||||
_data := v.(*ExpertExcel)
|
||||
// 所属领域
|
||||
//industrys := strings.Split(_data.Industry, "\n")
|
||||
fmt.Println(_data)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewExpert() ExpertHandle {
|
||||
return func(session *session.Admin) *Expert {
|
||||
return &Expert{session}
|
||||
|
@ -162,6 +162,7 @@ func registerAdminAPI(app *gin.Engine) {
|
||||
apiPrefix + "/v1/captcha",
|
||||
apiPrefix + "/v1/account/login",
|
||||
apiPrefix + "/v1/account/logout",
|
||||
apiPrefix + "/v1/manage/import/company",
|
||||
}...)))
|
||||
// 权限验证
|
||||
v1.Use(NeedPermission(AddSkipperURL([]string{
|
||||
|
Reference in New Issue
Block a user