作者 yangfu

共创用户导入修改

@@ -310,7 +310,7 @@ type BatchAddUserItem struct { @@ -310,7 +310,7 @@ type BatchAddUserItem struct {
310 // 共创公司 cooperationCompany 310 // 共创公司 cooperationCompany
311 CooperationCompany string `json:"cooperationCompany"` 311 CooperationCompany string `json:"cooperationCompany"`
312 // 共创到期时间 (yyyy-MM-dd) cooperationDeadline 312 // 共创到期时间 (yyyy-MM-dd) cooperationDeadline
313 - CooperationDeadline time.Time `json:"cooperationDeadline"` 313 + CooperationDeadline string `json:"cooperationDeadline"`
314 314
315 // 失败理由 315 // 失败理由
316 FailReason string `json:"failReason"` 316 FailReason string `json:"failReason"`
@@ -117,7 +117,7 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use @@ -117,7 +117,7 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use
117 continue 117 continue
118 //return fmt.Errorf("导入的组织机构不存在:" + user.Org) 118 //return fmt.Errorf("导入的组织机构不存在:" + user.Org)
119 } 119 }
120 - if dep, ok = mapOrg[user.Department]; !ok { 120 + if dep, ok = mapOrg[user.Department]; !ok && user.UserType != domain.UserTypeCooperation {
121 user.FailReason = "导入的所属部门不存在:" + user.Department 121 user.FailReason = "导入的所属部门不存在:" + user.Department
122 failRows = append(failRows, user) 122 failRows = append(failRows, user)
123 continue 123 continue
@@ -128,13 +128,13 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use @@ -128,13 +128,13 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use
128 UserType: user.UserType, 128 UserType: user.UserType,
129 UserCode: user.UserCode, 129 UserCode: user.UserCode,
130 OrganizationId: org.OrgId, 130 OrganizationId: org.OrgId,
131 - DepartmentId: dep.OrgId,  
132 - UserOrg: []*domain.Org{},  
133 - UserRole: []*domain.Role{},  
134 - FavoriteMenus: []string{}, 131 + //DepartmentId: dep.OrgId,
  132 + UserOrg: []*domain.Org{},
  133 + UserRole: []*domain.Role{},
  134 + FavoriteMenus: []string{},
135 CooperationInfo: &domain.CooperationInfo{ 135 CooperationInfo: &domain.CooperationInfo{
136 - CooperationCompany: user.CooperationCompany,  
137 - CooperationDeadline: user.CooperationDeadline, 136 + CooperationCompany: user.CooperationCompany,
  137 + //CooperationDeadline: user.CooperationDeadline,
138 }, 138 },
139 UserInfo: &domain.UserInfo{ 139 UserInfo: &domain.UserInfo{
140 UserName: user.UserName, 140 UserName: user.UserName,
@@ -147,11 +147,23 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use @@ -147,11 +147,23 @@ func (ptr *PgBatchAddUserService) BatchAddUser2(optUser *domain.OperateInfo, use
147 Phone: user.Phone, 147 Phone: user.Phone,
148 UserName: user.UserName, 148 UserName: user.UserName,
149 OrgName: org.OrgName, 149 OrgName: org.OrgName,
150 - DepName: dep.OrgName, 150 + //DepName: dep.OrgName,
151 }, 151 },
152 CreatedAt: time.Now(), 152 CreatedAt: time.Now(),
153 UpdatedAt: time.Now(), 153 UpdatedAt: time.Now(),
154 } 154 }
  155 + if dep != nil {
  156 + newUser.DepartmentId = dep.OrgId
  157 + newUser.Ext.DepName = dep.OrgName
  158 + }
  159 + if len(user.CooperationDeadline) > 0 {
  160 + newUser.CooperationInfo.CooperationDeadline, err = time.Parse("2006-01-02", user.CooperationDeadline)
  161 + if err != nil {
  162 + user.FailReason = fmt.Sprintf("共创到期时间格式有误 (例如:2001-01-01)")
  163 + failRows = append(failRows, user)
  164 + continue
  165 + }
  166 + }
155 if newUser, err = createUserService.CreateUser(nil, newUser, password); err != nil { 167 if newUser, err = createUserService.CreateUser(nil, newUser, password); err != nil {
156 user.FailReason = err.Error() 168 user.FailReason = err.Error()
157 failRows = append(failRows, user) 169 failRows = append(failRows, user)