mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-15 00:57:36 +00:00
feat: administrator (#271)
* feat: get views and failed events * feat: get views and failed events * feat: get views and failed events * Update internal/view/repository/sequence.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> * Update internal/view/repository/general_query.go Co-authored-by: Livio Amstutz <livio.a@gmail.com> Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package view
|
||||
|
||||
import (
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
"time"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
@@ -8,12 +9,11 @@ import (
|
||||
key_model "github.com/caos/zitadel/internal/key/model"
|
||||
"github.com/caos/zitadel/internal/key/repository/view/model"
|
||||
global_model "github.com/caos/zitadel/internal/model"
|
||||
"github.com/caos/zitadel/internal/view"
|
||||
)
|
||||
|
||||
func KeyByIDAndType(db *gorm.DB, table, keyID string, private bool) (*model.KeyView, error) {
|
||||
key := new(model.KeyView)
|
||||
query := view.PrepareGetByQuery(table,
|
||||
query := repository.PrepareGetByQuery(table,
|
||||
model.KeySearchQuery{Key: key_model.KeySearchKeyID, Method: global_model.SearchMethodEquals, Value: keyID},
|
||||
model.KeySearchQuery{Key: key_model.KeySearchKeyPrivate, Method: global_model.SearchMethodEquals, Value: private},
|
||||
)
|
||||
@@ -23,7 +23,7 @@ func KeyByIDAndType(db *gorm.DB, table, keyID string, private bool) (*model.KeyV
|
||||
|
||||
func GetSigningKey(db *gorm.DB, table string) (*model.KeyView, error) {
|
||||
key := new(model.KeyView)
|
||||
query := view.PrepareGetByQuery(table,
|
||||
query := repository.PrepareGetByQuery(table,
|
||||
model.KeySearchQuery{Key: key_model.KeySearchKeyPrivate, Method: global_model.SearchMethodEquals, Value: true},
|
||||
model.KeySearchQuery{Key: key_model.KeySearchKeyUsage, Method: global_model.SearchMethodEquals, Value: key_model.KeyUsageSigning},
|
||||
model.KeySearchQuery{Key: key_model.KeySearchKeyExpiry, Method: global_model.SearchMethodGreaterThan, Value: time.Now().UTC()},
|
||||
@@ -34,7 +34,7 @@ func GetSigningKey(db *gorm.DB, table string) (*model.KeyView, error) {
|
||||
|
||||
func GetActivePublicKeys(db *gorm.DB, table string) ([]*model.KeyView, error) {
|
||||
keys := make([]*model.KeyView, 0)
|
||||
query := view.PrepareSearchQuery(table,
|
||||
query := repository.PrepareSearchQuery(table,
|
||||
model.KeySearchRequest{
|
||||
Queries: []*key_model.KeySearchQuery{
|
||||
{Key: key_model.KeySearchKeyPrivate, Method: global_model.SearchMethodEquals, Value: false},
|
||||
@@ -48,7 +48,7 @@ func GetActivePublicKeys(db *gorm.DB, table string) ([]*model.KeyView, error) {
|
||||
}
|
||||
|
||||
func PutKeys(db *gorm.DB, table string, privateKey, publicKey *model.KeyView) error {
|
||||
save := view.PrepareSave(table)
|
||||
save := repository.PrepareSave(table)
|
||||
err := save(db, privateKey)
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -57,14 +57,14 @@ func PutKeys(db *gorm.DB, table string, privateKey, publicKey *model.KeyView) er
|
||||
}
|
||||
|
||||
func DeleteKey(db *gorm.DB, table, keyID string, private bool) error {
|
||||
delete := view.PrepareDeleteByKeys(table,
|
||||
view.Key{Key: model.KeySearchKey(key_model.KeySearchKeyID), Value: keyID},
|
||||
view.Key{Key: model.KeySearchKey(key_model.KeySearchKeyPrivate), Value: private},
|
||||
delete := repository.PrepareDeleteByKeys(table,
|
||||
repository.Key{Key: model.KeySearchKey(key_model.KeySearchKeyID), Value: keyID},
|
||||
repository.Key{Key: model.KeySearchKey(key_model.KeySearchKeyPrivate), Value: private},
|
||||
)
|
||||
return delete(db)
|
||||
}
|
||||
|
||||
func DeleteKeyPair(db *gorm.DB, table, keyID string) error {
|
||||
delete := view.PrepareDeleteByKey(table, model.KeySearchKey(key_model.KeySearchKeyID), keyID)
|
||||
delete := repository.PrepareDeleteByKey(table, model.KeySearchKey(key_model.KeySearchKeyID), keyID)
|
||||
return delete(db)
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package model
|
||||
import (
|
||||
key_model "github.com/caos/zitadel/internal/key/model"
|
||||
global_model "github.com/caos/zitadel/internal/model"
|
||||
"github.com/caos/zitadel/internal/view"
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
)
|
||||
|
||||
type KeySearchRequest key_model.KeySearchRequest
|
||||
@@ -18,7 +18,7 @@ func (req KeySearchRequest) GetOffset() uint64 {
|
||||
return req.Offset
|
||||
}
|
||||
|
||||
func (req KeySearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
func (req KeySearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||
if req.SortingColumn == key_model.KeySearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
@@ -29,15 +29,15 @@ func (req KeySearchRequest) GetAsc() bool {
|
||||
return req.Asc
|
||||
}
|
||||
|
||||
func (req KeySearchRequest) GetQueries() []view.SearchQuery {
|
||||
result := make([]view.SearchQuery, len(req.Queries))
|
||||
func (req KeySearchRequest) GetQueries() []repository.SearchQuery {
|
||||
result := make([]repository.SearchQuery, len(req.Queries))
|
||||
for i, q := range req.Queries {
|
||||
result[i] = KeySearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (req KeySearchQuery) GetKey() view.ColumnKey {
|
||||
func (req KeySearchQuery) GetKey() repository.ColumnKey {
|
||||
return KeySearchKey(req.Key)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user