作者 yangfu

共创用户导入修改

... ... @@ -310,7 +310,7 @@ type BatchAddUserItem struct {
// 共创公司 cooperationCompany
CooperationCompany string `json:"cooperationCompany"`
// 共创到期时间 (yyyy-MM-dd) cooperationDeadline
CooperationDeadline time.Time `json:"cooperationDeadline"`
CooperationDeadline string `json:"cooperationDeadline"`
// 失败理由
FailReason string `json:"failReason"`
... ...
... ... @@ -117,7 +117,7 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use
continue
//return fmt.Errorf("导入的组织机构不存在:" + user.Org)
}
if dep, ok = mapOrg[user.Department]; !ok {
if dep, ok = mapOrg[user.Department]; !ok && user.UserType != domain.UserTypeCooperation {
user.FailReason = "导入的所属部门不存在:" + user.Department
failRows = append(failRows, user)
continue
... ... @@ -128,13 +128,13 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use
UserType: user.UserType,
UserCode: user.UserCode,
OrganizationId: org.OrgId,
DepartmentId: dep.OrgId,
//DepartmentId: dep.OrgId,
UserOrg: []*domain.Org{},
UserRole: []*domain.Role{},
FavoriteMenus: []string{},
CooperationInfo: &domain.CooperationInfo{
CooperationCompany: user.CooperationCompany,
CooperationDeadline: user.CooperationDeadline,
//CooperationDeadline: user.CooperationDeadline,
},
UserInfo: &domain.UserInfo{
UserName: user.UserName,
... ... @@ -147,11 +147,23 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use
Phone: user.Phone,
UserName: user.UserName,
OrgName: org.OrgName,
DepName: dep.OrgName,
//DepName: dep.OrgName,
},
CreatedAt: time.Now(),
UpdatedAt: time.Now(),
}
if dep != nil {
newUser.DepartmentId = dep.OrgId
newUser.Ext.DepName = dep.OrgName
}
if len(user.CooperationDeadline) > 0 {
newUser.CooperationInfo.CooperationDeadline, err = time.Parse("2006-01-02", user.CooperationDeadline)
if err != nil {
user.FailReason = fmt.Sprintf("共创到期时间格式有误 (例如:2001-01-01)")
failRows = append(failRows, user)
continue
}
}
if newUser, err = createUserService.CreateUser(nil, newUser, password); err != nil {
user.FailReason = err.Error()
failRows = append(failRows, user)
... ...