2020-05-11 12:16:29 +02:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
2021-03-01 08:48:50 +01:00
|
|
|
"github.com/caos/zitadel/internal/domain"
|
2020-05-11 12:16:29 +02:00
|
|
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
2020-06-25 08:01:13 +02:00
|
|
|
"github.com/caos/zitadel/internal/view/repository"
|
2020-05-11 12:16:29 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type ProjectMemberSearchRequest proj_model.ProjectMemberSearchRequest
|
|
|
|
type ProjectMemberSearchQuery proj_model.ProjectMemberSearchQuery
|
|
|
|
type ProjectMemberSearchKey proj_model.ProjectMemberSearchKey
|
|
|
|
|
|
|
|
func (req ProjectMemberSearchRequest) GetLimit() uint64 {
|
|
|
|
return req.Limit
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ProjectMemberSearchRequest) GetOffset() uint64 {
|
|
|
|
return req.Offset
|
|
|
|
}
|
|
|
|
|
2020-06-25 08:01:13 +02:00
|
|
|
func (req ProjectMemberSearchRequest) GetSortingColumn() repository.ColumnKey {
|
2020-06-23 14:47:47 +02:00
|
|
|
if req.SortingColumn == proj_model.ProjectMemberSearchKeyUnspecified {
|
2020-05-11 12:16:29 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return ProjectMemberSearchKey(req.SortingColumn)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ProjectMemberSearchRequest) GetAsc() bool {
|
|
|
|
return req.Asc
|
|
|
|
}
|
|
|
|
|
2020-06-25 08:01:13 +02:00
|
|
|
func (req ProjectMemberSearchRequest) GetQueries() []repository.SearchQuery {
|
|
|
|
result := make([]repository.SearchQuery, len(req.Queries))
|
2020-05-11 12:16:29 +02:00
|
|
|
for i, q := range req.Queries {
|
|
|
|
result[i] = ProjectMemberSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2020-06-25 08:01:13 +02:00
|
|
|
func (req ProjectMemberSearchQuery) GetKey() repository.ColumnKey {
|
2020-05-11 12:16:29 +02:00
|
|
|
return ProjectMemberSearchKey(req.Key)
|
|
|
|
}
|
|
|
|
|
2021-03-01 08:48:50 +01:00
|
|
|
func (req ProjectMemberSearchQuery) GetMethod() domain.SearchMethod {
|
2020-05-11 12:16:29 +02:00
|
|
|
return req.Method
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ProjectMemberSearchQuery) GetValue() interface{} {
|
|
|
|
return req.Value
|
|
|
|
}
|
|
|
|
|
|
|
|
func (key ProjectMemberSearchKey) ToColumnName() string {
|
|
|
|
switch proj_model.ProjectMemberSearchKey(key) {
|
2020-06-23 14:47:47 +02:00
|
|
|
case proj_model.ProjectMemberSearchKeyEmail:
|
2020-05-11 12:16:29 +02:00
|
|
|
return ProjectMemberKeyEmail
|
2020-06-23 14:47:47 +02:00
|
|
|
case proj_model.ProjectMemberSearchKeyFirstName:
|
2020-05-11 12:16:29 +02:00
|
|
|
return ProjectMemberKeyFirstName
|
2020-06-23 14:47:47 +02:00
|
|
|
case proj_model.ProjectMemberSearchKeyLastName:
|
2020-05-11 12:16:29 +02:00
|
|
|
return ProjectMemberKeyLastName
|
2020-06-23 14:47:47 +02:00
|
|
|
case proj_model.ProjectMemberSearchKeyUserName:
|
2020-05-11 12:16:29 +02:00
|
|
|
return ProjectMemberKeyUserName
|
2020-06-23 14:47:47 +02:00
|
|
|
case proj_model.ProjectMemberSearchKeyUserID:
|
2020-05-11 12:16:29 +02:00
|
|
|
return ProjectMemberKeyUserID
|
2020-06-23 14:47:47 +02:00
|
|
|
case proj_model.ProjectMemberSearchKeyProjectID:
|
2020-05-11 12:16:29 +02:00
|
|
|
return ProjectMemberKeyProjectID
|
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|