...
|
...
|
@@ -31,14 +31,21 @@ func DepartmentAdd(param protocol.RequestDepartmentAdd) (protocol.ResponseDepart |
|
|
return returndata, protocol.NewErrWithMessage("1", e)
|
|
|
}
|
|
|
}
|
|
|
for _, v := range param.Managers {
|
|
|
_, err = models.GetUserCompanyBy(v, param.CompanyID)
|
|
|
if err != nil {
|
|
|
e := fmt.Errorf("GetUserCompanyBy(userid,companyid)[%d, %d] err:%s", v, param.CompanyID, err)
|
|
|
log.Error(e.Error())
|
|
|
return returndata, protocol.NewErrWithMessage("1", e)
|
|
|
}
|
|
|
}
|
|
|
// for _, v := range param.Managers {
|
|
|
// uc, err := models.GetUserCompanyReal([]int64{v})
|
|
|
// if err != nil {
|
|
|
// e := fmt.Errorf("GetUserCompanyReal([]int64{%d}) err:%s", v, err)
|
|
|
// log.Error(e.Error())
|
|
|
// return returndata, protocol.NewErrWithMessage("1", e)
|
|
|
// }
|
|
|
// if len(uc) > 0 {
|
|
|
// if uc[0].CompanyId != param.CompanyID {
|
|
|
// e := fmt.Errorf("managers err")
|
|
|
// log.Error(e.Error())
|
|
|
// return returndata, protocol.NewErrWithMessage("1", e)
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
departmentAdd := &models.Department{
|
|
|
CompanyId: param.CompanyID,
|
|
|
Name: param.Name,
|
...
|
...
|
@@ -46,7 +53,7 @@ func DepartmentAdd(param protocol.RequestDepartmentAdd) (protocol.ResponseDepart |
|
|
UpdateAt: time.Now(),
|
|
|
ParentId: param.ParentID,
|
|
|
}
|
|
|
departmentAdd.SetManages(param.Managers)
|
|
|
departmentAdd.SetManages(nil)
|
|
|
o := orm.NewOrm()
|
|
|
o.Begin()
|
|
|
_, err = models.AddDepartment(departmentAdd, o)
|
...
|
...
|
@@ -286,7 +293,7 @@ func DepartmentListAll(companyId int64) ([]protocol.ResponseDepartmentInfo, erro |
|
|
err error
|
|
|
)
|
|
|
const (
|
|
|
datasql0 string = `SELECT id, company_id,name,parent_id,member,managers,delete_at ` +
|
|
|
datasql0 string = `SELECT id, company_id,name,parent_id,member,managers ` +
|
|
|
` FROM department WHERE company_id = ? AND delete_at = 0`
|
|
|
)
|
|
|
err = utils.ExecuteQueryAll(&departmodels, datasql0, companyId)
|
...
|
...
|
|