作者 郑周

管理员ID 过滤

@@ -3,12 +3,13 @@ package command @@ -3,12 +3,13 @@ package command
3 import "github.com/beego/beego/v2/core/validation" 3 import "github.com/beego/beego/v2/core/validation"
4 4
5 type QueryProjectCommand struct { 5 type QueryProjectCommand struct {
6 - CompanyId int64 `cname:"公司ID" json:"companyId"`  
7 - CycleId int64 `cname:"周期ID" json:"cycleId,string"`  
8 - Name string `cname:"项目名称" json:"name"`  
9 - State int `cname:"项目状态" json:"state"`  
10 - PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"`  
11 - PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"` 6 + CompanyId int64 `cname:"公司ID" json:"companyId"`
  7 + CycleId int64 `cname:"周期ID" json:"cycleId,string"`
  8 + Name string `cname:"项目名称" json:"name"`
  9 + State int `cname:"项目状态" json:"state"`
  10 + PmpIds []string `cname:"项目管理员ID" json:"pmpIds"`
  11 + PageNumber int `cname:"分页页码" json:"pageNumber" valid:"Required"`
  12 + PageSize int `cname:"分页数量" json:"pageSize" valid:"Required"`
12 } 13 }
13 14
14 func (in *QueryProjectCommand) Valid(validation *validation.Validation) { 15 func (in *QueryProjectCommand) Valid(validation *validation.Validation) {
@@ -352,8 +352,7 @@ func (rs *EvaluationProjectService) StatisticCycleUser(in *command.StatisticCycl @@ -352,8 +352,7 @@ func (rs *EvaluationProjectService) StatisticCycleUser(in *command.StatisticCycl
352 _, users, _ := userRepository.Find(map[string]interface{}{"ids": userIds, "limit": len(userIds)}) 352 _, users, _ := userRepository.Find(map[string]interface{}{"ids": userIds, "limit": len(userIds)})
353 departmentIdMap := map[int]int{} 353 departmentIdMap := map[int]int{}
354 for i := range users { 354 for i := range users {
355 - user := users[i]  
356 - for _, v := range user.DepartmentId { 355 + for _, v := range users[i].DepartmentId {
357 departmentIdMap[v] = v 356 departmentIdMap[v] = v
358 } 357 }
359 } 358 }
@@ -145,6 +145,18 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{ @@ -145,6 +145,18 @@ func (repo *EvaluationProjectRepository) Find(queryOptions map[string]interface{
145 query.Where("state = ?", v) 145 query.Where("state = ?", v)
146 } 146 }
147 147
  148 + if v, ok := queryOptions["pmpIds"]; ok {
  149 + pmpIds := v.([]string)
  150 + if len(pmpIds) > 0 {
  151 + query.WhereGroup(func(query *pg.Query) (*pg.Query, error) {
  152 + for i := range pmpIds {
  153 + query.WhereOr("pmp_ids @> ?", pmpIds[i])
  154 + }
  155 + return query, nil
  156 + })
  157 + }
  158 + }
  159 +
148 if v, ok := queryOptions["limit"].(int); ok { 160 if v, ok := queryOptions["limit"].(int); ok {
149 query.Limit(v) 161 query.Limit(v)
150 } 162 }