|
@@ -7,6 +7,7 @@ import ( |
|
@@ -7,6 +7,7 @@ import ( |
7
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/command"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/command"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/query"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/query"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
|
|
|
10
|
+ "gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/domainService"
|
10
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
|
11
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
|
11
|
"strconv"
|
12
|
"strconv"
|
12
|
"time"
|
13
|
"time"
|
|
@@ -61,6 +62,10 @@ func (srv ExcelDataService) ExportCooperationUser(companyUserListQuery *query.Co |
|
@@ -61,6 +62,10 @@ func (srv ExcelDataService) ExportCooperationUser(companyUserListQuery *query.Co |
61
|
|
62
|
|
62
|
// ImportCompanyUser 导入公司用户信息
|
63
|
// ImportCompanyUser 导入公司用户信息
|
63
|
func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
64
|
func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
|
|
65
|
+ initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
|
|
|
66
|
+ if err != nil {
|
|
|
67
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
68
|
+ }
|
64
|
excelImport := excel.NewExcelImport()
|
69
|
excelImport := excel.NewExcelImport()
|
65
|
excelImport.RowBegin = 2 //第二行开始读取
|
70
|
excelImport.RowBegin = 2 //第二行开始读取
|
66
|
excelImport.DataFields = []excel.DataField{
|
71
|
excelImport.DataFields = []excel.DataField{
|
|
@@ -70,13 +75,13 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
|
@@ -70,13 +75,13 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
70
|
{EnName: "DepartmentID", CnName: "*所属部门"},
|
75
|
{EnName: "DepartmentID", CnName: "*所属部门"},
|
71
|
{EnName: "Phone", CnName: "*手机号"},
|
76
|
{EnName: "Phone", CnName: "*手机号"},
|
72
|
{EnName: "Email", CnName: "邮箱"},
|
77
|
{EnName: "Email", CnName: "邮箱"},
|
|
|
78
|
+ {EnName: "Status", CnName: "状态"},
|
73
|
}
|
79
|
}
|
74
|
excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
|
80
|
excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
|
75
|
if err != nil {
|
81
|
if err != nil {
|
76
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
82
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
77
|
}
|
83
|
}
|
78
|
users := make([]allied_creation_user.BatchAddUserItem, 0)
|
84
|
users := make([]allied_creation_user.BatchAddUserItem, 0)
|
79
|
- var fail int
|
|
|
80
|
for _, v := range excelData {
|
85
|
for _, v := range excelData {
|
81
|
item := allied_creation_user.BatchAddUserItem{
|
86
|
item := allied_creation_user.BatchAddUserItem{
|
82
|
CompanyID: importDataCommand.Operator.CompanyId,
|
87
|
CompanyID: importDataCommand.Operator.CompanyId,
|
|
@@ -93,19 +98,18 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
|
@@ -93,19 +98,18 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
93
|
}
|
98
|
}
|
94
|
item.OrganizationID, err = strconv.Atoi(v["OrganizationID"])
|
99
|
item.OrganizationID, err = strconv.Atoi(v["OrganizationID"])
|
95
|
if err != nil {
|
100
|
if err != nil {
|
96
|
- fail++
|
|
|
97
|
- continue
|
101
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("用户:%v 组织值:%v 类型无效(数值类型)", item.UserInfo.UserName, item.OrganizationID))
|
98
|
}
|
102
|
}
|
99
|
item.DepartmentID, err = strconv.Atoi(v["DepartmentID"])
|
103
|
item.DepartmentID, err = strconv.Atoi(v["DepartmentID"])
|
100
|
if err != nil {
|
104
|
if err != nil {
|
101
|
- fail++
|
|
|
102
|
- continue
|
105
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("用户:%v 部门值:%v 类型无效(数值类型)", item.UserInfo.UserName, item.DepartmentID))
|
103
|
}
|
106
|
}
|
104
|
users = append(users, item)
|
107
|
users = append(users, item)
|
105
|
}
|
108
|
}
|
106
|
userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
|
109
|
userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
|
107
|
result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
|
110
|
result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
|
108
|
Users: users,
|
111
|
Users: users,
|
|
|
112
|
+ Password: initPassword,
|
109
|
})
|
113
|
})
|
110
|
if err != nil {
|
114
|
if err != nil {
|
111
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
115
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
@@ -115,6 +119,10 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
|
@@ -115,6 +119,10 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
115
|
|
119
|
|
116
|
// ImportCooperationUser 导入共创用户信息
|
120
|
// ImportCooperationUser 导入共创用户信息
|
117
|
func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
121
|
func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
|
|
122
|
+ initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
|
|
|
123
|
+ if err != nil {
|
|
|
124
|
+ return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
125
|
+ }
|
118
|
excelImport := excel.NewExcelImport()
|
126
|
excelImport := excel.NewExcelImport()
|
119
|
excelImport.RowBegin = 2 //第二行开始读取
|
127
|
excelImport.RowBegin = 2 //第二行开始读取
|
120
|
excelImport.DataFields = []excel.DataField{
|
128
|
excelImport.DataFields = []excel.DataField{
|
|
@@ -156,6 +164,7 @@ func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.Imp |
|
@@ -156,6 +164,7 @@ func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.Imp |
156
|
userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
|
164
|
userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
|
157
|
result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
|
165
|
result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
|
158
|
Users: users,
|
166
|
Users: users,
|
|
|
167
|
+ Password: initPassword,
|
159
|
})
|
168
|
})
|
160
|
if err != nil {
|
169
|
if err != nil {
|
161
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
170
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|