作者 yangfu

导入修改

@@ -182,13 +182,13 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD @@ -182,13 +182,13 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD
182 excelImport := excel.NewExcelImport() 182 excelImport := excel.NewExcelImport()
183 excelImport.RowBegin = 3 //第二行开始读取 183 excelImport.RowBegin = 3 //第二行开始读取
184 excelImport.DataFields = []excel.DataField{ 184 excelImport.DataFields = []excel.DataField{
185 - {EnName: "userCode", CnName: "*用户编"}, 185 + {EnName: "userCode", CnName: "*用户编"},
186 {EnName: "userName", CnName: "*用户姓名"}, 186 {EnName: "userName", CnName: "*用户姓名"},
187 {EnName: "org", CnName: "*组织机构"}, 187 {EnName: "org", CnName: "*组织机构"},
188 {EnName: "department", CnName: "*所属部门"}, 188 {EnName: "department", CnName: "*所属部门"},
  189 + {EnName: "enableStatus", CnName: "*用户状态"},
189 {EnName: "phone", CnName: "*手机号"}, 190 {EnName: "phone", CnName: "*手机号"},
190 {EnName: "email", CnName: "邮箱"}, 191 {EnName: "email", CnName: "邮箱"},
191 - {EnName: "enableStatus", CnName: "状态"},  
192 } 192 }
193 excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader) 193 excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
194 if err != nil { 194 if err != nil {
@@ -229,9 +229,9 @@ func (srv ExcelDataService) ImportOrganization(importDataCommand *command.Import @@ -229,9 +229,9 @@ func (srv ExcelDataService) ImportOrganization(importDataCommand *command.Import
229 excelImport := excel.NewExcelImport() 229 excelImport := excel.NewExcelImport()
230 excelImport.RowBegin = 3 //第二行开始读取 230 excelImport.RowBegin = 3 //第二行开始读取
231 excelImport.DataFields = []excel.DataField{ 231 excelImport.DataFields = []excel.DataField{
232 - {EnName: "OrgCode", CnName: "*部门编码"},  
233 - {EnName: "OrgName", CnName: "*部门名称"},  
234 - {EnName: "ParentOrgCode", CnName: "*上级部门编码"}, 232 + {EnName: "orgCode", CnName: "*部门编码"},
  233 + {EnName: "orgName", CnName: "*部门名称"},
  234 + {EnName: "parentOrgCode", CnName: "*上级部门编码"},
235 } 235 }
236 excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader) 236 excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
237 if err != nil { 237 if err != nil {
@@ -241,9 +241,9 @@ func (srv ExcelDataService) ImportOrganization(importDataCommand *command.Import @@ -241,9 +241,9 @@ func (srv ExcelDataService) ImportOrganization(importDataCommand *command.Import
241 for _, v := range excelData { 241 for _, v := range excelData {
242 item := allied_creation_user.BatchAddOrgItem{ 242 item := allied_creation_user.BatchAddOrgItem{
243 CompanyId: importDataCommand.Operator.CompanyId, 243 CompanyId: importDataCommand.Operator.CompanyId,
244 - OrgCode: v["OrgCode"],  
245 - OrgName: v["OrgName"],  
246 - ParentOrgCode: v["ParentOrgCode"], 244 + OrgCode: v["orgCode"],
  245 + OrgName: v["orgName"],
  246 + ParentOrgCode: v["parentOrgCode"],
247 } 247 }
248 items = append(items, item) 248 items = append(items, item)
249 } 249 }
@@ -254,7 +254,7 @@ func (srv ExcelDataService) ImportOrganization(importDataCommand *command.Import @@ -254,7 +254,7 @@ func (srv ExcelDataService) ImportOrganization(importDataCommand *command.Import
254 if err != nil { 254 if err != nil {
255 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error()) 255 return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
256 } 256 }
257 - return result, nil 257 + return srv.importResultWithHeader(excelImport.DataFields, result.FailRows, len(excelData)), nil
258 } 258 }
259 259
260 // 导入结果 260 // 导入结果
@@ -284,11 +284,11 @@ func (srv ExcelDataService) importResultWithHeader(headers []excel.DataField, fa @@ -284,11 +284,11 @@ func (srv ExcelDataService) importResultWithHeader(headers []excel.DataField, fa
284 // ImportCompanyUser 导入公司用户信息 284 // ImportCompanyUser 导入公司用户信息
285 func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.ImportDataCommand) (interface{}, error) { 285 func (srv ExcelDataService) FileImportTemplate(importDataCommand *command.ImportDataCommand) (interface{}, error) {
286 var mapTemplate = map[string]string{ 286 var mapTemplate = map[string]string{
287 - domain.TemplateCompanyUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx", 287 + domain.ImportCompanyUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx",
288 // 模板待更新 288 // 模板待更新
289 - domain.TemplateOrganization: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx",  
290 - domain.TemplateCooperationUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx",  
291 - domain.TemplateDividendsOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx", 289 + domain.ImportOrganization: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx",
  290 + domain.ImportCooperationUser: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx",
  291 + domain.ImportDividendsOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx",
292 domain.ImportDividendsReturnOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx", 292 domain.ImportDividendsReturnOrders: "https://timeless-world.oss-cn-shenzhen.aliyuncs.com/open-api/dev_online/20210909/object/1631171021_baB6y5zdpwC2WnsHFQhKC3dkQEaAYMNZ.xlsx",
293 } 293 }
294 var url string 294 var url string
@@ -53,7 +53,7 @@ const ( @@ -53,7 +53,7 @@ const (
53 // 导入公司用户 53 // 导入公司用户
54 ImportCompanyUser = "ADMIN_SYSTEM-MANAGE_BASE_USER" 54 ImportCompanyUser = "ADMIN_SYSTEM-MANAGE_BASE_USER"
55 // 导入公司组织 55 // 导入公司组织
56 - ImportOrganization = "ImportOrganization" 56 + ImportOrganization = "ADMIN_SYSTEM-MANAGE_BASE_DEPARTMENT"
57 // 导入共创用户 57 // 导入共创用户
58 ImportCooperationUser = "ADMIN_SYSTEM-MANAGE_BASE_ALLIED-USER" 58 ImportCooperationUser = "ADMIN_SYSTEM-MANAGE_BASE_ALLIED-USER"
59 59
@@ -62,18 +62,3 @@ const ( @@ -62,18 +62,3 @@ const (
62 // 导入退货订单 62 // 导入退货订单
63 ImportDividendsReturnOrders = "BUSINESS_ALLIED-CREATION_BONUS_RETURN" 63 ImportDividendsReturnOrders = "BUSINESS_ALLIED-CREATION_BONUS_RETURN"
64 ) 64 )
65 -  
66 -//excel 导入模板  
67 -const (  
68 - // 导入公司用户  
69 - TemplateCompanyUser = "ADMIN_SYSTEM-MANAGE_BASE_USER"  
70 - // 导入公司组织  
71 - TemplateOrganization = "TemplateOrganization"  
72 - // 导入共创用户  
73 - TemplateCooperationUser = "ADMIN_SYSTEM-MANAGE_BASE_ALLIED-USER"  
74 -  
75 - // 分红订单模板  
76 - TemplateDividendsOrders = "BUSINESS_ALLIED-CREATION_BONUS_ORDER"  
77 - // 导入退货订单  
78 - TemplateDividendsReturnOrders = "BUSINESS_ALLIED-CREATION_BONUS_RETURN"  
79 -)  
@@ -226,7 +226,7 @@ func (gateway HttplibAlliedCreationUser) OrgSearch(param ReqOrgSearch) (*DataOrg @@ -226,7 +226,7 @@ func (gateway HttplibAlliedCreationUser) OrgSearch(param ReqOrgSearch) (*DataOrg
226 return &data, err 226 return &data, err
227 } 227 }
228 228
229 -func (gateway HttplibAlliedCreationUser) OrgBatchAdd(param ReqBatchAddOrg) (*DataBatchAddOrg, error) { 229 +func (gateway HttplibAlliedCreationUser) OrgBatchAdd(param ReqBatchAddOrg) (*DataImportResponse, error) {
230 url := fmt.Sprintf("%s%s", gateway.baseUrL, "/org/batch-add") 230 url := fmt.Sprintf("%s%s", gateway.baseUrL, "/org/batch-add")
231 method := "post" 231 method := "post"
232 req := gateway.CreateRequest(url, method) 232 req := gateway.CreateRequest(url, method)
@@ -252,7 +252,7 @@ func (gateway HttplibAlliedCreationUser) OrgBatchAdd(param ReqBatchAddOrg) (*Dat @@ -252,7 +252,7 @@ func (gateway HttplibAlliedCreationUser) OrgBatchAdd(param ReqBatchAddOrg) (*Dat
252 if err != nil { 252 if err != nil {
253 return nil, fmt.Errorf("解析批量添加用户:%w", err) 253 return nil, fmt.Errorf("解析批量添加用户:%w", err)
254 } 254 }
255 - var data DataBatchAddOrg 255 + var data DataImportResponse
256 err = gateway.GetResponseData(result, &data) 256 err = gateway.GetResponseData(result, &data)
257 return &data, err 257 return &data, err
258 } 258 }
1 package web_client 1 package web_client
2 2
3 import ( 3 import (
  4 + "fmt"
  5 + "io"
4 "strings" 6 "strings"
5 7
6 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain" 8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
@@ -43,7 +45,7 @@ func (controller *ExcelDataController) fieldValueAllEmpty(param map[string]strin @@ -43,7 +45,7 @@ func (controller *ExcelDataController) fieldValueAllEmpty(param map[string]strin
43 return isAllEmpty 45 return isAllEmpty
44 } 46 }
45 47
46 -//导出公司用户 48 +// ExportCompanyUser 导出公司用户
47 func (controller ExcelDataController) ExportCompanyUser() { 49 func (controller ExcelDataController) ExportCompanyUser() {
48 excelService := service.NewExcelDataService(nil) 50 excelService := service.NewExcelDataService(nil)
49 companyUserListQuery := &query.CompanyUserListQuery{} 51 companyUserListQuery := &query.CompanyUserListQuery{}
@@ -70,7 +72,7 @@ func (controller ExcelDataController) ExportCompanyUser() { @@ -70,7 +72,7 @@ func (controller ExcelDataController) ExportCompanyUser() {
70 controller.responseExcelByFile(controller.Ctx, excelTool, "导出公司用户") 72 controller.responseExcelByFile(controller.Ctx, excelTool, "导出公司用户")
71 } 73 }
72 74
73 -//导出共创用户 75 +// ExportCooperationUser 导出共创用户
74 func (controller ExcelDataController) ExportCooperationUser() { 76 func (controller ExcelDataController) ExportCooperationUser() {
75 excelService := service.NewExcelDataService(nil) 77 excelService := service.NewExcelDataService(nil)
76 companyUserListQuery := &query.CompanyUserListQuery{} 78 companyUserListQuery := &query.CompanyUserListQuery{}
@@ -97,7 +99,7 @@ func (controller ExcelDataController) ExportCooperationUser() { @@ -97,7 +99,7 @@ func (controller ExcelDataController) ExportCooperationUser() {
97 controller.responseExcelByFile(controller.Ctx, excelTool, "导出共创用户") 99 controller.responseExcelByFile(controller.Ctx, excelTool, "导出共创用户")
98 } 100 }
99 101
100 -// ImportDividendsOrder TODO 导入分红订单 102 +// ImportDividendsOrder 导入分红订单
101 func (controller ExcelDataController) ImportDividendsOrder() { 103 func (controller ExcelDataController) ImportDividendsOrder() {
102 importDividendsOrder(controller) 104 importDividendsOrder(controller)
103 } 105 }
@@ -223,95 +225,51 @@ func importDividendsReturnedOrder(controller ExcelDataController) { @@ -223,95 +225,51 @@ func importDividendsReturnedOrder(controller ExcelDataController) {
223 controller.Response(result, nil) 225 controller.Response(result, nil)
224 } 226 }
225 227
226 -func (controller ExcelDataController) ImportCompanyUser() {  
227 - importCompanyUser(controller)  
228 -}  
229 -func importCompanyUser(controller ExcelDataController) {  
230 - excelService := service.NewExcelDataService(nil)  
231 - r, err := controller.GetExcelFile()  
232 - if err != nil {  
233 - controller.Response(nil, err)  
234 - return  
235 - }  
236 - cmd := &command.ImportDataCommand{}  
237 - cmd.Operator = controller.GetOperator()  
238 - cmd.Reader = r  
239 - data, err := excelService.ImportCompanyUser(cmd)  
240 - controller.Response(data, err)  
241 -}  
242 -  
243 -func (controller ExcelDataController) ImportCooperationUser() {  
244 - importCooperationUser(controller)  
245 -}  
246 -func importCooperationUser(controller ExcelDataController) {  
247 - excelService := service.NewExcelDataService(nil)  
248 - r, err := controller.GetExcelFile()  
249 - if err != nil {  
250 - controller.Response(nil, err)  
251 - return 228 +// FileImport 文件导入
  229 +func (controller ExcelDataController) FileImport() {
  230 + code := controller.GetString("code")
  231 + switch code {
  232 + case domain.ImportDividendsOrders:
  233 + importDividendsOrder(controller)
  234 + case domain.ImportDividendsReturnOrders:
  235 + importDividendsReturnedOrder(controller)
  236 + default:
  237 + defaultImport(controller)
252 } 238 }
253 - cmd := &command.ImportDataCommand{}  
254 - cmd.Operator = controller.GetOperator()  
255 - cmd.Reader = r  
256 - data, err := excelService.ImportCooperationUser(cmd)  
257 - controller.Response(data, err)  
258 } 239 }
259 240
260 -func importOrganization(controller ExcelDataController) { 241 +func defaultImport(controller ExcelDataController) {
  242 + var (
  243 + data interface{}
  244 + err error
  245 + r io.Reader
  246 + )
261 excelService := service.NewExcelDataService(nil) 247 excelService := service.NewExcelDataService(nil)
262 - r, err := controller.GetExcelFile() 248 + r, err = controller.GetExcelFile()
263 if err != nil { 249 if err != nil {
264 controller.Response(nil, err) 250 controller.Response(nil, err)
265 return 251 return
266 } 252 }
267 cmd := &command.ImportDataCommand{} 253 cmd := &command.ImportDataCommand{}
  254 + controller.ParseForm(cmd)
268 cmd.Operator = controller.GetOperator() 255 cmd.Operator = controller.GetOperator()
269 cmd.Reader = r 256 cmd.Reader = r
270 - data, err := excelService.ImportOrganization(cmd)  
271 - controller.Response(data, err)  
272 -}  
273 -  
274 -func (controller ExcelDataController) ImportOrganization() {  
275 - importOrganization(controller)  
276 -}  
277 -  
278 -func (controller ExcelDataController) FileImport() {  
279 - // excelService := service.NewExcelDataService(nil)  
280 - // r, err := controller.GetExcelFile()  
281 - // if err != nil {  
282 - // controller.Response(nil, err)  
283 - // return  
284 - // }  
285 - // cmd := &command.ImportDataCommand{}  
286 - //controller.Unmarshal(cmd)  
287 - // controller.ParseForm(cmd)  
288 - // cmd.Operator = controller.GetOperator()  
289 - // cmd.Reader = r  
290 - // var (  
291 - // data interface{}  
292 - // err error  
293 - // )  
294 - code := controller.GetString("code")  
295 - switch code { 257 + switch cmd.Code {
296 case domain.ImportCompanyUser: 258 case domain.ImportCompanyUser:
297 - importCompanyUser(controller) 259 + data, err = excelService.ImportCompanyUser(cmd)
298 case domain.ImportCooperationUser: 260 case domain.ImportCooperationUser:
299 - importCooperationUser(controller)  
300 - case domain.ImportDividendsOrders:  
301 - importDividendsOrder(controller)  
302 - case domain.ImportDividendsReturnOrders:  
303 - importDividendsReturnedOrder(controller) 261 + data, err = excelService.ImportCooperationUser(cmd)
304 case domain.ImportOrganization: 262 case domain.ImportOrganization:
305 - importOrganization(controller) 263 + data, err = excelService.ImportOrganization(cmd)
  264 + default:
  265 + err = fmt.Errorf("导入不存在 Code:%v", cmd.Code)
306 } 266 }
307 - // controller.Response(data, err) 267 + controller.Response(data, err)
308 } 268 }
309 269
310 func (controller ExcelDataController) FileImportTemplate() { 270 func (controller ExcelDataController) FileImportTemplate() {
311 -  
312 excelService := service.NewExcelDataService(nil) 271 excelService := service.NewExcelDataService(nil)
313 cmd := &command.ImportDataCommand{} 272 cmd := &command.ImportDataCommand{}
314 - //controller.Unmarshal(cmd)  
315 code := controller.GetString(":code") 273 code := controller.GetString(":code")
316 cmd.Code = code 274 cmd.Code = code
317 var data interface{} 275 var data interface{}
@@ -9,14 +9,9 @@ func init() { @@ -9,14 +9,9 @@ func init() {
9 web.Router("/v1/web/excel/export/company-user", &web_client.ExcelDataController{}, "Post:ExportCompanyUser") 9 web.Router("/v1/web/excel/export/company-user", &web_client.ExcelDataController{}, "Post:ExportCompanyUser")
10 web.Router("/v1/web/excel/export/cooperation-user", &web_client.ExcelDataController{}, "Post:ExportCooperationUser") 10 web.Router("/v1/web/excel/export/cooperation-user", &web_client.ExcelDataController{}, "Post:ExportCooperationUser")
11 11
12 - web.Router("/v1/web/excel/import/company-user", &web_client.ExcelDataController{}, "Post:ImportCompanyUser")  
13 - web.Router("/v1/web/excel/import/cooperation-user", &web_client.ExcelDataController{}, "Post:ImportCooperationUser")  
14 -  
15 web.Router("/v1/web/excel/import/dividends-orders", &web_client.ExcelDataController{}, "Post:ImportDividendsOrder") 12 web.Router("/v1/web/excel/import/dividends-orders", &web_client.ExcelDataController{}, "Post:ImportDividendsOrder")
16 web.Router("/v1/web/excel/import/dividends-returned-orders", &web_client.ExcelDataController{}, "Post:ImportDividendsReturnedOrder") 13 web.Router("/v1/web/excel/import/dividends-returned-orders", &web_client.ExcelDataController{}, "Post:ImportDividendsReturnedOrder")
17 14
18 - web.Router("/v1/web/excel/import/organization", &web_client.ExcelDataController{}, "Post:ImportOrganization")  
19 -  
20 web.Router("/v1/web/file-import", &web_client.ExcelDataController{}, "Post:FileImport") 15 web.Router("/v1/web/file-import", &web_client.ExcelDataController{}, "Post:FileImport")
21 web.Router("/v1/web/file-import-template/:code", &web_client.ExcelDataController{}, "Get:FileImportTemplate") 16 web.Router("/v1/web/file-import-template/:code", &web_client.ExcelDataController{}, "Get:FileImportTemplate")
22 } 17 }