...
|
...
|
@@ -182,13 +182,13 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
|
|
excelImport := excel.NewExcelImport()
|
|
|
excelImport.RowBegin = 2 //第二行开始读取
|
|
|
excelImport.DataFields = []excel.DataField{
|
|
|
{EnName: "UserCode", CnName: "*用户编号"},
|
|
|
{EnName: "UserName", CnName: "*用户姓名"},
|
|
|
{EnName: "Organization", CnName: "*组织机构"},
|
|
|
{EnName: "Department", CnName: "*所属部门"},
|
|
|
{EnName: "Phone", CnName: "*手机号"},
|
|
|
{EnName: "Email", CnName: "邮箱"},
|
|
|
{EnName: "Status", CnName: "状态"},
|
|
|
{EnName: "userCode", CnName: "*用户编号"},
|
|
|
{EnName: "userName", CnName: "*用户姓名"},
|
|
|
{EnName: "organization", CnName: "*组织机构"},
|
|
|
{EnName: "department", CnName: "*所属部门"},
|
|
|
{EnName: "phone", CnName: "*手机号"},
|
|
|
{EnName: "email", CnName: "邮箱"},
|
|
|
{EnName: "enableStatus", CnName: "状态"},
|
|
|
}
|
|
|
excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
|
|
|
if err != nil {
|
...
|
...
|
@@ -199,15 +199,15 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
|
|
item := allied_creation_user.BatchAddUserItem{
|
|
|
CompanyId: importDataCommand.Operator.CompanyId,
|
|
|
UserType: domain.UserTypeEmployee,
|
|
|
UserCode: v["UserCode"],
|
|
|
Org: v["Organization"],
|
|
|
Department: v["Department"],
|
|
|
UserName: v["UserName"],
|
|
|
Phone: v["Phone"],
|
|
|
Email: v["Email"],
|
|
|
UserCode: v["userCode"],
|
|
|
Org: v["organization"],
|
|
|
Department: v["department"],
|
|
|
UserName: v["userName"],
|
|
|
Phone: v["phone"],
|
|
|
Email: v["email"],
|
|
|
EnableStatus: domain.UserStatusEnable,
|
|
|
}
|
|
|
if status, ok := v["Status"]; ok {
|
|
|
if status, ok := v["status"]; ok {
|
|
|
if strings.TrimSpace(status) != "启用" {
|
|
|
item.EnableStatus = domain.UserStatusDisable
|
|
|
}
|
...
|
...
|
@@ -222,7 +222,15 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
return result, nil
|
|
|
return srv.importResultWithHeader(map[string]interface{}{
|
|
|
"userCode": "*用户编号",
|
|
|
"userName": "*用户姓名",
|
|
|
"organization": "*组织机构",
|
|
|
"department": "*所属部门",
|
|
|
"phone": "*手机号",
|
|
|
"email": "邮箱",
|
|
|
"enableStatus": "状态",
|
|
|
}, result.FailRows, len(excelData)), nil
|
|
|
}
|
|
|
|
|
|
func (srv ExcelDataService) ImportOrganization(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
...
|
...
|
@@ -256,3 +264,22 @@ func (srv ExcelDataService) ImportOrganization(importDataCommand *command.Import |
|
|
}
|
|
|
return result, nil
|
|
|
}
|
|
|
|
|
|
// 导入结果
|
|
|
func (srv ExcelDataService) importResultWithHeader(header interface{}, failRows []interface{}, totalRow int) interface{} {
|
|
|
var result = map[string]interface{}{
|
|
|
"successCount": 0,
|
|
|
"fail": struct{}{},
|
|
|
}
|
|
|
if len(failRows) == 0 {
|
|
|
result["successCount"] = totalRow
|
|
|
}
|
|
|
if len(failRows) > 0 {
|
|
|
fail := map[string]interface{}{
|
|
|
"body": failRows,
|
|
|
}
|
|
|
fail["header"] = header
|
|
|
result["fail"] = fail
|
|
|
}
|
|
|
return result
|
|
|
} |
...
|
...
|
|