正在显示
5 个修改的文件
包含
33 行增加
和
12 行删除
@@ -23,10 +23,19 @@ func (c *CommonController) SelectorDepartment() { | @@ -23,10 +23,19 @@ func (c *CommonController) SelectorDepartment() { | ||
23 | defer func() { | 23 | defer func() { |
24 | c.ResposeJson(msg) | 24 | c.ResposeJson(msg) |
25 | }() | 25 | }() |
26 | + type Parameter struct { | ||
27 | + DepartmentId int64 `json:"department_id"` | ||
28 | + } | ||
29 | + var param Parameter | ||
30 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
31 | + log.Error("json 解析失败 err:%s", err) | ||
32 | + msg = protocol.BadRequestParam("1") | ||
33 | + return | ||
34 | + } | ||
26 | companyid := c.GetCompanyId() | 35 | companyid := c.GetCompanyId() |
27 | - departs := servecommon.SelectorDepartment(companyid) | ||
28 | - | ||
29 | - msg = protocol.NewReturnResponse(departs, nil) | 36 | + departs := servecommon.SelectorDepartment(companyid, param.DepartmentId) |
37 | + data := protocol.ResponseListData{List: departs} | ||
38 | + msg = protocol.NewReturnResponse(data, nil) | ||
30 | return | 39 | return |
31 | } | 40 | } |
32 | 41 |
@@ -13,6 +13,10 @@ type ResponsePageInfo struct { | @@ -13,6 +13,10 @@ type ResponsePageInfo struct { | ||
13 | // ListData interface{} `json:"lists"` | 13 | // ListData interface{} `json:"lists"` |
14 | } | 14 | } |
15 | 15 | ||
16 | +type ResponseListData struct { | ||
17 | + List interface{} `json:"lists"` | ||
18 | +} | ||
19 | + | ||
16 | // DepartmentBase下拉选择列表-部门 | 20 | // DepartmentBase下拉选择列表-部门 |
17 | type DepartmentBase struct { | 21 | type DepartmentBase struct { |
18 | Id int64 `json:"id" orm:"column(id)"` | 22 | Id int64 `json:"id" orm:"column(id)"` |
@@ -17,11 +17,6 @@ type DepartmentManager struct { | @@ -17,11 +17,6 @@ type DepartmentManager struct { | ||
17 | Name string `json:"name"` | 17 | Name string `json:"name"` |
18 | } | 18 | } |
19 | 19 | ||
20 | -type DepartmentMember struct { | ||
21 | - Id int64 `json:"id"` | ||
22 | - Name string `json:"name"` | ||
23 | -} | ||
24 | - | ||
25 | //RequestDepartmentEdit 编辑 | 20 | //RequestDepartmentEdit 编辑 |
26 | type RequestDepartmentEdit struct { | 21 | type RequestDepartmentEdit struct { |
27 | ID int64 `json:"id"` | 22 | ID int64 `json:"id"` |
@@ -35,6 +30,11 @@ type RequestDepartmentDelete struct { | @@ -35,6 +30,11 @@ type RequestDepartmentDelete struct { | ||
35 | CompanyID int64 `json:"company_id"` //公司 | 30 | CompanyID int64 `json:"company_id"` //公司 |
36 | } | 31 | } |
37 | 32 | ||
33 | +type DepartmentMember struct { | ||
34 | + Id int64 `json:"id"` | ||
35 | + Name string `json:"name"` | ||
36 | +} | ||
37 | + | ||
38 | //ResponseDepartmentInfo ... | 38 | //ResponseDepartmentInfo ... |
39 | type ResponseDepartmentInfo struct { | 39 | type ResponseDepartmentInfo struct { |
40 | ID int64 `json:"id"` | 40 | ID int64 `json:"id"` |
@@ -8,13 +8,21 @@ import ( | @@ -8,13 +8,21 @@ import ( | ||
8 | "oppmg/utils" | 8 | "oppmg/utils" |
9 | ) | 9 | ) |
10 | 10 | ||
11 | -func SelectorDepartment(companyid int64) []protocol.DepartmentBase { | ||
12 | - const dataSql string = `SELECT id,name,parent_id FROM department WHERE company_id = ? AND delete_at = 0` | 11 | +func SelectorDepartment(companyid int64, departmentid int64) []protocol.DepartmentBase { |
12 | + | ||
13 | var ( | 13 | var ( |
14 | err error | 14 | err error |
15 | departs []protocol.DepartmentBase | 15 | departs []protocol.DepartmentBase |
16 | + cond []interface{} | ||
17 | + where string | ||
16 | ) | 18 | ) |
17 | - err = utils.ExecuteQueryAll(&departs, dataSql, companyid) | 19 | + dataSql := `SELECT id,name,parent_id FROM department WHERE company_id = ? AND delete_at = 0 ` |
20 | + cond = append(cond, companyid) | ||
21 | + if departmentid >= 0 { | ||
22 | + cond = append(cond, departmentid) | ||
23 | + where += ` And parent_id=? ` | ||
24 | + } | ||
25 | + err = utils.ExecuteQueryAll(&departs, dataSql+where, cond...) | ||
18 | if err != nil { | 26 | if err != nil { |
19 | e := fmt.Errorf("EXECUTE SQL err:%s", err) | 27 | e := fmt.Errorf("EXECUTE SQL err:%s", err) |
20 | log.Error(e.Error()) | 28 | log.Error(e.Error()) |
@@ -380,7 +380,7 @@ func GetDepartmentUser(companyid int64, departmentid int64) ([]protocol.DepartUs | @@ -380,7 +380,7 @@ func GetDepartmentUser(companyid int64, departmentid int64) ([]protocol.DepartUs | ||
380 | department, err = models.GetDepartmentById(departmentid) | 380 | department, err = models.GetDepartmentById(departmentid) |
381 | if err != nil { | 381 | if err != nil { |
382 | log.Error("获取部门失败:%s", err) | 382 | log.Error("获取部门失败:%s", err) |
383 | - return nil, protocol.NewErrWithMessage("1") | 383 | + return nil, nil |
384 | } | 384 | } |
385 | if department.CompanyId != companyid { | 385 | if department.CompanyId != companyid { |
386 | log.Error("deparment.CompanyId err") | 386 | log.Error("deparment.CompanyId err") |
-
请 注册 或 登录 后发表评论