zitadel/internal/query/member.go
Livio Amstutz e99b7f4972
fix: move activity log to queries and remove old code (#3096)
* move changes to queries and remove old code

* fix changes query

* remove unused code

* fix sorting

* fix sorting

* refactor and remove old code

* remove accidental go.mod replace

* add missing file

* remove listDetail from ChangesResponse
2022-01-26 10:16:33 +01:00

78 lines
1.7 KiB
Go

package query
import (
"time"
"github.com/caos/zitadel/internal/query/projection"
sq "github.com/Masterminds/squirrel"
)
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
Roles []string
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,
}
)