作者 yangfu

导出共创用户列表

... ... @@ -34,3 +34,23 @@ func (srv ExcelDataService) ExportCompanyUser(companyUserListQuery *query.Compan
}
return ExportCompanyUserData(result.Users), nil
}
// 导出共创用户信息列表
func (srv ExcelDataService) ExportCooperationUser(companyUserListQuery *query.CompanyUserListQuery) (ExportCooperationUserData, error) {
creationUserGateway := allied_creation_user.NewHttplibAlliedCreationUser(companyUserListQuery.Operator)
result, err := creationUserGateway.UserSearch(allied_creation_user.ReqUserSearch{
Limit: 10000,
CompanyId: companyUserListQuery.Operator.CompanyId,
OrganizationId: 0,
DepartmentId: 0,
UserName: companyUserListQuery.UserName,
DepName: companyUserListQuery.DepartmentName,
Phone: "",
UserType: domain.UserTypeCooperation,
InOrgIds: companyUserListQuery.Operator.OrgIds,
})
if err != nil {
return ExportCooperationUserData{}, fmt.Errorf("获取企业用户数据失败:%w", err)
}
return ExportCooperationUserData(result.Users), nil
}
... ...
... ... @@ -68,3 +68,48 @@ func (data ExportCompanyUserData) DataListLen() int {
func (data ExportCompanyUserData) TableTitle() []string {
return nil
}
//exportCompanyUserData 导出共创用户数据
type ExportCooperationUserData []allied_creation_user.UserDetail
var _ excel.ExcelMaker = (*ExportCooperationUserData)(nil)
func (data ExportCooperationUserData) DataFieldList() []excel.DataField {
return []excel.DataField{
{EnName: "UserCode", CnName: "用户编码"},
{EnName: "UserName", CnName: "用户姓名"},
{EnName: "CooperationCompany", CnName: "合作公司"},
{EnName: "CooperationDeadline", CnName: "合作到期"},
{EnName: "Phone", CnName: "手机号"},
{EnName: "Email", CnName: "邮箱"},
}
}
func (data ExportCooperationUserData) CellValue(index int, enName string) (value interface{}) {
if index > data.DataListLen() {
return ""
}
switch enName {
case "UserCode":
return data[index].UserCode
case "UserName":
return data[index].UserInfo.UserName
case "CooperationCompany":
return data[index].CooperationInfo.CooperationCompany
case "CooperationDeadline":
return data[index].CooperationInfo.CooperationDeadline.Format("2006-01-02")
case "Phone":
return data[index].UserInfo.Phone
case "Email":
return data[index].UserInfo.Email
}
return nil
}
func (data ExportCooperationUserData) DataListLen() int {
return len(data)
}
func (data ExportCooperationUserData) TableTitle() []string {
return nil
}
... ...
... ... @@ -52,3 +52,30 @@ func (controller ExcelDataController) ExportCompanyUser() {
}
controller.responseExcelByFile(controller.Ctx, excelTool, "导出公司用户")
}
//导出共创用户
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, "导出共创用户")
}
... ...
... ... @@ -7,4 +7,5 @@ import (
func init() {
web.Router("/v1/web/excel/export/company-user", &web_client.ExcelDataController{}, "Post:ExportCompanyUser")
web.Router("/v1/web/excel/export/cooperation-user", &web_client.ExcelDataController{}, "Post:ExportCooperationUser")
}
... ...