作者 yangfu

1.部门列表修改 增加根部门列表

... ... @@ -7,6 +7,7 @@ import (
const (
DepartmentUser = iota //用户所有部门
DepartmentAll //公司所有部门
DepartmentRoot //公司一级部门
)
const (
... ... @@ -59,8 +60,8 @@ type Department struct {
Name string `orm:"column(name)" json:"name"`
PId int `orm:"column(parent_id)" json:"-"`
ManagerString string `orm:"column(managers)" json:"-"`
Relation string `orm:"column(relation)"`
CreateTime time.Time `orm:"column(create_time)"`
Relation string `orm:"column(relation)" json:"-"`
CreateTime time.Time `orm:"column(create_time)" json:"-"`
Managers []int `json:"-"`
Departments []*Department `json:"departments,omitempty"`
}
... ...
... ... @@ -31,6 +31,20 @@ func Departments(header *protocol.RequestHeader, request *protocol.DepartmentsRe
log.Error(err)
return
}
case protocol.DepartmentRoot:
if departments, err = models.GetDepartmentByCompanyId(header.CompanyId); err != nil {
log.Error(err)
return
}
for i := range departments {
item := departments[i]
walkDepartment(tmpDepartment, item)
}
rsp.Departments = tmpDepartment.Departments
rsp.Departments = rsp.GetRootDepartment()
for i := range rsp.Departments {
rsp.Departments[i].Departments = make([]*protocol.Department, 0)
}
default:
break
}
... ...