|
@@ -3,6 +3,8 @@ package repository |
|
@@ -3,6 +3,8 @@ package repository |
3
|
import (
|
3
|
import (
|
4
|
"fmt"
|
4
|
"fmt"
|
5
|
"github.com/go-pg/pg/v10"
|
5
|
"github.com/go-pg/pg/v10"
|
|
|
6
|
+ "github.com/go-pg/pg/v10/orm"
|
|
|
7
|
+ query2 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/query"
|
6
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
|
9
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
|
8
|
"time"
|
10
|
"time"
|
|
@@ -266,6 +268,39 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int |
|
@@ -266,6 +268,39 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int |
266
|
if cooperationProjectUndertakerType, ok := queryOptions["cooperationProjectUndertakerType"]; ok && cooperationProjectUndertakerType.(int32) != 0 {
|
268
|
if cooperationProjectUndertakerType, ok := queryOptions["cooperationProjectUndertakerType"]; ok && cooperationProjectUndertakerType.(int32) != 0 {
|
267
|
query.Where(`cooperation_project.cooperation_project_undertaker_types @> '{?}'`, cooperationProjectUndertakerType)
|
269
|
query.Where(`cooperation_project.cooperation_project_undertaker_types @> '{?}'`, cooperationProjectUndertakerType)
|
268
|
}
|
270
|
}
|
|
|
271
|
+ if cooperationProjectUndertakerTypes, ok := queryOptions["cooperationProjectUndertakerTypes"]; ok && len(cooperationProjectUndertakerTypes.([]int32)) > 0 {
|
|
|
272
|
+ query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
|
|
|
273
|
+ for _, cooperationProjectUndertakerType := range cooperationProjectUndertakerTypes.([]int32) {
|
|
|
274
|
+ q.WhereOr(`cooperation_project.cooperation_project_undertaker_types @> '{?}'`, cooperationProjectUndertakerType)
|
|
|
275
|
+ }
|
|
|
276
|
+ return q, nil
|
|
|
277
|
+ })
|
|
|
278
|
+ }
|
|
|
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
|
+ }
|
|
|
303
|
+ }
|
269
|
if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" {
|
304
|
if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" {
|
270
|
query.Where("department->>'departmentName' like ? ", fmt.Sprintf("%%%s%%", departmentName))
|
305
|
query.Where("department->>'departmentName' like ? ", fmt.Sprintf("%%%s%%", departmentName))
|
271
|
}
|
306
|
}
|