...
|
...
|
@@ -3,6 +3,8 @@ package repository |
|
|
import (
|
|
|
"fmt"
|
|
|
"github.com/go-pg/pg/v10"
|
|
|
"github.com/go-pg/pg/v10/orm"
|
|
|
query2 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/application/cooperationProject/query"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/infrastructure/utils"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-cooperation/pkg/log"
|
|
|
"time"
|
...
|
...
|
@@ -266,6 +268,39 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int |
|
|
if cooperationProjectUndertakerType, ok := queryOptions["cooperationProjectUndertakerType"]; ok && cooperationProjectUndertakerType.(int32) != 0 {
|
|
|
query.Where(`cooperation_project.cooperation_project_undertaker_types @> '{?}'`, cooperationProjectUndertakerType)
|
|
|
}
|
|
|
if cooperationProjectUndertakerTypes, ok := queryOptions["cooperationProjectUndertakerTypes"]; ok && len(cooperationProjectUndertakerTypes.([]int32)) > 0 {
|
|
|
query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
|
|
|
for _, cooperationProjectUndertakerType := range cooperationProjectUndertakerTypes.([]int32) {
|
|
|
q.WhereOr(`cooperation_project.cooperation_project_undertaker_types @> '{?}'`, cooperationProjectUndertakerType)
|
|
|
}
|
|
|
return q, nil
|
|
|
})
|
|
|
}
|
|
|
if searchCooperationProjectExtQueries, ok := queryOptions["searchCooperationProjectExtQueries"]; ok && len(searchCooperationProjectExtQueries.([]*query2.SearchCooperationProjectExtQuery)) > 0 {
|
|
|
for _, searchCooperationProjectExtQuery := range searchCooperationProjectExtQueries.([]*query2.SearchCooperationProjectExtQuery) {
|
|
|
query.WhereOrGroup(func(q *orm.Query) (*orm.Query, error) {
|
|
|
if searchCooperationProjectExtQuery.ExtCompanyId != 0 {
|
|
|
q.Where("company->>'companyId' = '?'", searchCooperationProjectExtQuery.ExtCompanyId)
|
|
|
}
|
|
|
if searchCooperationProjectExtQuery.ExtOrgId != 0 {
|
|
|
q.Where("org->>'orgId' = '?'", searchCooperationProjectExtQuery.ExtOrgId)
|
|
|
}
|
|
|
if len(searchCooperationProjectExtQuery.ExtOrgIds) > 0 {
|
|
|
newOrgIds := utils.SliceItoa(searchCooperationProjectExtQuery.ExtOrgIds)
|
|
|
q.Where("org->>'orgId' in (?)", pg.In(newOrgIds))
|
|
|
}
|
|
|
if len(searchCooperationProjectExtQuery.ExtCooperationProjectUndertakerTypes) > 0 {
|
|
|
q.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
|
|
|
for _, cooperationProjectUndertakerType := range searchCooperationProjectExtQuery.ExtCooperationProjectUndertakerTypes {
|
|
|
q.WhereOr(`cooperation_project.cooperation_project_undertaker_types @> '{?}'`, cooperationProjectUndertakerType)
|
|
|
}
|
|
|
return q, nil
|
|
|
})
|
|
|
}
|
|
|
return q, nil
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" {
|
|
|
query.Where("department->>'departmentName' like ? ", fmt.Sprintf("%%%s%%", departmentName))
|
|
|
}
|
...
|
...
|
|