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 ProjectRoleSearchRequest proj_model.ProjectRoleSearchRequest
|
|
|
|
type ProjectRoleSearchQuery proj_model.ProjectRoleSearchQuery
|
|
|
|
type ProjectRoleSearchKey proj_model.ProjectRoleSearchKey
|
|
|
|
|
|
|
|
func (req ProjectRoleSearchRequest) GetLimit() uint64 {
|
|
|
|
return req.Limit
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ProjectRoleSearchRequest) GetOffset() uint64 {
|
|
|
|
return req.Offset
|
|
|
|
}
|
|
|
|
|
2020-06-25 08:01:13 +02:00
|
|
|
func (req ProjectRoleSearchRequest) GetSortingColumn() repository.ColumnKey {
|
2020-06-23 14:47:47 +02:00
|
|
|
if req.SortingColumn == proj_model.ProjectRoleSearchKeyUnspecified {
|
2020-05-11 12:16:29 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return ProjectRoleSearchKey(req.SortingColumn)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ProjectRoleSearchRequest) GetAsc() bool {
|
|
|
|
return req.Asc
|
|
|
|
}
|
|
|
|
|
2020-06-25 08:01:13 +02:00
|
|
|
func (req ProjectRoleSearchRequest) 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] = ProjectRoleSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2020-06-25 08:01:13 +02:00
|
|
|
func (req ProjectRoleSearchQuery) GetKey() repository.ColumnKey {
|
2020-05-11 12:16:29 +02:00
|
|
|
return ProjectRoleSearchKey(req.Key)
|
|
|
|
}
|
|
|
|
|
2021-03-01 08:48:50 +01:00
|
|
|
func (req ProjectRoleSearchQuery) GetMethod() domain.SearchMethod {
|
2020-05-11 12:16:29 +02:00
|
|
|
return req.Method
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ProjectRoleSearchQuery) GetValue() interface{} {
|
|
|
|
return req.Value
|
|
|
|
}
|
|
|
|
|
|
|
|
func (key ProjectRoleSearchKey) ToColumnName() string {
|
|
|
|
switch proj_model.ProjectRoleSearchKey(key) {
|
2020-06-23 14:47:47 +02:00
|
|
|
case proj_model.ProjectRoleSearchKeyKey:
|
2020-05-11 12:16:29 +02:00
|
|
|
return ProjectRoleKeyKey
|
2020-06-23 14:47:47 +02:00
|
|
|
case proj_model.ProjectRoleSearchKeyOrgID:
|
2020-05-11 12:16:29 +02:00
|
|
|
return ProjectRoleKeyOrgID
|
2020-06-23 14:47:47 +02:00
|
|
|
case proj_model.ProjectRoleSearchKeyProjectID:
|
2020-05-11 12:16:29 +02:00
|
|
|
return ProjectRoleKeyProjectID
|
2020-06-23 14:47:47 +02:00
|
|
|
case proj_model.ProjectRoleSearchKeyResourceOwner:
|
2020-05-11 12:16:29 +02:00
|
|
|
return ProjectRoleKeyResourceOwner
|
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|