...
|
...
|
@@ -8,13 +8,21 @@ import ( |
|
|
"oppmg/utils"
|
|
|
)
|
|
|
|
|
|
func SelectorDepartment(companyid int64) []protocol.DepartmentBase {
|
|
|
const dataSql string = `SELECT id,name,parent_id FROM department WHERE company_id = ? AND delete_at = 0`
|
|
|
func SelectorDepartment(companyid int64, departmentid int64) []protocol.DepartmentBase {
|
|
|
|
|
|
var (
|
|
|
err error
|
|
|
departs []protocol.DepartmentBase
|
|
|
cond []interface{}
|
|
|
where string
|
|
|
)
|
|
|
err = utils.ExecuteQueryAll(&departs, dataSql, companyid)
|
|
|
dataSql := `SELECT id,name,parent_id FROM department WHERE company_id = ? AND delete_at = 0 `
|
|
|
cond = append(cond, companyid)
|
|
|
if departmentid >= 0 {
|
|
|
cond = append(cond, departmentid)
|
|
|
where += ` And parent_id=? `
|
|
|
}
|
|
|
err = utils.ExecuteQueryAll(&departs, dataSql+where, cond...)
|
|
|
if err != nil {
|
|
|
e := fmt.Errorf("EXECUTE SQL err:%s", err)
|
|
|
log.Error(e.Error())
|
...
|
...
|
|