作者 yangfu

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

@@ -7,6 +7,7 @@ import ( @@ -7,6 +7,7 @@ import (
7 const ( 7 const (
8 DepartmentUser = iota //用户所有部门 8 DepartmentUser = iota //用户所有部门
9 DepartmentAll //公司所有部门 9 DepartmentAll //公司所有部门
  10 + DepartmentRoot //公司一级部门
10 ) 11 )
11 12
12 const ( 13 const (
@@ -59,8 +60,8 @@ type Department struct { @@ -59,8 +60,8 @@ type Department struct {
59 Name string `orm:"column(name)" json:"name"` 60 Name string `orm:"column(name)" json:"name"`
60 PId int `orm:"column(parent_id)" json:"-"` 61 PId int `orm:"column(parent_id)" json:"-"`
61 ManagerString string `orm:"column(managers)" json:"-"` 62 ManagerString string `orm:"column(managers)" json:"-"`
62 - Relation string `orm:"column(relation)"`  
63 - CreateTime time.Time `orm:"column(create_time)"` 63 + Relation string `orm:"column(relation)" json:"-"`
  64 + CreateTime time.Time `orm:"column(create_time)" json:"-"`
64 Managers []int `json:"-"` 65 Managers []int `json:"-"`
65 Departments []*Department `json:"departments,omitempty"` 66 Departments []*Department `json:"departments,omitempty"`
66 } 67 }
@@ -31,6 +31,20 @@ func Departments(header *protocol.RequestHeader, request *protocol.DepartmentsRe @@ -31,6 +31,20 @@ func Departments(header *protocol.RequestHeader, request *protocol.DepartmentsRe
31 log.Error(err) 31 log.Error(err)
32 return 32 return
33 } 33 }
  34 + case protocol.DepartmentRoot:
  35 + if departments, err = models.GetDepartmentByCompanyId(header.CompanyId); err != nil {
  36 + log.Error(err)
  37 + return
  38 + }
  39 + for i := range departments {
  40 + item := departments[i]
  41 + walkDepartment(tmpDepartment, item)
  42 + }
  43 + rsp.Departments = tmpDepartment.Departments
  44 + rsp.Departments = rsp.GetRootDepartment()
  45 + for i := range rsp.Departments {
  46 + rsp.Departments[i].Departments = make([]*protocol.Department, 0)
  47 + }
34 default: 48 default:
35 break 49 break
36 } 50 }