...
|
...
|
@@ -589,12 +589,18 @@ func RemoveUserDepartment(data RemoveUserDepartmentData) error { |
|
|
err error
|
|
|
companyData *models.Company
|
|
|
)
|
|
|
data.DepartmentIds = utils.ArrayInt64Unique(data.DepartmentIds)
|
|
|
data.UserIds = utils.ArrayInt64Unique(data.UserIds)
|
|
|
userDepartmentDatas := make(map[int64][]UserDepartData)
|
|
|
companyData, err = models.GetCompanyByUCenter(data.CompanyId)
|
|
|
if err != nil {
|
|
|
log.Error("h获取公司数据失败,user_center_id=%d,err:%s", data.CompanyId, err)
|
|
|
return errors.New("获取公司数据失败")
|
|
|
}
|
|
|
topdepartment, err := models.GetTopDepartmentByCompany(data.CompanyId)
|
|
|
if err != nil {
|
|
|
log.Error("获取公司一级部门失败;%s")
|
|
|
}
|
|
|
for _, v := range data.UserIds {
|
|
|
var userDapart []UserDepartData
|
|
|
for _, vv := range data.DepartmentIds {
|
...
|
...
|
@@ -603,6 +609,9 @@ func RemoveUserDepartment(data RemoveUserDepartmentData) error { |
|
|
UserId: v,
|
|
|
DepartmentId: vv,
|
|
|
}
|
|
|
if m.DepartmentId == 0 {
|
|
|
m.DepartmentId = topdepartment.Id
|
|
|
}
|
|
|
userDapart = append(userDapart, m)
|
|
|
}
|
|
|
userDepartmentDatas[v] = userDapart
|
...
|
...
|
|