mirror of
https://github.com/andwati/zitadel.git
synced 2026-12-05 02:18:48 +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 <[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:
@@ -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"
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ func ProjectGrantByProjectAndOrg(db *gorm.DB, table, projectID, orgID string) (*
|
||||
|
||||
projectIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GrantedProjectSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
||||
orgIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GrantedProjectSearchKeyOrgID, Value: orgID, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, projectIDQuery, orgIDQuery)
|
||||
query := repository.PrepareGetByQuery(table, projectIDQuery, orgIDQuery)
|
||||
err := query(db, project)
|
||||
return project, err
|
||||
}
|
||||
@@ -21,7 +21,7 @@ func ProjectGrantByProjectAndOrg(db *gorm.DB, table, projectID, orgID string) (*
|
||||
func ProjectGrantByID(db *gorm.DB, table, grantID string) (*model.ProjectGrantView, error) {
|
||||
project := new(model.ProjectGrantView)
|
||||
grantIDQuery := model.ProjectGrantSearchQuery{Key: proj_model.GrantedProjectSearchKeyGrantID, Value: grantID, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, grantIDQuery)
|
||||
query := repository.PrepareGetByQuery(table, grantIDQuery)
|
||||
err := query(db, project)
|
||||
return project, err
|
||||
}
|
||||
@@ -31,7 +31,7 @@ func ProjectGrantsByProjectID(db *gorm.DB, table, projectID string) ([]*model.Pr
|
||||
queries := []*proj_model.ProjectGrantViewSearchQuery{
|
||||
&proj_model.ProjectGrantViewSearchQuery{Key: proj_model.GrantedProjectSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.ProjectGrantSearchRequest{Queries: queries})
|
||||
query := repository.PrepareSearchQuery(table, model.ProjectGrantSearchRequest{Queries: queries})
|
||||
_, err := query(db, &projects)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -45,7 +45,7 @@ func ProjectGrantsByProjectIDAndRoleKey(db *gorm.DB, table, projectID, roleKey s
|
||||
&proj_model.ProjectGrantViewSearchQuery{Key: proj_model.GrantedProjectSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
||||
&proj_model.ProjectGrantViewSearchQuery{Key: proj_model.GrantedProjectSearchKeyRoleKeys, Value: roleKey, Method: global_model.SearchMethodListContains},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.ProjectGrantSearchRequest{Queries: queries})
|
||||
query := repository.PrepareSearchQuery(table, model.ProjectGrantSearchRequest{Queries: queries})
|
||||
_, err := query(db, &projects)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -55,7 +55,7 @@ func ProjectGrantsByProjectIDAndRoleKey(db *gorm.DB, table, projectID, roleKey s
|
||||
|
||||
func SearchProjectGrants(db *gorm.DB, table string, req *proj_model.ProjectGrantViewSearchRequest) ([]*model.ProjectGrantView, int, error) {
|
||||
projects := make([]*model.ProjectGrantView, 0)
|
||||
query := view.PrepareSearchQuery(table, model.ProjectGrantSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||
query := repository.PrepareSearchQuery(table, model.ProjectGrantSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||
count, err := query(db, &projects)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
@@ -64,11 +64,11 @@ func SearchProjectGrants(db *gorm.DB, table string, req *proj_model.ProjectGrant
|
||||
}
|
||||
|
||||
func PutProjectGrant(db *gorm.DB, table string, project *model.ProjectGrantView) error {
|
||||
save := view.PrepareSave(table)
|
||||
save := repository.PrepareSave(table)
|
||||
return save(db, project)
|
||||
}
|
||||
|
||||
func DeleteProjectGrant(db *gorm.DB, table, grantID string) error {
|
||||
delete := view.PrepareDeleteByKey(table, model.ProjectSearchKey(proj_model.GrantedProjectSearchKeyGrantID), grantID)
|
||||
delete := repository.PrepareDeleteByKey(table, model.ProjectSearchKey(proj_model.GrantedProjectSearchKeyGrantID), grantID)
|
||||
return delete(db)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user