作者 郑周

管理员ID 过滤

... ... @@ -7,6 +7,7 @@ type QueryProjectCommand struct {
CycleId int64 `cname:"周期ID" json:"cycleId,string"`
Name string `cname:"项目名称" json:"name"`
State int `cname:"项目状态" json:"state"`
PmpIds []string `cname:"项目管理员ID" json:"pmpIds"`
PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"`
PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"`
}
... ...
... ... @@ -352,8 +352,7 @@ func (rs *EvaluationProjectService) StatisticCycleUser(in *command.StatisticCycl
_, users, _ := userRepository.Find(map[string]interface{}{"ids": userIds, "limit": len(userIds)})
departmentIdMap := map[int]int{}
for i := range users {
user := users[i]
for _, v := range user.DepartmentId {
for _, v := range users[i].DepartmentId {
departmentIdMap[v] = v
}
}
... ...
... ... @@ -145,6 +145,18 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{
query.Where("state = ?", v)
}
if v, ok := queryOptions["pmpIds"]; ok {
pmpIds := v.([]string)
if len(pmpIds) > 0 {
query.WhereGroup(func(query *pg.Query) (*pg.Query, error) {
for i := range pmpIds {
query.WhereOr("pmp_ids @> ?", pmpIds[i])
}
return query, nil
})
}
}
if v, ok := queryOptions["limit"].(int); ok {
query.Limit(v)
}
... ...