作者 yangfu

共创项目修改

... ... @@ -52,6 +52,8 @@ type SearchCooperationProjectQuery struct {
UserId int64 `cname:"用户ID" json:"userId"`
// 用户基础数据id
UserBaseId int64 `cname:"用户基础数据ID" json:"userBaseId"`
// 额外的查询条件 0:不需要额外查询 1:额外查询
SearchCooperationProjectExtQueriesFlag int `cname:"额外的查询条件标识" json:"searchCooperationProjectExtQueriesFlag"`
// 额外的查询条件
SearchCooperationProjectExtQueries []*SearchCooperationProjectExtQuery `cname:"额外的查询条件" json:"searchCooperationProjectExtQueries"`
}
... ...
... ... @@ -276,33 +276,38 @@ func (repository *CooperationProjectRepository) Find(queryOptions map[string]int
return q, nil
})
}
if searchCooperationProjectExtQueries, ok := queryOptions["searchCooperationProjectExtQueries"]; ok && len(searchCooperationProjectExtQueries.([]*query2.SearchCooperationProjectExtQuery)) > 0 {
query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
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
})
}
return q, nil
})
if searchCooperationProjectExtQueriesFlag, ok := queryOptions["searchCooperationProjectExtQueriesFlag"]; ok && searchCooperationProjectExtQueriesFlag.(int) != 0 {
if searchCooperationProjectExtQueries, ok := queryOptions["searchCooperationProjectExtQueries"]; ok && len(searchCooperationProjectExtQueries.([]*query2.SearchCooperationProjectExtQuery)) > 0 {
query.WhereGroup(func(q *orm.Query) (*orm.Query, error) {
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
})
}
query.WhereOr(`cooperation_project.cooperation_project_undertaker_types @> '{?}'`, 3) //公开
return q, nil
})
} else {
query.Where(`cooperation_project.cooperation_project_undertaker_types @> '{?}'`, 3) //公开
}
}
if departmentName, ok := queryOptions["departmentName"]; ok && departmentName != "" {
query.Where("department->>'departmentName' like ? ", fmt.Sprintf("%%%s%%", departmentName))
... ...