正在显示
4 个修改的文件
包含
93 行增加
和
0 行删除
@@ -34,3 +34,23 @@ func (srv ExcelDataService) ExportCompanyUser(companyUserListQuery *query.Compan | @@ -34,3 +34,23 @@ func (srv ExcelDataService) ExportCompanyUser(companyUserListQuery *query.Compan | ||
34 | } | 34 | } |
35 | return ExportCompanyUserData(result.Users), nil | 35 | return ExportCompanyUserData(result.Users), nil |
36 | } | 36 | } |
37 | + | ||
38 | +// 导出共创用户信息列表 | ||
39 | +func (srv ExcelDataService) ExportCooperationUser(companyUserListQuery *query.CompanyUserListQuery) (ExportCooperationUserData, error) { | ||
40 | + creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(companyUserListQuery.Operator) | ||
41 | + result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{ | ||
42 | + Limit: 10000, | ||
43 | + CompanyId: companyUserListQuery.Operator.CompanyId, | ||
44 | + OrganizationId: 0, | ||
45 | + DepartmentId: 0, | ||
46 | + UserName: companyUserListQuery.UserName, | ||
47 | + DepName: companyUserListQuery.DepartmentName, | ||
48 | + Phone: "", | ||
49 | + UserType: domain.UserTypeCooperation, | ||
50 | + InOrgIds: companyUserListQuery.Operator.OrgIds, | ||
51 | + }) | ||
52 | + if err != nil { | ||
53 | + return ExportCooperationUserData{}, fmt.Errorf("获取企业用户数据失败:%w", err) | ||
54 | + } | ||
55 | + return ExportCooperationUserData(result.Users), nil | ||
56 | +} |
@@ -68,3 +68,48 @@ func (data ExportCompanyUserData) DataListLen() int { | @@ -68,3 +68,48 @@ func (data ExportCompanyUserData) DataListLen() int { | ||
68 | func (data ExportCompanyUserData) TableTitle() []string { | 68 | func (data ExportCompanyUserData) TableTitle() []string { |
69 | return nil | 69 | return nil |
70 | } | 70 | } |
71 | + | ||
72 | +//exportCompanyUserData 导出共创用户数据 | ||
73 | +type ExportCooperationUserData []allied_creation_user.UserDetail | ||
74 | + | ||
75 | +var _ excel.ExcelMaker = (*ExportCooperationUserData)(nil) | ||
76 | + | ||
77 | +func (data ExportCooperationUserData) DataFieldList() []excel.DataField { | ||
78 | + return []excel.DataField{ | ||
79 | + {EnName: "UserCode", CnName: "用户编码"}, | ||
80 | + {EnName: "UserName", CnName: "用户姓名"}, | ||
81 | + {EnName: "CooperationCompany", CnName: "合作公司"}, | ||
82 | + {EnName: "CooperationDeadline", CnName: "合作到期"}, | ||
83 | + {EnName: "Phone", CnName: "手机号"}, | ||
84 | + {EnName: "Email", CnName: "邮箱"}, | ||
85 | + } | ||
86 | +} | ||
87 | + | ||
88 | +func (data ExportCooperationUserData) CellValue(index int, enName string) (value interface{}) { | ||
89 | + if index > data.DataListLen() { | ||
90 | + return "" | ||
91 | + } | ||
92 | + switch enName { | ||
93 | + case "UserCode": | ||
94 | + return data[index].UserCode | ||
95 | + case "UserName": | ||
96 | + return data[index].UserInfo.UserName | ||
97 | + case "CooperationCompany": | ||
98 | + return data[index].CooperationInfo.CooperationCompany | ||
99 | + case "CooperationDeadline": | ||
100 | + return data[index].CooperationInfo.CooperationDeadline.Format("2006-01-02") | ||
101 | + case "Phone": | ||
102 | + return data[index].UserInfo.Phone | ||
103 | + case "Email": | ||
104 | + return data[index].UserInfo.Email | ||
105 | + } | ||
106 | + return nil | ||
107 | +} | ||
108 | + | ||
109 | +func (data ExportCooperationUserData) DataListLen() int { | ||
110 | + return len(data) | ||
111 | +} | ||
112 | + | ||
113 | +func (data ExportCooperationUserData) TableTitle() []string { | ||
114 | + return nil | ||
115 | +} |
@@ -52,3 +52,30 @@ func (controller ExcelDataController) ExportCompanyUser() { | @@ -52,3 +52,30 @@ func (controller ExcelDataController) ExportCompanyUser() { | ||
52 | } | 52 | } |
53 | controller.responseExcelByFile(controller.Ctx, excelTool, "导出公司用户") | 53 | controller.responseExcelByFile(controller.Ctx, excelTool, "导出公司用户") |
54 | } | 54 | } |
55 | + | ||
56 | +//导出共创用户 | ||
57 | +func (controller ExcelDataController) ExportCooperationUser() { | ||
58 | + excelService := service.NewExcelDataService(nil) | ||
59 | + companyUserListQuery := &query.CompanyUserListQuery{} | ||
60 | + err := controller.Unmarshal(companyUserListQuery) | ||
61 | + if err != nil { | ||
62 | + log.Logger.Debug("json err:" + err.Error()) | ||
63 | + controller.Response(nil, err) | ||
64 | + return | ||
65 | + } | ||
66 | + companyUserListQuery.Operator = controller.GetOperator() | ||
67 | + data, err := excelService.ExportCooperationUser(companyUserListQuery) | ||
68 | + if err != nil { | ||
69 | + log.Logger.Debug("excelService.ExportCompanyUser err:" + err.Error()) | ||
70 | + controller.Response(nil, err) | ||
71 | + return | ||
72 | + } | ||
73 | + excelTool := excel.NewExcelExport() | ||
74 | + err = excelTool.ExportData(data, "") | ||
75 | + if err != nil { | ||
76 | + log.Logger.Debug("excelTool.ExportData err:" + err.Error()) | ||
77 | + controller.Response(nil, err) | ||
78 | + return | ||
79 | + } | ||
80 | + controller.responseExcelByFile(controller.Ctx, excelTool, "导出共创用户") | ||
81 | +} |
@@ -7,4 +7,5 @@ import ( | @@ -7,4 +7,5 @@ import ( | ||
7 | 7 | ||
8 | func init() { | 8 | 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 | } | 11 | } |
-
请 注册 或 登录 后发表评论