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