...
|
...
|
@@ -232,6 +232,13 @@ func AddEmployeeData(data []ModuleEmployee) error { |
|
|
}
|
|
|
uc.EntryTime, _ = time.ParseInLocation("2006-01-02", v.EntryTime, time.Local)
|
|
|
usercompanydata = append(usercompanydata, uc)
|
|
|
var (
|
|
|
topdepartment *models.Department
|
|
|
)
|
|
|
topdepartment, err = models.GetTopDepartmentByCompany(companydata.Id)
|
|
|
if err != nil {
|
|
|
log.Error("获取公司一级部门失败;%s")
|
|
|
}
|
|
|
for i := range v.UserDepartments {
|
|
|
d := &models.UserDepartment{
|
|
|
CompanyId: companydata.Id,
|
...
|
...
|
@@ -240,6 +247,9 @@ func AddEmployeeData(data []ModuleEmployee) error { |
|
|
CreateTime: nowTime,
|
|
|
EnableStatus: 1,
|
|
|
}
|
|
|
if v.UserDepartments[i].DepartmentId == 0 {
|
|
|
d.DepartmentId = topdepartment.Id
|
|
|
}
|
|
|
userdepartmentData = append(userdepartmentData, d)
|
|
|
}
|
|
|
for i := range v.UserPositions {
|
...
|
...
|
@@ -360,6 +370,18 @@ func UpdateEmployeeData(data ModuleEmployee) error { |
|
|
log.Error("UpdateUserCompanyById err:%s", err)
|
|
|
return errors.New("更新用户数据失败")
|
|
|
}
|
|
|
var (
|
|
|
topdepartment *models.Department
|
|
|
)
|
|
|
topdepartment, err = models.GetTopDepartmentByCompany(companyInfo.Id)
|
|
|
if err != nil {
|
|
|
log.Error("获取公司一级部门失败;%s")
|
|
|
}
|
|
|
for i := range data.UserDepartments {
|
|
|
if data.UserDepartments[i].DepartmentId == 0 {
|
|
|
data.UserDepartments[i].DepartmentId = topdepartment.Id
|
|
|
}
|
|
|
}
|
|
|
//添加部门
|
|
|
err = editUserDepart(data.Id, companyInfo.Id, data.UserDepartments, o)
|
|
|
if err != nil {
|
...
|
...
|
|