正在显示
4 个修改的文件
包含
71 行增加
和
9 行删除
@@ -137,6 +137,28 @@ func (c *CompanyController) DepartmentDelete() { | @@ -137,6 +137,28 @@ func (c *CompanyController) DepartmentDelete() { | ||
137 | return | 137 | return |
138 | } | 138 | } |
139 | 139 | ||
140 | +//DepartmentInfo 部门详情 | ||
141 | +//@router /department/info | ||
142 | +func (c *CompanyController) DepartmentInfo() { | ||
143 | + var msg *protocol.ResponseMessage | ||
144 | + defer func() { | ||
145 | + c.ResposeJson(msg) | ||
146 | + }() | ||
147 | + type Parameter struct { | ||
148 | + DepartmentId int64 `json:"id"` | ||
149 | + } | ||
150 | + var param Parameter | ||
151 | + if err := json.Unmarshal(c.Ctx.Input.RequestBody, ¶m); err != nil { | ||
152 | + log.Error("json 解析失败 err:%s", err) | ||
153 | + msg = protocol.BadRequestParam("1") | ||
154 | + return | ||
155 | + } | ||
156 | + companyID := c.GetCompanyId() | ||
157 | + detail, err := servecompany.GetDepartmentDetail(companyID, param.DepartmentId) | ||
158 | + msg = protocol.NewReturnResponse(detail, err) | ||
159 | + return | ||
160 | +} | ||
161 | + | ||
140 | // PositionAdd 添加职位 | 162 | // PositionAdd 添加职位 |
141 | // @router /position/add [post] | 163 | // @router /position/add [post] |
142 | func (c *CompanyController) PositionAdd() { | 164 | func (c *CompanyController) PositionAdd() { |
@@ -37,13 +37,12 @@ type DepartmentMember struct { | @@ -37,13 +37,12 @@ type DepartmentMember struct { | ||
37 | 37 | ||
38 | //ResponseDepartmentInfo ... | 38 | //ResponseDepartmentInfo ... |
39 | type ResponseDepartmentInfo struct { | 39 | type ResponseDepartmentInfo struct { |
40 | - ID int64 `json:"id"` | ||
41 | - CompanyID int64 `json:"company_id"` //公司 | ||
42 | - Name string `json:"name"` //部门名字 | ||
43 | - ParantID int64 `json:"parentId"` //父级部门Id | ||
44 | - ParentName string `json:"parentName"` | ||
45 | - Manages []DepartmentManager `json:"manages"` //部门管理员 | ||
46 | - Member int64 `json:"member"` //成员数 | 40 | + ID int64 `json:"id"` |
41 | + CompanyID int64 `json:"company_id"` //公司 | ||
42 | + Name string `json:"name"` //部门名字 | ||
43 | + ParantID int64 `json:"parentId"` //父级部门Id | ||
44 | + Manages []DepartmentManager `json:"manages"` //部门管理员 | ||
45 | + Member int64 `json:"member"` //成员数 | ||
47 | } | 46 | } |
48 | 47 | ||
49 | //ResponseDepartmentList .... | 48 | //ResponseDepartmentList .... |
@@ -51,6 +50,15 @@ type ResponseDepartmentList struct { | @@ -51,6 +50,15 @@ type ResponseDepartmentList struct { | ||
51 | List []ResponseDepartmentInfo `json:"lists"` | 50 | List []ResponseDepartmentInfo `json:"lists"` |
52 | } | 51 | } |
53 | 52 | ||
53 | +// 部门详情 | ||
54 | +type ResponseDepartmentDetail struct { | ||
55 | + ID int64 `json:"id"` | ||
56 | + Name string `json:"name"` //部门名字 | ||
57 | + ParantID int64 `json:"parentId"` //父级部门Id | ||
58 | + ParentName string `json:"parentName"` | ||
59 | + Manages []DepartmentManager `json:"manages"` //部门管理员 | ||
60 | +} | ||
61 | + | ||
54 | //RequestPositionAdd 添加职位 | 62 | //RequestPositionAdd 添加职位 |
55 | type RequestPositionAdd struct { | 63 | type RequestPositionAdd struct { |
56 | CompanyID int64 `json:"company_id"` | 64 | CompanyID int64 `json:"company_id"` |
@@ -21,6 +21,7 @@ func init() { | @@ -21,6 +21,7 @@ func init() { | ||
21 | beego.NSRouter("/edit", &controllers.CompanyController{}, "post:DepartmentUpdate"), | 21 | beego.NSRouter("/edit", &controllers.CompanyController{}, "post:DepartmentUpdate"), |
22 | beego.NSRouter("/delete", &controllers.CompanyController{}, "post:DepartmentDelete"), | 22 | beego.NSRouter("/delete", &controllers.CompanyController{}, "post:DepartmentDelete"), |
23 | beego.NSRouter("/user", &controllers.CompanyController{}, "post:DepartmentUser"), | 23 | beego.NSRouter("/user", &controllers.CompanyController{}, "post:DepartmentUser"), |
24 | + beego.NSRouter("/info", &controllers.CompanyController{}, "post:DepartmentInfo"), | ||
24 | ), | 25 | ), |
25 | beego.NSNamespace("/company", | 26 | beego.NSNamespace("/company", |
26 | beego.NSRouter("/current/edit", &controllers.CompanyController{}, "post:CurrentCompanyEdit"), | 27 | beego.NSRouter("/current/edit", &controllers.CompanyController{}, "post:CurrentCompanyEdit"), |
@@ -351,8 +351,7 @@ func DepartmentListAll(companyId int64) ([]protocol.ResponseDepartmentInfo, erro | @@ -351,8 +351,7 @@ func DepartmentListAll(companyId int64) ([]protocol.ResponseDepartmentInfo, erro | ||
351 | depart := protocol.ResponseDepartmentInfo{ | 351 | depart := protocol.ResponseDepartmentInfo{ |
352 | ID: v.Id, CompanyID: v.CompanyId, | 352 | ID: v.Id, CompanyID: v.CompanyId, |
353 | Name: v.Name, Member: cnt, | 353 | Name: v.Name, Member: cnt, |
354 | - ParantID: v.ParentId, | ||
355 | - ParentName: v.Name, | 354 | + ParantID: v.ParentId, |
356 | } | 355 | } |
357 | var manage []protocol.DepartmentManager | 356 | var manage []protocol.DepartmentManager |
358 | manage = v.GetManages() | 357 | manage = v.GetManages() |
@@ -402,3 +401,35 @@ func GetDepartmentUser(companyid int64, departmentid int64) ([]protocol.DepartUs | @@ -402,3 +401,35 @@ func GetDepartmentUser(companyid int64, departmentid int64) ([]protocol.DepartUs | ||
402 | } | 401 | } |
403 | return returnData, nil | 402 | return returnData, nil |
404 | } | 403 | } |
404 | + | ||
405 | +func GetDepartmentDetail(companyid int64, departmentId int64) (*protocol.ResponseDepartmentDetail, error) { | ||
406 | + var ( | ||
407 | + departinfo *models.Department | ||
408 | + err error | ||
409 | + parentDepart = &models.Department{} | ||
410 | + ) | ||
411 | + | ||
412 | + departinfo, err = models.GetDepartmentById(departmentId) | ||
413 | + if err != nil { | ||
414 | + log.Error("获取部门失败:%s", err) | ||
415 | + return nil, protocol.NewErrWithMessage("1") | ||
416 | + } | ||
417 | + if departinfo.CompanyId != companyid { | ||
418 | + log.Error("部门所属的公司id不匹配") | ||
419 | + return nil, protocol.NewErrWithMessage("1") | ||
420 | + } | ||
421 | + if departinfo.ParentId != 0 { | ||
422 | + parentDepart, err = models.GetDepartmentById(departinfo.ParentId) | ||
423 | + if err != nil { | ||
424 | + log.Error("获取父级部门失败:%s", err) | ||
425 | + } | ||
426 | + } | ||
427 | + rspData := &protocol.ResponseDepartmentDetail{ | ||
428 | + ID: departinfo.Id, | ||
429 | + Name: departinfo.Name, | ||
430 | + ParantID: departinfo.ParentId, | ||
431 | + ParentName: parentDepart.Name, | ||
432 | + Manages: departinfo.GetManages(), | ||
433 | + } | ||
434 | + return rspData, nil | ||
435 | +} |
-
请 注册 或 登录 后发表评论