zitadel/internal/user/repository/view/model/user_session_query.go
Livio Amstutz 1305c14e49
feat: handle instanceID in projections (#3442)
* feat: handle instanceID in projections

* rename functions

* fix key lock

* fix import
2022-04-19 08:26:12 +02:00

68 lines
1.8 KiB
Go

package model
import (
"github.com/caos/zitadel/internal/domain"
usr_model "github.com/caos/zitadel/internal/user/model"
"github.com/caos/zitadel/internal/view/repository"
)
type UserSessionSearchRequest usr_model.UserSessionSearchRequest
type UserSessionSearchQuery usr_model.UserSessionSearchQuery
type UserSessionSearchKey usr_model.UserSessionSearchKey
func (req UserSessionSearchRequest) GetLimit() uint64 {
return req.Limit
}
func (req UserSessionSearchRequest) GetOffset() uint64 {
return req.Offset
}
func (req UserSessionSearchRequest) GetSortingColumn() repository.ColumnKey {
if req.SortingColumn == usr_model.UserSessionSearchKeyUnspecified {
return nil
}
return UserSessionSearchKey(req.SortingColumn)
}
func (req UserSessionSearchRequest) GetAsc() bool {
return req.Asc
}
func (req UserSessionSearchRequest) GetQueries() []repository.SearchQuery {
result := make([]repository.SearchQuery, len(req.Queries))
for i, q := range req.Queries {
result[i] = UserSessionSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
}
return result
}
func (req UserSessionSearchQuery) GetKey() repository.ColumnKey {
return UserSessionSearchKey(req.Key)
}
func (req UserSessionSearchQuery) GetMethod() domain.SearchMethod {
return req.Method
}
func (req UserSessionSearchQuery) GetValue() interface{} {
return req.Value
}
func (key UserSessionSearchKey) ToColumnName() string {
switch usr_model.UserSessionSearchKey(key) {
case usr_model.UserSessionSearchKeyUserAgentID:
return UserSessionKeyUserAgentID
case usr_model.UserSessionSearchKeyUserID:
return UserSessionKeyUserID
case usr_model.UserSessionSearchKeyState:
return UserSessionKeyState
case usr_model.UserSessionSearchKeyResourceOwner:
return UserSessionKeyResourceOwner
case usr_model.UserSessionSearchKeyInstanceID:
return UserSessionKeyInstanceID
default:
return ""
}
}