2020-05-11 10:16:29 +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-05-11 10:16:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
type ProjectRoleSearchRequest proj_model.ProjectRoleSearchRequest
|
|
|
|
type ProjectRoleSearchQuery proj_model.ProjectRoleSearchQuery
|
|
|
|
type ProjectRoleSearchKey proj_model.ProjectRoleSearchKey
|
|
|
|
|
|
|
|
func (req ProjectRoleSearchRequest) GetLimit() uint64 {
|
|
|
|
return req.Limit
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ProjectRoleSearchRequest) GetOffset() uint64 {
|
|
|
|
return req.Offset
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (req ProjectRoleSearchRequest) GetSortingColumn() repository.ColumnKey {
|
2020-06-23 12:47:47 +00:00
|
|
|
if req.SortingColumn == proj_model.ProjectRoleSearchKeyUnspecified {
|
2020-05-11 10:16:29 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return ProjectRoleSearchKey(req.SortingColumn)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ProjectRoleSearchRequest) GetAsc() bool {
|
|
|
|
return req.Asc
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (req ProjectRoleSearchRequest) 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] = ProjectRoleSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
|
|
|
}
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (req ProjectRoleSearchQuery) GetKey() repository.ColumnKey {
|
2020-05-11 10:16:29 +00:00
|
|
|
return ProjectRoleSearchKey(req.Key)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ProjectRoleSearchQuery) GetMethod() global_model.SearchMethod {
|
|
|
|
return req.Method
|
|
|
|
}
|
|
|
|
|
|
|
|
func (req ProjectRoleSearchQuery) GetValue() interface{} {
|
|
|
|
return req.Value
|
|
|
|
}
|
|
|
|
|
|
|
|
func (key ProjectRoleSearchKey) ToColumnName() string {
|
|
|
|
switch proj_model.ProjectRoleSearchKey(key) {
|
2020-06-23 12:47:47 +00:00
|
|
|
case proj_model.ProjectRoleSearchKeyKey:
|
2020-05-11 10:16:29 +00:00
|
|
|
return ProjectRoleKeyKey
|
2020-06-23 12:47:47 +00:00
|
|
|
case proj_model.ProjectRoleSearchKeyOrgID:
|
2020-05-11 10:16:29 +00:00
|
|
|
return ProjectRoleKeyOrgID
|
2020-06-23 12:47:47 +00:00
|
|
|
case proj_model.ProjectRoleSearchKeyProjectID:
|
2020-05-11 10:16:29 +00:00
|
|
|
return ProjectRoleKeyProjectID
|
2020-06-23 12:47:47 +00:00
|
|
|
case proj_model.ProjectRoleSearchKeyResourceOwner:
|
2020-05-11 10:16:29 +00:00
|
|
|
return ProjectRoleKeyResourceOwner
|
|
|
|
default:
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
}
|