作者 yangfu

导出模板

... ... @@ -280,3 +280,22 @@ func (srv ExcelDataService) importResultWithHeader(headers []excel.DataField, fa
}
return result
}
// ImportCompanyUser 导入公司用户信息
func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.ImportDataCommand) (interface{}, error) {
var mapTemplate = map[string]string{
domain.TemplateCompanyUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx",
// 模板待更新
domain.TemplateOrganization: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx",
domain.TemplateCooperationUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx",
domain.TemplateDividendsOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx",
}
var url string
var ok bool
if url, ok = mapTemplate[importDataCommand.Code]; !ok {
return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("模板:%v 不存在", importDataCommand.Code))
}
return map[string]string{
"url": url,
}, nil
}
... ...
... ... @@ -48,3 +48,27 @@ const (
MaxQueryRowCount = 1000
NormalQueryRowCount = 100
)
const (
// 导入公司用户
ImportCompanyUser = "ImportCompanyUser"
// 导入公司组织
ImportOrganization = "ImportOrganization"
// 导入共创用户
ImportCooperationUser = "ImportCooperationUser"
// 导入分红订单
ImportDividendsOrders = "ImportDividendsOrders"
)
const (
// 导入公司用户
TemplateCompanyUser = "TemplateCompanyUser"
// 导入公司组织
TemplateOrganization = "TemplateOrganization"
// 导入共创用户
TemplateCooperationUser = "TemplateCooperationUser"
// 分红订单模板
TemplateDividendsOrders = "TemplateDividendsOrders"
)
... ...
... ... @@ -2,6 +2,7 @@ package web_client
import (
"errors"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
"path/filepath"
"strings"
... ... @@ -283,8 +284,19 @@ func (controller ExcelDataController) FileImport() {
cmd.Reader = r
var data interface{}
switch cmd.Code {
case "ImportCompanyUser":
case domain.ImportCompanyUser:
data, err = excelService.ImportCompanyUser(cmd)
}
controller.Response(data, err)
}
func (controller ExcelDataController) FileImportTemplate() {
excelService := service.NewExcelDataService(nil)
cmd := &command.ImportDataCommand{}
//controller.Unmarshal(cmd)
code := controller.GetString(":code")
cmd.Code = code
var data interface{}
data, err := excelService.FileImportTemplate(cmd)
controller.Response(data, err)
}
... ...
... ... @@ -18,4 +18,5 @@ func init() {
web.Router("/v1/web/excel/import/organization", &web_client.ExcelDataController{}, "Post:ImportOrganization")
web.Router("/v1/web/file-import", &web_client.ExcelDataController{}, "Post:FileImport")
web.Router("/v1/web/file-import-template/:code", &web_client.ExcelDataController{}, "Get:FileImportTemplate")
}
... ...