正在显示
1 个修改的文件
包含
22 行增加
和
0 行删除
@@ -232,6 +232,13 @@ func AddEmployeeData(data []ModuleEmployee) error { | @@ -232,6 +232,13 @@ func AddEmployeeData(data []ModuleEmployee) error { | ||
232 | } | 232 | } |
233 | uc.EntryTime, _ = time.ParseInLocation("2006-01-02", v.EntryTime, time.Local) | 233 | uc.EntryTime, _ = time.ParseInLocation("2006-01-02", v.EntryTime, time.Local) |
234 | usercompanydata = append(usercompanydata, uc) | 234 | usercompanydata = append(usercompanydata, uc) |
235 | + var ( | ||
236 | + topdepartment *models.Department | ||
237 | + ) | ||
238 | + topdepartment, err = models.GetTopDepartmentByCompany(companydata.Id) | ||
239 | + if err != nil { | ||
240 | + log.Error("获取公司一级部门失败;%s") | ||
241 | + } | ||
235 | for i := range v.UserDepartments { | 242 | for i := range v.UserDepartments { |
236 | d := &models.UserDepartment{ | 243 | d := &models.UserDepartment{ |
237 | CompanyId: companydata.Id, | 244 | CompanyId: companydata.Id, |
@@ -240,6 +247,9 @@ func AddEmployeeData(data []ModuleEmployee) error { | @@ -240,6 +247,9 @@ func AddEmployeeData(data []ModuleEmployee) error { | ||
240 | CreateTime: nowTime, | 247 | CreateTime: nowTime, |
241 | EnableStatus: 1, | 248 | EnableStatus: 1, |
242 | } | 249 | } |
250 | + if v.UserDepartments[i].DepartmentId == 0 { | ||
251 | + d.DepartmentId = topdepartment.Id | ||
252 | + } | ||
243 | userdepartmentData = append(userdepartmentData, d) | 253 | userdepartmentData = append(userdepartmentData, d) |
244 | } | 254 | } |
245 | for i := range v.UserPositions { | 255 | for i := range v.UserPositions { |
@@ -360,6 +370,18 @@ func UpdateEmployeeData(data ModuleEmployee) error { | @@ -360,6 +370,18 @@ func UpdateEmployeeData(data ModuleEmployee) error { | ||
360 | log.Error("UpdateUserCompanyById err:%s", err) | 370 | log.Error("UpdateUserCompanyById err:%s", err) |
361 | return errors.New("更新用户数据失败") | 371 | return errors.New("更新用户数据失败") |
362 | } | 372 | } |
373 | + var ( | ||
374 | + topdepartment *models.Department | ||
375 | + ) | ||
376 | + topdepartment, err = models.GetTopDepartmentByCompany(companyInfo.Id) | ||
377 | + if err != nil { | ||
378 | + log.Error("获取公司一级部门失败;%s") | ||
379 | + } | ||
380 | + for i := range data.UserDepartments { | ||
381 | + if data.UserDepartments[i].DepartmentId == 0 { | ||
382 | + data.UserDepartments[i].DepartmentId = topdepartment.Id | ||
383 | + } | ||
384 | + } | ||
363 | //添加部门 | 385 | //添加部门 |
364 | err = editUserDepart(data.Id, companyInfo.Id, data.UserDepartments, o) | 386 | err = editUserDepart(data.Id, companyInfo.Id, data.UserDepartments, o) |
365 | if err != nil { | 387 | if err != nil { |
-
请 注册 或 登录 后发表评论