2020-06-15 14:50:39 +02:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
2021-03-01 08:48:50 +01:00
|
|
|
"github.com/caos/zitadel/internal/domain"
|
2020-06-15 14:50:39 +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-06-15 14:50:39 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
type ProjectSearchRequest proj_model.ProjectViewSearchRequest
|
|
|
|
type ProjectSearchQuery proj_model.ProjectViewSearchQuery
|
|
|
|
type ProjectSearchKey proj_model.ProjectViewSearchKey
|
|
|
|
|
|
|
|
func (req ProjectSearchRequest) GetLimit() uint64 {
|
|
|
|
return req.Limit
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ProjectSearchRequest) GetOffset() uint64 {
|
|
|
|
return req.Offset
|
|
|
|
}
|
|
|
|
|
2020-06-25 08:01:13 +02:00
|
|
|
func (req ProjectSearchRequest) GetSortingColumn() repository.ColumnKey {
|
2020-06-23 14:47:47 +02:00
|
|
|
if req.SortingColumn == proj_model.ProjectViewSearchKeyUnspecified {
|
2020-06-15 14:50:39 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return ProjectSearchKey(req.SortingColumn)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ProjectSearchRequest) GetAsc() bool {
|
|
|
|
return req.Asc
|
|
|
|
}
|
|
|
|
|
2020-06-25 08:01:13 +02:00
|
|
|
func (req ProjectSearchRequest) GetQueries() []repository.SearchQuery {
|
|
|
|
result := make([]repository.SearchQuery, len(req.Queries))
|
2020-06-15 14:50:39 +02:00
|
|
|
for i, q := range req.Queries {
|
|
|
|
result[i] = ProjectSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2020-06-25 08:01:13 +02:00
|
|
|
func (req ProjectSearchQuery) GetKey() repository.ColumnKey {
|
2020-06-15 14:50:39 +02:00
|
|
|
return ProjectSearchKey(req.Key)
|
|
|
|
}
|
|
|
|
|
2021-03-01 08:48:50 +01:00
|
|
|
func (req ProjectSearchQuery) GetMethod() domain.SearchMethod {
|
2020-06-15 14:50:39 +02:00
|
|
|
return req.Method
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ProjectSearchQuery) GetValue() interface{} {
|
|
|
|
return req.Value
|
|
|
|
}
|
|
|
|
|
|
|
|
func (key ProjectSearchKey) ToColumnName() string {
|
|
|
|
switch proj_model.ProjectViewSearchKey(key) {
|
2020-06-23 14:47:47 +02:00
|
|
|
case proj_model.ProjectViewSearchKeyName:
|
2020-06-15 14:50:39 +02:00
|
|
|
return ProjectKeyName
|
2020-06-23 14:47:47 +02:00
|
|
|
case proj_model.ProjectViewSearchKeyProjectID:
|
2020-06-15 14:50:39 +02:00
|
|
|
return ProjectKeyProjectID
|
2020-06-23 14:47:47 +02:00
|
|
|
case proj_model.ProjectViewSearchKeyResourceOwner:
|
2020-06-15 14:50:39 +02:00
|
|
|
return ProjectKeyResourceOwner
|
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|