...
|
...
|
@@ -227,6 +227,12 @@ func initDepartment(newCompany *models.Company, newusercompany *models.UserCompa |
|
|
Filter("is_top", 1).
|
|
|
One(newDepartment)
|
|
|
if err == nil {
|
|
|
newDepartment.Name = newCompany.Name
|
|
|
err = models.UpdateDepartmentById(newDepartment, []string{"Name"}, o)
|
|
|
if err != nil {
|
|
|
log.Error("更新部门关系树数据失败:%s", err)
|
|
|
return nil, err
|
|
|
}
|
|
|
return newDepartment, nil
|
|
|
} else if err == orm.ErrNoRows {
|
|
|
//添加部门
|
...
|
...
|
@@ -309,7 +315,7 @@ func initRoleGroup(newCompany *models.Company, o orm.Ormer) (*models.Role, error |
|
|
Types: models.ROLETYPES_GROUP,
|
|
|
CompanyId: newCompany.Id,
|
|
|
IsDefault: models.ROLE_DEFAULR,
|
|
|
Name: "主管组",
|
|
|
Name: "管理员",
|
|
|
}
|
|
|
_, err = models.AddRole(newRoleGroup, o)
|
|
|
if err != nil {
|
...
|
...
|
@@ -405,19 +411,34 @@ func CompanyInfoEdit(companyid int64, logo string) error { |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
//
|
|
|
func CompanyEditFromUcenter(companyid int64, companyname string) error {
|
|
|
companyinfo, err := models.GetCompanyByUCenter(companyid)
|
|
|
//CompanyEditFromUcenter 总后台调用修改公司名称
|
|
|
func CompanyEditFromUcenter(ucompanyid int64, companyname string) error {
|
|
|
companyinfo, err := models.GetCompanyByUCenter(ucompanyid)
|
|
|
if err != nil {
|
|
|
log.Error("获取公司数据失败")
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
companyinfo.Name = companyname
|
|
|
o := orm.NewOrm()
|
|
|
o.Begin()
|
|
|
err = models.UpdateCompanyById(companyinfo, []string{"Name"})
|
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
|
log.Info("更新公司数据失败:%s", err)
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
_, err = o.QueryTable(&models.Department{}).
|
|
|
Filter("company_id", companyinfo.Id).
|
|
|
Filter("is_top", 1).
|
|
|
Update(orm.Params{
|
|
|
"name": companyname,
|
|
|
})
|
|
|
if err != nil {
|
|
|
o.Rollback()
|
|
|
log.Error("更新部门名称失败:%s", err)
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
o.Commit()
|
|
|
return nil
|
|
|
}
|
|
|
|
...
|
...
|
@@ -448,7 +469,7 @@ func ForbidCompany(ucenterCompany int64) error { |
|
|
companyData, err = models.GetCompanyByUCenter(ucenterCompany)
|
|
|
if err == orm.ErrNoRows {
|
|
|
log.Warn("未查找到公司数据")
|
|
|
return nil
|
|
|
return protocol.NewErrWithMessage("12001")
|
|
|
}
|
|
|
if err != nil && err != orm.ErrNoRows {
|
|
|
log.Error(err.Error())
|
...
|
...
|
@@ -465,6 +486,32 @@ func ForbidCompany(ucenterCompany int64) error { |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
//AllowCompany 启用公司
|
|
|
func AllowCompany(ucenterCompany int64) error {
|
|
|
var (
|
|
|
err error
|
|
|
companyData *models.Company
|
|
|
)
|
|
|
companyData, err = models.GetCompanyByUCenter(ucenterCompany)
|
|
|
if err == orm.ErrNoRows {
|
|
|
log.Warn("未查找到公司数据")
|
|
|
return protocol.NewErrWithMessage("12001")
|
|
|
}
|
|
|
if err != nil && err != orm.ErrNoRows {
|
|
|
log.Error(err.Error())
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
|
|
|
companyData.Enable = models.COMPANY_ENABLE_YES
|
|
|
companyData.UpdateAt = time.Now()
|
|
|
err = models.UpdateCompanyById(companyData, []string{"Enable", "UpdateAt"})
|
|
|
if err != nil {
|
|
|
log.Error("更新公司数据失败:%s", err)
|
|
|
return protocol.NewErrWithMessage("1")
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func CompanyInfoForUCenter(uCenterid int64) (protocol.ResponseCenterCompany, error) {
|
|
|
var (
|
|
|
err error
|
...
|
...
|
|