正在显示
3 个修改的文件
包含
41 行增加
和
2 行删除
@@ -275,6 +275,15 @@ func (c RankController) RankRangeInfo() { | @@ -275,6 +275,15 @@ func (c RankController) RankRangeInfo() { | ||
275 | } | 275 | } |
276 | // companyid := c.GetCompanyId() | 276 | // companyid := c.GetCompanyId() |
277 | rspData := serverank.GetRankRangeInfo(param.Id) | 277 | rspData := serverank.GetRankRangeInfo(param.Id) |
278 | + switch rspData.RangeType { | ||
279 | + case models.RANK_RANGE_TYPE_DEPARTMENT, models.RANK_RANGE_TYPE_DEPARTMENTALL: | ||
280 | + //部门 | ||
281 | + rspData.RangeType = 2 | ||
282 | + case models.RANK_RANGE_TYPE_EMPLAYEE, models.RANK_RANGE_TYPE_EMPLAYEEALL: | ||
283 | + //员工 | ||
284 | + rspData.RangeType = 1 | ||
285 | + | ||
286 | + } | ||
278 | msg = protocol.NewReturnResponse(rspData, nil) | 287 | msg = protocol.NewReturnResponse(rspData, nil) |
279 | return | 288 | return |
280 | } | 289 | } |
@@ -62,6 +62,14 @@ func GetUserCompanyById(id int64) (v *UserCompany, err error) { | @@ -62,6 +62,14 @@ func GetUserCompanyById(id int64) (v *UserCompany, err error) { | ||
62 | return nil, err | 62 | return nil, err |
63 | } | 63 | } |
64 | 64 | ||
65 | +func GetUserCompanyByIds(ids []int64) (v []UserCompany, err error) { | ||
66 | + o := orm.NewOrm() | ||
67 | + _, err = o.QueryTable(&UserCompany{}). | ||
68 | + Filter("id__in", ids). | ||
69 | + All(&v) | ||
70 | + return v, err | ||
71 | +} | ||
72 | + | ||
65 | // AddUserCompany insert a new UserCompany into database and returns | 73 | // AddUserCompany insert a new UserCompany into database and returns |
66 | // last inserted Id on success. | 74 | // last inserted Id on success. |
67 | func AddUserCompany(m *UserCompany, o orm.Ormer) (id int64, err error) { | 75 | func AddUserCompany(m *UserCompany, o orm.Ormer) (id int64, err error) { |
@@ -370,10 +370,32 @@ func GetRankRangeInfo(id int64) protocol.ResponseRankRangeInfo { | @@ -370,10 +370,32 @@ func GetRankRangeInfo(id int64) protocol.ResponseRankRangeInfo { | ||
370 | relationIds = append(relationIds, rankRangeData[i].RelationId) | 370 | relationIds = append(relationIds, rankRangeData[i].RelationId) |
371 | } | 371 | } |
372 | switch rankRange.Type { | 372 | switch rankRange.Type { |
373 | - case models.RANK_RANGE_TYPE_DEPARTMENT, models.RANK_RANGE_TYPE_DEPARTMENTALL: | 373 | + case models.RANK_RANGE_TYPE_DEPARTMENT: |
374 | //员工 | 374 | //员工 |
375 | - case models.RANK_RANGE_TYPE_EMPLAYEE, models.RANK_RANGE_TYPE_EMPLAYEEALL: | 375 | + users, err := models.GetUserCompanyByIds(relationIds) |
376 | + if err != nil { | ||
377 | + log.Error("获取员工数据失败") | ||
378 | + } | ||
379 | + for i := range users { | ||
380 | + m := protocol.RankRangeRelation{ | ||
381 | + Id: users[i].Id, | ||
382 | + Name: users[i].NickName, | ||
383 | + } | ||
384 | + rspdata.Relation = append(rspdata.Relation, m) | ||
385 | + } | ||
386 | + case models.RANK_RANGE_TYPE_EMPLAYEE: | ||
376 | //部门 | 387 | //部门 |
388 | + departments, err := models.GetDepartmentByIds(relationIds) | ||
389 | + if err != nil { | ||
390 | + log.Error("获取部门数据失败") | ||
391 | + } | ||
392 | + for i := range departments { | ||
393 | + m := protocol.RankRangeRelation{ | ||
394 | + Id: departments[i].Id, | ||
395 | + Name: departments[i].Name, | ||
396 | + } | ||
397 | + rspdata.Relation = append(rspdata.Relation, m) | ||
398 | + } | ||
377 | } | 399 | } |
378 | return rspdata | 400 | return rspdata |
379 | 401 |
-
请 注册 或 登录 后发表评论