|
|
package service
|
|
|
|
|
|
import (
|
|
|
"github.com/linmadan/egglib-go/utils/excel"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
|
|
|
)
|
|
|
|
|
|
//exportCompanyUserData 导出公司用户数据
|
|
|
type ExportCompanyUserData []allied_creation_user.UserDetail
|
|
|
|
|
|
var _ excel.ExcelMaker = (*ExportCompanyUserData)(nil)
|
|
|
|
|
|
func (data ExportCompanyUserData) DataFieldList() []excel.DataField {
|
|
|
return []excel.DataField{
|
|
|
{EnName: "UserCode", CnName: "用户编码"},
|
|
|
{EnName: "UserName", CnName: "用户姓名"},
|
|
|
{EnName: "Phone", CnName: "手机号"},
|
|
|
{EnName: "DepartmentName", CnName: "所属部门"},
|
|
|
{EnName: "EnableStatus", CnName: "状态"},
|
|
|
{EnName: "OrgName", CnName: "组织机构"},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (data ExportCompanyUserData) 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 "Phone":
|
|
|
return data[index].UserInfo.Phone
|
|
|
case "DepartmentName":
|
|
|
if data[index].Department != nil {
|
|
|
return data[index].Department.DepartmentName
|
|
|
} else {
|
|
|
return ""
|
|
|
}
|
|
|
case "EnableStatus":
|
|
|
status := data[index].EnableStatus
|
|
|
statusName := ""
|
|
|
// 状态(1:启用 2:禁用 3:注销)
|
|
|
switch status {
|
|
|
case 1:
|
|
|
statusName = "启用"
|
|
|
case 2:
|
|
|
statusName = "禁用"
|
|
|
case 3:
|
|
|
statusName = "注销"
|
|
|
}
|
|
|
return statusName
|
|
|
case "OrgName":
|
|
|
if data[index].Org != nil {
|
|
|
return data[index].Org.OrgName
|
|
|
} else {
|
|
|
return ""
|
|
|
}
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (data ExportCompanyUserData) DataListLen() int {
|
|
|
return len(data)
|
|
|
}
|
|
|
|
|
|
func (data ExportCompanyUserData) TableTitle() []string {
|
|
|
return nil
|
|
|
} |
|
|
package service
|
|
|
|
|
|
import (
|
|
|
"github.com/linmadan/egglib-go/utils/excel"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
|
|
|
)
|
|
|
|
|
|
//exportCompanyUserData 导出公司用户数据
|
|
|
type ExportCompanyUserData []allied_creation_user.UserDetail
|
|
|
|
|
|
var _ excel.ExcelMaker = (*ExportCompanyUserData)(nil)
|
|
|
|
|
|
func (data ExportCompanyUserData) DataFieldList() []excel.DataField {
|
|
|
return []excel.DataField{
|
|
|
{EnName: "UserCode", CnName: "用户编码"},
|
|
|
{EnName: "UserName", CnName: "用户姓名"},
|
|
|
{EnName: "Phone", CnName: "手机号"},
|
|
|
{EnName: "DepartmentName", CnName: "所属部门"},
|
|
|
{EnName: "EnableStatus", CnName: "状态"},
|
|
|
{EnName: "OrgName", CnName: "组织机构"},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
func (data ExportCompanyUserData) 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 "Phone":
|
|
|
return data[index].UserInfo.Phone
|
|
|
case "DepartmentName":
|
|
|
if data[index].Department != nil {
|
|
|
return data[index].Department.DepartmentName
|
|
|
} else {
|
|
|
return ""
|
|
|
}
|
|
|
case "EnableStatus":
|
|
|
status := data[index].EnableStatus
|
|
|
statusName := ""
|
|
|
// 状态(1:启用 2:禁用 3:注销)
|
|
|
switch status {
|
|
|
case 1:
|
|
|
statusName = "启用"
|
|
|
case 2:
|
|
|
statusName = "禁用"
|
|
|
case 3:
|
|
|
statusName = "注销"
|
|
|
}
|
|
|
return statusName
|
|
|
case "OrgName":
|
|
|
if data[index].Org != nil {
|
|
|
return data[index].Org.OrgName
|
|
|
} else {
|
|
|
return ""
|
|
|
}
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (data ExportCompanyUserData) DataListLen() int {
|
|
|
return len(data)
|
|
|
}
|
|
|
|
|
|
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
|
|
|
} |
...
|
...
|
|