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 <[email protected]>

* Update internal/view/repository/general_query.go

Co-authored-by: Livio Amstutz <[email protected]>

Co-authored-by: Livio Amstutz <[email protected]>
This commit is contained in:
Fabi
2020-06-25 08:01:13 +02:00
committed by GitHub
co-authored by Livio Amstutz
parent b88f200434
commit 8bfa1a083c
90 changed files with 3555 additions and 1661 deletions
@@ -4,7 +4,7 @@ import (
global_model "github.com/caos/zitadel/internal/model"
proj_model "github.com/caos/zitadel/internal/project/model"
"github.com/caos/zitadel/internal/project/repository/view/model"
"github.com/caos/zitadel/internal/view"
"github.com/caos/zitadel/internal/view/repository"
"github.com/jinzhu/gorm"
)
@@ -12,7 +12,7 @@ func ProjectByID(db *gorm.DB, table, projectID string) (*model.ProjectView, erro
project := new(model.ProjectView)
projectIDQuery := model.ProjectSearchQuery{Key: proj_model.ProjectViewSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
query := view.PrepareGetByQuery(table, projectIDQuery)
query := repository.PrepareGetByQuery(table, projectIDQuery)
err := query(db, project)
return project, err
}
@@ -22,7 +22,7 @@ func ProjectsByResourceOwner(db *gorm.DB, table, orgID string) ([]*model.Project
queries := []*proj_model.ProjectViewSearchQuery{
&proj_model.ProjectViewSearchQuery{Key: proj_model.ProjectViewSearchKeyResourceOwner, Value: orgID, Method: global_model.SearchMethodEquals},
}
query := view.PrepareSearchQuery(table, model.ProjectSearchRequest{Queries: queries})
query := repository.PrepareSearchQuery(table, model.ProjectSearchRequest{Queries: queries})
_, err := query(db, &projects)
if err != nil {
return nil, err
@@ -32,7 +32,7 @@ func ProjectsByResourceOwner(db *gorm.DB, table, orgID string) ([]*model.Project
func SearchProjects(db *gorm.DB, table string, req *proj_model.ProjectViewSearchRequest) ([]*model.ProjectView, int, error) {
projects := make([]*model.ProjectView, 0)
query := view.PrepareSearchQuery(table, model.ProjectSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
query := repository.PrepareSearchQuery(table, model.ProjectSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
count, err := query(db, &projects)
if err != nil {
return nil, 0, err
@@ -41,11 +41,11 @@ func SearchProjects(db *gorm.DB, table string, req *proj_model.ProjectViewSearch
}
func PutProject(db *gorm.DB, table string, project *model.ProjectView) error {
save := view.PrepareSave(table)
save := repository.PrepareSave(table)
return save(db, project)
}
func DeleteProject(db *gorm.DB, table, projectID string) error {
delete := view.PrepareDeleteByKey(table, model.ProjectSearchKey(proj_model.ProjectViewSearchKeyProjectID), projectID)
delete := repository.PrepareDeleteByKey(table, model.ProjectSearchKey(proj_model.ProjectViewSearchKeyProjectID), projectID)
return delete(db)
}