2020-05-11 10:16:29 +00:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
2021-03-01 07:48:50 +00:00
|
|
|
"github.com/caos/zitadel/internal/domain"
|
2020-05-11 10:16:29 +00:00
|
|
|
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-05-11 10:16:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ApplicationSearchRequest proj_model.ApplicationSearchRequest
|
|
|
|
type ApplicationSearchQuery proj_model.ApplicationSearchQuery
|
2020-06-23 12:47:47 +00:00
|
|
|
type ApplicationSearchKey proj_model.AppSearchKey
|
2020-05-11 10:16:29 +00:00
|
|
|
|
|
|
|
func (req ApplicationSearchRequest) GetLimit() uint64 {
|
|
|
|
return req.Limit
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ApplicationSearchRequest) GetOffset() uint64 {
|
|
|
|
return req.Offset
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (req ApplicationSearchRequest) GetSortingColumn() repository.ColumnKey {
|
2020-06-23 12:47:47 +00:00
|
|
|
if req.SortingColumn == proj_model.AppSearchKeyUnspecified {
|
2020-05-11 10:16:29 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return ApplicationSearchKey(req.SortingColumn)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ApplicationSearchRequest) GetAsc() bool {
|
|
|
|
return req.Asc
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (req ApplicationSearchRequest) GetQueries() []repository.SearchQuery {
|
|
|
|
result := make([]repository.SearchQuery, len(req.Queries))
|
2020-05-11 10:16:29 +00:00
|
|
|
for i, q := range req.Queries {
|
|
|
|
result[i] = ApplicationSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (req ApplicationSearchQuery) GetKey() repository.ColumnKey {
|
2020-05-11 10:16:29 +00:00
|
|
|
return ApplicationSearchKey(req.Key)
|
|
|
|
}
|
|
|
|
|
2021-03-01 07:48:50 +00:00
|
|
|
func (req ApplicationSearchQuery) GetMethod() domain.SearchMethod {
|
2020-05-11 10:16:29 +00:00
|
|
|
return req.Method
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ApplicationSearchQuery) GetValue() interface{} {
|
|
|
|
return req.Value
|
|
|
|
}
|
|
|
|
|
|
|
|
func (key ApplicationSearchKey) ToColumnName() string {
|
2020-06-23 12:47:47 +00:00
|
|
|
switch proj_model.AppSearchKey(key) {
|
|
|
|
case proj_model.AppSearchKeyAppID:
|
2020-05-11 10:16:29 +00:00
|
|
|
return ApplicationKeyID
|
2020-06-23 12:47:47 +00:00
|
|
|
case proj_model.AppSearchKeyName:
|
2020-05-11 10:16:29 +00:00
|
|
|
return ApplicationKeyName
|
2020-06-23 12:47:47 +00:00
|
|
|
case proj_model.AppSearchKeyProjectID:
|
2020-05-11 10:16:29 +00:00
|
|
|
return ApplicationKeyProjectID
|
2020-06-23 12:47:47 +00:00
|
|
|
case proj_model.AppSearchKeyOIDCClientID:
|
2020-05-11 10:16:29 +00:00
|
|
|
return ApplicationKeyOIDCClientID
|
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|