作者 tangxvhui

bug 修复

... ... @@ -82,7 +82,7 @@ func UpdateAchievementById(m *Achievement, cols []string, om ...orm.Ormer) (err
}
var num int64
if num, err = o.Update(m, cols...); err == nil {
log.Info("Number of records updated in database:", num)
log.Info("Number of records updated in database:%d", num)
}
return
... ...
... ... @@ -552,7 +552,7 @@ func ValidUserPermission(urlPath string, userid int64, companyid int64) bool {
}
companyinfo, err := models.GetCompanyById(companyid)
if err != nil {
log.Error("获取公司数据失败")
log.Error("获取公司数据失败:err:%s", err)
return false
}
if companyinfo.AdminId == userid {
... ...
... ... @@ -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
... ...
... ... @@ -63,3 +63,15 @@ func JoinInt64s(ids []int64, spilt string) string {
}
return strings.Join(idStrings, spilt)
}
func ArrayInt64Unique(s []int64) []int64 {
m := map[int64]bool{}
newS := []int64{}
for _, v := range s {
if _, ok := m[v]; ok {
continue
}
newS = append(newS, v)
}
return newS
}
... ...