2021-01-04 13:52:13 +00:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
2021-12-14 07:19:02 +00:00
|
|
|
"time"
|
|
|
|
|
2022-08-31 07:52:43 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/database"
|
2022-04-26 23:01:45 +00:00
|
|
|
"github.com/zitadel/zitadel/internal/query/projection"
|
2021-12-16 13:25:38 +00:00
|
|
|
|
|
|
|
sq "github.com/Masterminds/squirrel"
|
2021-01-04 13:52:13 +00:00
|
|
|
)
|
|
|
|
|
2021-12-14 07:19:02 +00:00
|
|
|
type MembersQuery struct {
|
|
|
|
SearchRequest
|
|
|
|
Queries []SearchQuery
|
|
|
|
}
|
|
|
|
|
|
|
|
func (q *MembersQuery) toQuery(query sq.SelectBuilder) sq.SelectBuilder {
|
|
|
|
query = q.SearchRequest.toQuery(query)
|
|
|
|
for _, q := range q.Queries {
|
|
|
|
query = q.toQuery(query)
|
|
|
|
}
|
|
|
|
return query
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewMemberEmailSearchQuery(method TextComparison, value string) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(HumanEmailCol, value, method)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewMemberFirstNameSearchQuery(method TextComparison, value string) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(HumanFirstNameCol, value, method)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewMemberLastNameSearchQuery(method TextComparison, value string) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(HumanLastNameCol, value, method)
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewMemberUserIDSearchQuery(value string) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(memberUserID, value, TextEquals)
|
|
|
|
}
|
|
|
|
func NewMemberResourceOwnerSearchQuery(value string) (SearchQuery, error) {
|
|
|
|
return NewTextQuery(memberResourceOwner, value, TextEquals)
|
|
|
|
}
|
|
|
|
|
|
|
|
type Members struct {
|
|
|
|
SearchResponse
|
|
|
|
Members []*Member
|
|
|
|
}
|
|
|
|
|
|
|
|
type Member struct {
|
|
|
|
CreationDate time.Time
|
|
|
|
ChangeDate time.Time
|
|
|
|
Sequence uint64
|
|
|
|
ResourceOwner string
|
|
|
|
|
|
|
|
UserID string
|
2022-08-31 07:52:43 +00:00
|
|
|
Roles database.StringArray
|
2021-12-14 07:19:02 +00:00
|
|
|
PreferredLoginName string
|
|
|
|
Email string
|
|
|
|
FirstName string
|
|
|
|
LastName string
|
|
|
|
DisplayName string
|
|
|
|
AvatarURL string
|
|
|
|
}
|
|
|
|
|
|
|
|
var (
|
|
|
|
memberTableAlias = table{
|
|
|
|
name: "members",
|
|
|
|
alias: "members",
|
|
|
|
}
|
|
|
|
memberUserID = Column{
|
|
|
|
name: projection.MemberUserIDCol,
|
|
|
|
table: memberTableAlias,
|
|
|
|
}
|
|
|
|
memberResourceOwner = Column{
|
|
|
|
name: projection.MemberResourceOwner,
|
|
|
|
table: memberTableAlias,
|
|
|
|
}
|
|
|
|
)
|