2021-01-04 14:52:13 +01:00
|
|
|
package query
|
|
|
|
|
|
|
|
import (
|
2021-12-14 08:19:02 +01:00
|
|
|
"time"
|
|
|
|
|
2024-04-03 13:43:43 +03:00
|
|
|
sq "github.com/Masterminds/squirrel"
|
|
|
|
|
2022-08-31 09:52:43 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/database"
|
2023-04-11 17:56:51 +02:00
|
|
|
"github.com/zitadel/zitadel/internal/domain"
|
2021-01-04 14:52:13 +01:00
|
|
|
)
|
|
|
|
|
2021-12-14 08:19:02 +01: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) {
|
2023-10-19 12:19:10 +02:00
|
|
|
return NewTextQuery(membershipUserID, value, TextEquals)
|
2021-12-14 08:19:02 +01:00
|
|
|
}
|
|
|
|
func NewMemberResourceOwnerSearchQuery(value string) (SearchQuery, error) {
|
2023-10-19 12:19:10 +02:00
|
|
|
return NewTextQuery(membershipResourceOwner, value, TextEquals)
|
2021-12-14 08:19:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
type Members struct {
|
|
|
|
SearchResponse
|
|
|
|
Members []*Member
|
|
|
|
}
|
|
|
|
|
|
|
|
type Member struct {
|
|
|
|
CreationDate time.Time
|
|
|
|
ChangeDate time.Time
|
|
|
|
Sequence uint64
|
|
|
|
ResourceOwner string
|
|
|
|
|
|
|
|
UserID string
|
2023-10-19 12:19:10 +02:00
|
|
|
Roles database.TextArray[string]
|
2021-12-14 08:19:02 +01:00
|
|
|
PreferredLoginName string
|
|
|
|
Email string
|
|
|
|
FirstName string
|
|
|
|
LastName string
|
|
|
|
DisplayName string
|
|
|
|
AvatarURL string
|
2023-04-11 17:56:51 +02:00
|
|
|
UserType domain.UserType
|
2021-12-14 08:19:02 +01:00
|
|
|
}
|