...
|
...
|
@@ -115,8 +115,9 @@ func SetCompanyCharge(data CompanyCharge) error { |
|
|
|
|
|
func UpdateCompanyData(data ModuleCompanytData) error {
|
|
|
var (
|
|
|
companyData *models.Company
|
|
|
err error
|
|
|
companyData *models.Company
|
|
|
err error
|
|
|
topDepartment *models.Department
|
|
|
)
|
|
|
newCompanyData := data.Company
|
|
|
companyData, err = models.GetCompanyByUCenter(newCompanyData.AdminCompanyId)
|
...
|
...
|
@@ -136,6 +137,11 @@ func UpdateCompanyData(data ModuleCompanytData) error { |
|
|
log.Error("获取公司主管理员user_company数据失败,company_id=%d,user_id=%d,err:%s", companyData.Id, companyData.AdminId, err)
|
|
|
return errors.New("获取公司主管理员数据失败")
|
|
|
}
|
|
|
topDepartment, err = models.GetTopDepartmentByCompany(companyData.Id)
|
|
|
if err != nil {
|
|
|
log.Error("获取公司一级数据失败,company_id=%d,err:%s", companyData.Id, err)
|
|
|
return errors.New("获取公司一级数据失败")
|
|
|
}
|
|
|
o := orm.NewOrm()
|
|
|
o.Begin()
|
|
|
if data.User.Id != oldAdminData.Id {
|
...
|
...
|
@@ -172,6 +178,13 @@ func UpdateCompanyData(data ModuleCompanytData) error { |
|
|
log.Error("更新公司数据失败:%s", err)
|
|
|
return errors.New("更新公司数据失败")
|
|
|
}
|
|
|
topDepartment.Name = newCompanyData.Name
|
|
|
err = models.UpdateDepartmentById(topDepartment, []string{"Name"}, o)
|
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
|
log.Error("更新公司一级部门数据失败:%s", err)
|
|
|
return errors.New("更新公司一级部门数据失败")
|
|
|
}
|
|
|
o.Commit()
|
|
|
return nil
|
|
|
}
|
...
|
...
|
|