...
|
...
|
@@ -13,7 +13,7 @@ type PgBatchAddUserService struct { |
|
|
transactionContext *pgTransaction.TransactionContext
|
|
|
}
|
|
|
|
|
|
// CreateUser 批量添加用户服务
|
|
|
// BatchAddUser 批量添加用户服务
|
|
|
//
|
|
|
// optUser 操作用户
|
|
|
// users 待添加用户列表数据
|
...
|
...
|
@@ -107,7 +107,6 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use |
|
|
user.FailReason = err.Error()
|
|
|
failRows = append(failRows, user)
|
|
|
continue
|
|
|
//return err
|
|
|
}
|
|
|
var org, dep *domain.Org
|
|
|
var ok bool
|
...
|
...
|
@@ -115,26 +114,22 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use |
|
|
user.FailReason = "导入的组织机构不存在:" + user.Org
|
|
|
failRows = append(failRows, user)
|
|
|
continue
|
|
|
//return fmt.Errorf("导入的组织机构不存在:" + user.Org)
|
|
|
}
|
|
|
if dep, ok = mapOrg[user.Department]; !ok && user.UserType != domain.UserTypeCooperation {
|
|
|
user.FailReason = "导入的所属部门不存在:" + user.Department
|
|
|
failRows = append(failRows, user)
|
|
|
continue
|
|
|
//return fmt.Errorf("导入的所属部门不存在:" + user.Department)
|
|
|
}
|
|
|
newUser := &domain.User{
|
|
|
CompanyId: user.CompanyId,
|
|
|
UserType: user.UserType,
|
|
|
UserCode: user.UserCode,
|
|
|
OrganizationId: org.OrgId,
|
|
|
//DepartmentId: dep.OrgId,
|
|
|
UserOrg: []*domain.Org{},
|
|
|
UserRole: []*domain.Role{},
|
|
|
FavoriteMenus: []string{},
|
|
|
UserOrg: []*domain.Org{},
|
|
|
UserRole: []*domain.Role{},
|
|
|
FavoriteMenus: []string{},
|
|
|
CooperationInfo: &domain.CooperationInfo{
|
|
|
CooperationCompany: user.CooperationCompany,
|
|
|
//CooperationDeadline: user.CooperationDeadline,
|
|
|
},
|
|
|
UserInfo: &domain.UserInfo{
|
|
|
UserName: user.UserName,
|
...
|
...
|
@@ -147,7 +142,6 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use |
|
|
Phone: user.Phone,
|
|
|
UserName: user.UserName,
|
|
|
OrgName: org.OrgName,
|
|
|
//DepName: dep.OrgName,
|
|
|
},
|
|
|
CreatedAt: time.Now(),
|
|
|
UpdatedAt: time.Now(),
|
...
|
...
|
@@ -164,11 +158,13 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use |
|
|
continue
|
|
|
}
|
|
|
}
|
|
|
if user.UserType == domain.UserTypeEmployee {
|
|
|
newUser.UserOrg = append(newUser.UserOrg, org.CloneSample())
|
|
|
}
|
|
|
if newUser, err = createUserService.CreateUser(nil, newUser, password); err != nil {
|
|
|
user.FailReason = err.Error()
|
|
|
failRows = append(failRows, user)
|
|
|
continue
|
|
|
//return fmt.Errorf("%v %v", user.UserName, err.Error())
|
|
|
}
|
|
|
}
|
|
|
return failRows, nil
|
...
|
...
|
@@ -206,12 +202,6 @@ func (ptr *PgBatchAddUserService) preCheck2(user *domain.BatchAddUserItem) error |
|
|
if len(user.Phone) == 0 || len(user.Phone) != 11 {
|
|
|
return fmt.Errorf("导入的手机号不是有效手机号")
|
|
|
}
|
|
|
//if len(user.Org) == 0 {
|
|
|
// return fmt.Errorf("导入的组织机构不存在")
|
|
|
//}
|
|
|
//if len(user.Department) == 0 && user.UserType == domain.UserTypeEmployee {
|
|
|
// return fmt.Errorf("导入的所属部门不存在")
|
|
|
//}
|
|
|
return nil
|
|
|
}
|
|
|
|
...
|
...
|
|