2020-06-15 12:50:39 +00:00
|
|
|
package model
|
|
|
|
|
|
|
|
import (
|
2021-03-01 07:48:50 +00:00
|
|
|
"github.com/caos/zitadel/internal/domain"
|
2020-06-15 12:50:39 +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-06-15 12:50:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ProjectGrantSearchRequest proj_model.ProjectGrantViewSearchRequest
|
|
|
|
type ProjectGrantSearchQuery proj_model.ProjectGrantViewSearchQuery
|
|
|
|
type ProjectGrantSearchKey proj_model.ProjectGrantViewSearchKey
|
|
|
|
|
|
|
|
func (req ProjectGrantSearchRequest) GetLimit() uint64 {
|
|
|
|
return req.Limit
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ProjectGrantSearchRequest) GetOffset() uint64 {
|
|
|
|
return req.Offset
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (req ProjectGrantSearchRequest) GetSortingColumn() repository.ColumnKey {
|
2020-06-23 12:47:47 +00:00
|
|
|
if req.SortingColumn == proj_model.GrantedProjectSearchKeyUnspecified {
|
2020-06-15 12:50:39 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return ProjectGrantSearchKey(req.SortingColumn)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ProjectGrantSearchRequest) GetAsc() bool {
|
|
|
|
return req.Asc
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (req ProjectGrantSearchRequest) 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] = ProjectGrantSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (req ProjectGrantSearchQuery) GetKey() repository.ColumnKey {
|
2020-06-15 12:50:39 +00:00
|
|
|
return ProjectGrantSearchKey(req.Key)
|
|
|
|
}
|
|
|
|
|
2021-03-01 07:48:50 +00:00
|
|
|
func (req ProjectGrantSearchQuery) GetMethod() domain.SearchMethod {
|
2020-06-15 12:50:39 +00:00
|
|
|
return req.Method
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ProjectGrantSearchQuery) GetValue() interface{} {
|
|
|
|
return req.Value
|
|
|
|
}
|
|
|
|
|
|
|
|
func (key ProjectGrantSearchKey) ToColumnName() string {
|
|
|
|
switch proj_model.ProjectGrantViewSearchKey(key) {
|
2020-06-23 12:47:47 +00:00
|
|
|
case proj_model.GrantedProjectSearchKeyName:
|
2020-06-15 12:50:39 +00:00
|
|
|
return ProjectGrantKeyName
|
2020-06-23 12:47:47 +00:00
|
|
|
case proj_model.GrantedProjectSearchKeyGrantID:
|
2020-06-15 12:50:39 +00:00
|
|
|
return ProjectGrantKeyGrantID
|
2020-06-23 12:47:47 +00:00
|
|
|
case proj_model.GrantedProjectSearchKeyOrgID:
|
2020-06-15 12:50:39 +00:00
|
|
|
return ProjectGrantKeyOrgID
|
2020-06-23 12:47:47 +00:00
|
|
|
case proj_model.GrantedProjectSearchKeyProjectID:
|
2020-06-15 12:50:39 +00:00
|
|
|
return ProjectGrantKeyProjectID
|
2020-06-23 12:47:47 +00:00
|
|
|
case proj_model.GrantedProjectSearchKeyResourceOwner:
|
2020-06-15 12:50:39 +00:00
|
|
|
return ProjectGrantKeyResourceOwner
|
2020-06-23 12:47:47 +00:00
|
|
|
case proj_model.GrantedProjectSearchKeyRoleKeys:
|
2020-06-19 13:32:03 +00:00
|
|
|
return ProjectGrantKeyRoleKeys
|
2020-06-15 12:50:39 +00:00
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|