作者 tangxvhui

赛季参与人设置 调整

... ... @@ -275,6 +275,15 @@ func (c RankController) RankRangeInfo() {
}
// companyid := c.GetCompanyId()
rspData := serverank.GetRankRangeInfo(param.Id)
switch rspData.RangeType {
case models.RANK_RANGE_TYPE_DEPARTMENT, models.RANK_RANGE_TYPE_DEPARTMENTALL:
//部门
rspData.RangeType = 2
case models.RANK_RANGE_TYPE_EMPLAYEE, models.RANK_RANGE_TYPE_EMPLAYEEALL:
//员工
rspData.RangeType = 1
}
msg = protocol.NewReturnResponse(rspData, nil)
return
}
... ...
... ... @@ -62,6 +62,14 @@ func GetUserCompanyById(id int64) (v *UserCompany, err error) {
return nil, err
}
func GetUserCompanyByIds(ids []int64) (v []UserCompany, err error) {
o := orm.NewOrm()
_, err = o.QueryTable(&UserCompany{}).
Filter("id__in", ids).
All(&v)
return v, err
}
// AddUserCompany insert a new UserCompany into database and returns
// last inserted Id on success.
func AddUserCompany(m *UserCompany, o orm.Ormer) (id int64, err error) {
... ...
... ... @@ -370,10 +370,32 @@ func GetRankRangeInfo(id int64) protocol.ResponseRankRangeInfo {
relationIds = append(relationIds, rankRangeData[i].RelationId)
}
switch rankRange.Type {
case models.RANK_RANGE_TYPE_DEPARTMENT, models.RANK_RANGE_TYPE_DEPARTMENTALL:
case models.RANK_RANGE_TYPE_DEPARTMENT:
//员工
case models.RANK_RANGE_TYPE_EMPLAYEE, models.RANK_RANGE_TYPE_EMPLAYEEALL:
users, err := models.GetUserCompanyByIds(relationIds)
if err != nil {
log.Error("获取员工数据失败")
}
for i := range users {
m := protocol.RankRangeRelation{
Id: users[i].Id,
Name: users[i].NickName,
}
rspdata.Relation = append(rspdata.Relation, m)
}
case models.RANK_RANGE_TYPE_EMPLAYEE:
//部门
departments, err := models.GetDepartmentByIds(relationIds)
if err != nil {
log.Error("获取部门数据失败")
}
for i := range departments {
m := protocol.RankRangeRelation{
Id: departments[i].Id,
Name: departments[i].Name,
}
rspdata.Relation = append(rspdata.Relation, m)
}
}
return rspdata
... ...