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 ApplicationSearchRequest proj_model.ApplicationSearchRequest
|
|
|
|
type ApplicationSearchQuery proj_model.ApplicationSearchQuery
|
2020-06-23 14:47:47 +02:00
|
|
|
type ApplicationSearchKey proj_model.AppSearchKey
|
2020-05-11 12:16:29 +02:00
|
|
|
|
|
|
|
func (req ApplicationSearchRequest) GetLimit() uint64 {
|
|
|
|
return req.Limit
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ApplicationSearchRequest) GetOffset() uint64 {
|
|
|
|
return req.Offset
|
|
|
|
}
|
|
|
|
|
2020-06-25 08:01:13 +02:00
|
|
|
func (req ApplicationSearchRequest) GetSortingColumn() repository.ColumnKey {
|
2020-06-23 14:47:47 +02:00
|
|
|
if req.SortingColumn == proj_model.AppSearchKeyUnspecified {
|
2020-05-11 12:16:29 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return ApplicationSearchKey(req.SortingColumn)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ApplicationSearchRequest) GetAsc() bool {
|
|
|
|
return req.Asc
|
|
|
|
}
|
|
|
|
|
2020-06-25 08:01:13 +02:00
|
|
|
func (req ApplicationSearchRequest) 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] = ApplicationSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2020-06-25 08:01:13 +02:00
|
|
|
func (req ApplicationSearchQuery) GetKey() repository.ColumnKey {
|
2020-05-11 12:16:29 +02:00
|
|
|
return ApplicationSearchKey(req.Key)
|
|
|
|
}
|
|
|
|
|
2021-03-01 08:48:50 +01:00
|
|
|
func (req ApplicationSearchQuery) GetMethod() domain.SearchMethod {
|
2020-05-11 12:16:29 +02:00
|
|
|
return req.Method
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ApplicationSearchQuery) GetValue() interface{} {
|
|
|
|
return req.Value
|
|
|
|
}
|
|
|
|
|
|
|
|
func (key ApplicationSearchKey) ToColumnName() string {
|
2020-06-23 14:47:47 +02:00
|
|
|
switch proj_model.AppSearchKey(key) {
|
|
|
|
case proj_model.AppSearchKeyAppID:
|
2020-05-11 12:16:29 +02:00
|
|
|
return ApplicationKeyID
|
2020-06-23 14:47:47 +02:00
|
|
|
case proj_model.AppSearchKeyName:
|
2020-05-11 12:16:29 +02:00
|
|
|
return ApplicationKeyName
|
2020-06-23 14:47:47 +02:00
|
|
|
case proj_model.AppSearchKeyProjectID:
|
2020-05-11 12:16:29 +02:00
|
|
|
return ApplicationKeyProjectID
|
2020-06-23 14:47:47 +02:00
|
|
|
case proj_model.AppSearchKeyOIDCClientID:
|
2020-05-11 12:16:29 +02:00
|
|
|
return ApplicationKeyOIDCClientID
|
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|