...
|
...
|
@@ -5,13 +5,22 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
|
|
|
)
|
|
|
|
|
|
type DataFieldOptions struct {
|
|
|
EnName string `json:"enName"`
|
|
|
CnName string `json:"cnName"`
|
|
|
IsDefault bool `json:"isDefault"`
|
|
|
}
|
|
|
|
|
|
// ExportCompanyUserData 导出公司用户数据
|
|
|
type ExportCompanyUserData []allied_creation_user.UserDetail
|
|
|
type ExportCompanyUserData struct {
|
|
|
SourceData []allied_creation_user.UserDetail
|
|
|
SelectedField []string
|
|
|
}
|
|
|
|
|
|
var _ excel.ExcelMaker = (*ExportCompanyUserData)(nil)
|
|
|
|
|
|
func (data ExportCompanyUserData) DataFieldList() []excel.DataField {
|
|
|
return []excel.DataField{
|
|
|
func (data ExportCompanyUserData) AllFields() []DataFieldOptions {
|
|
|
return []DataFieldOptions{
|
|
|
{EnName: "UserCode", CnName: "用户编码"},
|
|
|
{EnName: "UserName", CnName: "用户姓名"},
|
|
|
{EnName: "Phone", CnName: "手机号"},
|
...
|
...
|
@@ -21,25 +30,42 @@ func (data ExportCompanyUserData) DataFieldList() []excel.DataField { |
|
|
}
|
|
|
}
|
|
|
|
|
|
func (data ExportCompanyUserData) DataFieldList() []excel.DataField {
|
|
|
fields := []excel.DataField{}
|
|
|
allFields := data.AllFields()
|
|
|
for _, value2 := range allFields {
|
|
|
if len(data.SelectedField) == 0 || value2.IsDefault {
|
|
|
fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
|
|
|
continue
|
|
|
}
|
|
|
for _, value3 := range data.SelectedField {
|
|
|
if value2.EnName == value3 {
|
|
|
fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return fields
|
|
|
}
|
|
|
|
|
|
func (data ExportCompanyUserData) CellValue(index int, enName string) (value interface{}) {
|
|
|
if index > data.DataListLen() {
|
|
|
return ""
|
|
|
}
|
|
|
switch enName {
|
|
|
case "UserCode":
|
|
|
return data[index].UserCode
|
|
|
return data.SourceData[index].UserCode
|
|
|
case "UserName":
|
|
|
return data[index].UserInfo.UserName
|
|
|
return data.SourceData[index].UserInfo.UserName
|
|
|
case "Phone":
|
|
|
return data[index].UserInfo.Phone
|
|
|
return data.SourceData[index].UserInfo.Phone
|
|
|
case "DepartmentName":
|
|
|
if data[index].Department != nil {
|
|
|
return data[index].Department.DepartmentName
|
|
|
if data.SourceData[index].Department != nil {
|
|
|
return data.SourceData[index].Department.DepartmentName
|
|
|
} else {
|
|
|
return ""
|
|
|
}
|
|
|
case "EnableStatus":
|
|
|
status := data[index].EnableStatus
|
|
|
status := data.SourceData[index].EnableStatus
|
|
|
statusName := ""
|
|
|
// 状态(1:启用 2:禁用 3:注销)
|
|
|
switch status {
|
...
|
...
|
@@ -52,8 +78,8 @@ func (data ExportCompanyUserData) CellValue(index int, enName string) (value int |
|
|
}
|
|
|
return statusName
|
|
|
case "OrgName":
|
|
|
if data[index].Org != nil {
|
|
|
return data[index].Org.OrgName
|
|
|
if data.SourceData[index].Org != nil {
|
|
|
return data.SourceData[index].Org.OrgName
|
|
|
} else {
|
|
|
return ""
|
|
|
}
|
...
|
...
|
@@ -62,7 +88,7 @@ func (data ExportCompanyUserData) CellValue(index int, enName string) (value int |
|
|
}
|
|
|
|
|
|
func (data ExportCompanyUserData) DataListLen() int {
|
|
|
return len(data)
|
|
|
return len(data.SourceData)
|
|
|
}
|
|
|
|
|
|
func (data ExportCompanyUserData) TableTitle() []string {
|
...
|
...
|
@@ -70,21 +96,39 @@ func (data ExportCompanyUserData) TableTitle() []string { |
|
|
}
|
|
|
|
|
|
//ExportCooperationUserData 导出共创用户数据
|
|
|
type ExportCooperationUserData []allied_creation_user.UserDetail
|
|
|
type ExportCooperationUserData struct {
|
|
|
SourceData []allied_creation_user.UserDetail
|
|
|
SelectedField []string
|
|
|
}
|
|
|
|
|
|
var _ excel.ExcelMaker = (*ExportCooperationUserData)(nil)
|
|
|
|
|
|
func (data ExportCooperationUserData) DataFieldList() []excel.DataField {
|
|
|
return []excel.DataField{
|
|
|
func (data ExportCooperationUserData) AllFields() []DataFieldOptions {
|
|
|
return []DataFieldOptions{
|
|
|
{EnName: "UserCode", CnName: "用户编码"},
|
|
|
{EnName: "UserName", CnName: "用户姓名"},
|
|
|
{EnName: "Phone", CnName: "手机号"},
|
|
|
{EnName: "CooperationCompany", CnName: "共创公司"},
|
|
|
{EnName: "CooperationDeadline", CnName: "共创到期"},
|
|
|
{EnName: "EnableStatus", CnName: "状态"},
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//{EnName: "Email", CnName: "邮箱"},
|
|
|
func (data ExportCooperationUserData) DataFieldList() []excel.DataField {
|
|
|
fields := []excel.DataField{}
|
|
|
allFields := data.AllFields()
|
|
|
for _, value2 := range allFields {
|
|
|
if len(data.SelectedField) == 0 || value2.IsDefault {
|
|
|
fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
|
|
|
continue
|
|
|
}
|
|
|
for _, value3 := range data.SelectedField {
|
|
|
if value2.EnName == value3 {
|
|
|
fields = append(fields, excel.DataField{EnName: value2.EnName, CnName: value2.CnName})
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return fields
|
|
|
}
|
|
|
|
|
|
func (data ExportCooperationUserData) CellValue(index int, enName string) (value interface{}) {
|
...
|
...
|
@@ -93,22 +137,22 @@ func (data ExportCooperationUserData) CellValue(index int, enName string) (value |
|
|
}
|
|
|
switch enName {
|
|
|
case "UserCode":
|
|
|
return data[index].UserCode
|
|
|
return data.SourceData[index].UserCode
|
|
|
case "UserName":
|
|
|
return data[index].UserInfo.UserName
|
|
|
return data.SourceData[index].UserInfo.UserName
|
|
|
case "CooperationCompany":
|
|
|
return data[index].CooperationInfo.CooperationCompany
|
|
|
return data.SourceData[index].CooperationInfo.CooperationCompany
|
|
|
case "CooperationDeadline":
|
|
|
if data[index].CooperationInfo.CooperationDeadline.IsZero() || data[index].CooperationInfo.CooperationDeadline.Unix() == 0 {
|
|
|
if data.SourceData[index].CooperationInfo.CooperationDeadline.IsZero() || data.SourceData[index].CooperationInfo.CooperationDeadline.Unix() == 0 {
|
|
|
return ""
|
|
|
}
|
|
|
return data[index].CooperationInfo.CooperationDeadline.Format("2006-01-02")
|
|
|
return data.SourceData[index].CooperationInfo.CooperationDeadline.Format("2006-01-02")
|
|
|
case "Phone":
|
|
|
return data[index].UserInfo.Phone
|
|
|
return data.SourceData[index].UserInfo.Phone
|
|
|
case "Email":
|
|
|
return data[index].UserInfo.Email
|
|
|
return data.SourceData[index].UserInfo.Email
|
|
|
case "EnableStatus":
|
|
|
status := data[index].EnableStatus
|
|
|
status := data.SourceData[index].EnableStatus
|
|
|
statusName := ""
|
|
|
// 状态(1:启用 2:禁用 3:注销)
|
|
|
switch status {
|
...
|
...
|
@@ -125,7 +169,7 @@ func (data ExportCooperationUserData) CellValue(index int, enName string) (value |
|
|
}
|
|
|
|
|
|
func (data ExportCooperationUserData) DataListLen() int {
|
|
|
return len(data)
|
|
|
return len(data.SourceData)
|
|
|
}
|
|
|
|
|
|
func (data ExportCooperationUserData) TableTitle() []string {
|
...
|
...
|
|