作者 陈志颖

fix:共创项目查询

@@ -277,29 +277,32 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int @@ -277,29 +277,32 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int
277 }) 277 })
278 } 278 }
279 if searchCooperationProjectExtQueries, ok := queryOptions["searchCooperationProjectExtQueries"]; ok && len(searchCooperationProjectExtQueries.([]*query2.SearchCooperationProjectExtQuery)) > 0 { 279 if searchCooperationProjectExtQueries, ok := queryOptions["searchCooperationProjectExtQueries"]; ok && len(searchCooperationProjectExtQueries.([]*query2.SearchCooperationProjectExtQuery)) > 0 {
280 - for _, searchCooperationProjectExtQuery := range searchCooperationProjectExtQueries.([]*query2.SearchCooperationProjectExtQuery) {  
281 - query.WhereOrGroup(func(q *orm.Query) (*orm.Query, error) {  
282 - if searchCooperationProjectExtQuery.ExtCompanyId != 0 {  
283 - q.Where("company->>'companyId' = '?'", searchCooperationProjectExtQuery.ExtCompanyId)  
284 - }  
285 - if searchCooperationProjectExtQuery.ExtOrgId != 0 {  
286 - q.Where("org->>'orgId' = '?'", searchCooperationProjectExtQuery.ExtOrgId)  
287 - }  
288 - if len(searchCooperationProjectExtQuery.ExtOrgIds) > 0 {  
289 - newOrgIds := utils.SliceItoa(searchCooperationProjectExtQuery.ExtOrgIds)  
290 - q.Where("org->>'orgId' in (?)", pg.In(newOrgIds))  
291 - }  
292 - if len(searchCooperationProjectExtQuery.ExtCooperationProjectUndertakerTypes) > 0 {  
293 - q.WhereGroup(func(q *orm.Query) (*orm.Query, error) {  
294 - for _, cooperationProjectUndertakerType := range searchCooperationProjectExtQuery.ExtCooperationProjectUndertakerTypes {  
295 - q.WhereOr(`cooperation_project.cooperation_project_undertaker_types @> '{?}'`, cooperationProjectUndertakerType)  
296 - }  
297 - return q, nil  
298 - })  
299 - }  
300 - return q, nil  
301 - })  
302 - } 280 + query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
  281 + for _, searchCooperationProjectExtQuery := range searchCooperationProjectExtQueries.([]*query2.SearchCooperationProjectExtQuery) {
  282 + query.WhereOrGroup(func(q *orm.Query) (*orm.Query, error) {
  283 + if searchCooperationProjectExtQuery.ExtCompanyId != 0 {
  284 + q.Where("company->>'companyId' = '?'", searchCooperationProjectExtQuery.ExtCompanyId)
  285 + }
  286 + if searchCooperationProjectExtQuery.ExtOrgId != 0 {
  287 + q.Where("org->>'orgId' = '?'", searchCooperationProjectExtQuery.ExtOrgId)
  288 + }
  289 + if len(searchCooperationProjectExtQuery.ExtOrgIds) > 0 {
  290 + newOrgIds := utils.SliceItoa(searchCooperationProjectExtQuery.ExtOrgIds)
  291 + q.Where("org->>'orgId' in (?)", pg.In(newOrgIds))
  292 + }
  293 + if len(searchCooperationProjectExtQuery.ExtCooperationProjectUndertakerTypes) > 0 {
  294 + q.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
  295 + for _, cooperationProjectUndertakerType := range searchCooperationProjectExtQuery.ExtCooperationProjectUndertakerTypes {
  296 + q.WhereOr(`cooperation_project.cooperation_project_undertaker_types @> '{?}'`, cooperationProjectUndertakerType)
  297 + }
  298 + return q, nil
  299 + })
  300 + }
  301 + return q, nil
  302 + })
  303 + }
  304 + return q, nil
  305 + })
303 } 306 }
304 if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" { 307 if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" {
305 query.Where("department->>'departmentName' like ? ", fmt.Sprintf("%%%s%%", departmentName)) 308 query.Where("department->>'departmentName' like ? ", fmt.Sprintf("%%%s%%", departmentName))