zitadel/internal/api/grpc/admin/org_converter.go
Livio Amstutz 3a63fb765a
fix: cleanup some todos (#3642)
* cleanup todo

* fix: some todos
2022-05-16 16:35:49 +02:00

36 lines
960 B
Go

package admin
import (
"github.com/zitadel/zitadel/internal/api/grpc/object"
org_grpc "github.com/zitadel/zitadel/internal/api/grpc/org"
"github.com/zitadel/zitadel/internal/query"
"github.com/zitadel/zitadel/pkg/grpc/admin"
"github.com/zitadel/zitadel/pkg/grpc/org"
)
func listOrgRequestToModel(req *admin.ListOrgsRequest) (*query.OrgSearchQueries, error) {
offset, limit, asc := object.ListQueryToModel(req.Query)
queries, err := org_grpc.OrgQueriesToModel(req.Queries)
if err != nil {
return nil, err
}
return &query.OrgSearchQueries{
SearchRequest: query.SearchRequest{
Offset: offset,
Limit: limit,
SortingColumn: fieldNameToOrgColumn(req.SortingColumn),
Asc: asc,
},
Queries: queries,
}, nil
}
func fieldNameToOrgColumn(fieldName org.OrgFieldName) query.Column {
switch fieldName {
case org.OrgFieldName_ORG_FIELD_NAME_NAME:
return query.OrgColumnName
default:
return query.Column{}
}
}