作者 yangfu

导出修改

... ... @@ -29,7 +29,7 @@ func (srv ExcelDataService) ExportCompanyUser(companyUserListQuery *query.Compan
}
// ExportCooperationUser 导出共创用户信息列表
func (srv ExcelDataService) ExportCooperationUser(companyUserListQuery *query.CompanyUserListQuery) (ExportCooperationUserData, error) {
func (srv ExcelDataService) ExportCooperationUser(companyUserListQuery *query.CooperationUserListQuery) (ExportCooperationUserData, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(companyUserListQuery.Operator)
result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
Limit: 10000,
... ... @@ -37,7 +37,7 @@ func (srv ExcelDataService) ExportCooperationUser(companyUserListQuery *query.Co
OrganizationId: 0,
DepartmentId: 0,
UserName: companyUserListQuery.UserName,
DepName: companyUserListQuery.DepartmentName,
CooperationCompany: companyUserListQuery.CooperationCompany,
Phone: "",
UserType: domain.UserTypeCooperation,
InOrgIds: companyUserListQuery.Operator.OrgIds,
... ...
... ... @@ -62,3 +62,10 @@ const (
// 导入退货订单
ImportDividendsReturnOrders = "BUSINESS_ALLIED-CREATION_BONUS_RETURN"
)
const (
// 导入公司用户
ExportCompanyUser = "ExportCompanyUser"
// 导入共创用户
ExportCooperationUser = "ExportCooperationUser"
)
... ...
... ... @@ -45,97 +45,6 @@ func (controller *ExcelDataController) fieldValueAllEmpty(param map[string]strin
return isAllEmpty
}
// ExportCompanyUser 导出公司用户
func (controller ExcelDataController) ExportCompanyUser() {
//excelService := service.NewExcelDataService(nil)
//companyUserListQuery := &query.CompanyUserListQuery{}
//err := controller.Unmarshal(companyUserListQuery)
//if err != nil {
// log.Logger.Debug("json err:" + err.Error())
// controller.Response(nil, err)
// return
//}
//companyUserListQuery.Operator = controller.GetOperator()
//data, err := excelService.ExportCompanyUser(companyUserListQuery)
//if err != nil {
// log.Logger.Debug("excelService.ExportCompanyUser err:" + err.Error())
// controller.Response(nil, err)
// return
//}
//excelTool := excel.NewExcelExport()
//err = excelTool.ExportData(data, "")
//if err != nil {
// log.Logger.Debug("excelTool.ExportData err:" + err.Error())
// controller.Response(nil, err)
// return
//}
//controller.responseExcelByFile(controller.Ctx, excelTool, "导出公司用户")
// 1.读取command
exportDataCommand := &command.ExportDataCommand{}
err := controller.Unmarshal(exportDataCommand)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
controller.Response(nil, err)
return
}
exportDataCommand.Operator = controller.GetOperator()
// 2.读取data
var data excel.ExcelMaker
var filename string
var excelService = service.NewExcelDataService(nil)
switch exportDataCommand.Code {
default:
companyUserListQuery := &query.CompanyUserListQuery{}
exportDataCommand.UnmarshalQuery(companyUserListQuery)
companyUserListQuery.Operator = exportDataCommand.Operator
data, err = excelService.ExportCompanyUser(companyUserListQuery)
filename = "导出公司用户"
}
if err != nil {
log.Logger.Debug("excelService.Export err:" + err.Error())
controller.Response(nil, err)
return
}
// 3.返回文件
excelTool := excel.NewExcelExport()
err = excelTool.ExportData(data, "")
if err != nil {
log.Logger.Debug("excelTool.ExportData err:" + err.Error())
controller.Response(nil, err)
return
}
controller.responseExcelByFile(controller.Ctx, excelTool, filename)
}
// ExportCooperationUser 导出共创用户
func (controller ExcelDataController) ExportCooperationUser() {
excelService := service.NewExcelDataService(nil)
companyUserListQuery := &query.CompanyUserListQuery{}
err := controller.Unmarshal(companyUserListQuery)
if err != nil {
log.Logger.Debug("json err:" + err.Error())
controller.Response(nil, err)
return
}
companyUserListQuery.Operator = controller.GetOperator()
data, err := excelService.ExportCooperationUser(companyUserListQuery)
if err != nil {
log.Logger.Debug("excelService.ExportCompanyUser err:" + err.Error())
controller.Response(nil, err)
return
}
excelTool := excel.NewExcelExport()
err = excelTool.ExportData(data, "")
if err != nil {
log.Logger.Debug("excelTool.ExportData err:" + err.Error())
controller.Response(nil, err)
return
}
controller.responseExcelByFile(controller.Ctx, excelTool, "导出共创用户")
}
// ImportDividendsOrder 导入分红订单
func (controller ExcelDataController) ImportDividendsOrder() {
importDividendsOrder(controller)
... ... @@ -316,6 +225,10 @@ func (controller ExcelDataController) FileImportTemplate() {
// FileExport 文件导出
func (controller ExcelDataController) FileExport() {
fileExport(controller, "")
}
func fileExport(controller ExcelDataController, code string) {
// 1.读取command
exportDataCommand := &command.ExportDataCommand{}
err := controller.Unmarshal(exportDataCommand)
... ... @@ -326,17 +239,28 @@ func (controller ExcelDataController) FileExport() {
}
exportDataCommand.Operator = controller.GetOperator()
if exportDataCommand.Code == "" && code != "" {
exportDataCommand.Code = code
}
// 2.读取data
var data excel.ExcelMaker
var filename string
var excelService = service.NewExcelDataService(nil)
switch exportDataCommand.Code {
default:
case domain.ExportCompanyUser:
companyUserListQuery := &query.CompanyUserListQuery{}
exportDataCommand.UnmarshalQuery(companyUserListQuery)
companyUserListQuery.Operator = exportDataCommand.Operator
data, err = excelService.ExportCompanyUser(companyUserListQuery)
filename = "导出公司用户"
case domain.ExportCooperationUser:
companyUserListQuery := &query.CooperationUserListQuery{}
exportDataCommand.UnmarshalQuery(companyUserListQuery)
companyUserListQuery.Operator = exportDataCommand.Operator
data, err = excelService.ExportCooperationUser(companyUserListQuery)
filename = "导出共创用户"
default:
err = fmt.Errorf("export type :%v not exists", exportDataCommand.Code)
}
if err != nil {
log.Logger.Debug("excelService.Export err:" + err.Error())
... ... @@ -354,3 +278,13 @@ func (controller ExcelDataController) FileExport() {
}
controller.responseExcelByFile(controller.Ctx, excelTool, filename)
}
// ExportCompanyUser 导出公司用户
func (controller ExcelDataController) ExportCompanyUser() {
fileExport(controller, domain.ExportCompanyUser)
}
// ExportCooperationUser 导出共创用户
func (controller ExcelDataController) ExportCooperationUser() {
fileExport(controller, domain.ExportCooperationUser)
}
... ...