...
|
...
|
@@ -7,6 +7,7 @@ import ( |
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/command"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/web/excelData/query"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/domainService"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/service_gateway/allied_creation_user"
|
|
|
"strconv"
|
|
|
"time"
|
...
|
...
|
@@ -61,6 +62,10 @@ func (srv ExcelDataService) ExportCooperationUser(companyUserListQuery *query.Co |
|
|
|
|
|
// ImportCompanyUser 导入公司用户信息
|
|
|
func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
|
|
initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
excelImport := excel.NewExcelImport()
|
|
|
excelImport.RowBegin = 2 //第二行开始读取
|
|
|
excelImport.DataFields = []excel.DataField{
|
...
|
...
|
@@ -70,13 +75,13 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
|
|
{EnName: "DepartmentID", CnName: "*所属部门"},
|
|
|
{EnName: "Phone", CnName: "*手机号"},
|
|
|
{EnName: "Email", CnName: "邮箱"},
|
|
|
{EnName: "Status", CnName: "状态"},
|
|
|
}
|
|
|
excelData, err := excelImport.OpenExcelFromIoReader(importDataCommand.Reader)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
users := make([]allied_creation_user.BatchAddUserItem, 0)
|
|
|
var fail int
|
|
|
for _, v := range excelData {
|
|
|
item := allied_creation_user.BatchAddUserItem{
|
|
|
CompanyID: importDataCommand.Operator.CompanyId,
|
...
|
...
|
@@ -93,19 +98,18 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
|
|
}
|
|
|
item.OrganizationID, err = strconv.Atoi(v["OrganizationID"])
|
|
|
if err != nil {
|
|
|
fail++
|
|
|
continue
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("用户:%v 组织值:%v 类型无效(数值类型)", item.UserInfo.UserName, item.OrganizationID))
|
|
|
}
|
|
|
item.DepartmentID, err = strconv.Atoi(v["DepartmentID"])
|
|
|
if err != nil {
|
|
|
fail++
|
|
|
continue
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, fmt.Sprintf("用户:%v 部门值:%v 类型无效(数值类型)", item.UserInfo.UserName, item.DepartmentID))
|
|
|
}
|
|
|
users = append(users, item)
|
|
|
}
|
|
|
userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
|
|
|
result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
|
|
|
Users: users,
|
|
|
Password: initPassword,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
...
|
...
|
@@ -115,6 +119,10 @@ func (srv ExcelDataService) ImportCompanyUser(importDataCommand *command.ImportD |
|
|
|
|
|
// ImportCooperationUser 导入共创用户信息
|
|
|
func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.ImportDataCommand) (interface{}, error) {
|
|
|
initPassword, _, err := domainService.GetInitPassword(importDataCommand.Operator)
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
|
|
}
|
|
|
excelImport := excel.NewExcelImport()
|
|
|
excelImport.RowBegin = 2 //第二行开始读取
|
|
|
excelImport.DataFields = []excel.DataField{
|
...
|
...
|
@@ -156,6 +164,7 @@ func (srv ExcelDataService) ImportCooperationUser(importDataCommand *command.Imp |
|
|
userGateway := allied_creation_user.NewHttplibAlliedCreationUser(importDataCommand.Operator)
|
|
|
result, err := userGateway.UserBatchAdd(allied_creation_user.ReqBatchAddUser{
|
|
|
Users: users,
|
|
|
Password: initPassword,
|
|
|
})
|
|
|
if err != nil {
|
|
|
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
|
...
|
...
|
|