mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 01:47:33 +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:
@@ -4,13 +4,13 @@ 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"
|
||||
)
|
||||
|
||||
func ApplicationByID(db *gorm.DB, table, appID string) (*model.ApplicationView, error) {
|
||||
app := new(model.ApplicationView)
|
||||
query := view.PrepareGetByKey(table, model.ApplicationSearchKey(proj_model.AppSearchKeyAppID), appID)
|
||||
query := repository.PrepareGetByKey(table, model.ApplicationSearchKey(proj_model.AppSearchKeyAppID), appID)
|
||||
err := query(db, app)
|
||||
return app, err
|
||||
}
|
||||
@@ -18,7 +18,7 @@ func ApplicationByID(db *gorm.DB, table, appID string) (*model.ApplicationView,
|
||||
func ApplicationByOIDCClientID(db *gorm.DB, table, clientID string) (*model.ApplicationView, error) {
|
||||
app := new(model.ApplicationView)
|
||||
clientIDQuery := model.ApplicationSearchQuery{Key: proj_model.AppSearchKeyOIDCClientID, Value: clientID, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, clientIDQuery)
|
||||
query := repository.PrepareGetByQuery(table, clientIDQuery)
|
||||
err := query(db, app)
|
||||
return app, err
|
||||
}
|
||||
@@ -27,24 +27,24 @@ func ApplicationByProjectIDAndAppName(db *gorm.DB, table, projectID, appName str
|
||||
app := new(model.ApplicationView)
|
||||
projectIDQuery := model.ApplicationSearchQuery{Key: proj_model.AppSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
||||
appNameQuery := model.ApplicationSearchQuery{Key: proj_model.AppSearchKeyName, Value: appName, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, projectIDQuery, appNameQuery)
|
||||
query := repository.PrepareGetByQuery(table, projectIDQuery, appNameQuery)
|
||||
err := query(db, app)
|
||||
return app, err
|
||||
}
|
||||
|
||||
func SearchApplications(db *gorm.DB, table string, req *proj_model.ApplicationSearchRequest) ([]*model.ApplicationView, int, error) {
|
||||
apps := make([]*model.ApplicationView, 0)
|
||||
query := view.PrepareSearchQuery(table, model.ApplicationSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||
query := repository.PrepareSearchQuery(table, model.ApplicationSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||
count, err := query(db, &apps)
|
||||
return apps, count, err
|
||||
}
|
||||
|
||||
func PutApplication(db *gorm.DB, table string, app *model.ApplicationView) error {
|
||||
save := view.PrepareSave(table)
|
||||
save := repository.PrepareSave(table)
|
||||
return save(db, app)
|
||||
}
|
||||
|
||||
func DeleteApplication(db *gorm.DB, table, appID string) error {
|
||||
delete := view.PrepareDeleteByKey(table, model.ApplicationSearchKey(proj_model.AppSearchKeyAppID), appID)
|
||||
delete := repository.PrepareDeleteByKey(table, model.ApplicationSearchKey(proj_model.AppSearchKeyAppID), appID)
|
||||
return delete(db)
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package model
|
||||
import (
|
||||
global_model "github.com/caos/zitadel/internal/model"
|
||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||
"github.com/caos/zitadel/internal/view"
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
)
|
||||
|
||||
type ApplicationSearchRequest proj_model.ApplicationSearchRequest
|
||||
@@ -18,7 +18,7 @@ func (req ApplicationSearchRequest) GetOffset() uint64 {
|
||||
return req.Offset
|
||||
}
|
||||
|
||||
func (req ApplicationSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
func (req ApplicationSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||
if req.SortingColumn == proj_model.AppSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
@@ -29,15 +29,15 @@ func (req ApplicationSearchRequest) GetAsc() bool {
|
||||
return req.Asc
|
||||
}
|
||||
|
||||
func (req ApplicationSearchRequest) GetQueries() []view.SearchQuery {
|
||||
result := make([]view.SearchQuery, len(req.Queries))
|
||||
func (req ApplicationSearchRequest) GetQueries() []repository.SearchQuery {
|
||||
result := make([]repository.SearchQuery, len(req.Queries))
|
||||
for i, q := range req.Queries {
|
||||
result[i] = ApplicationSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (req ApplicationSearchQuery) GetKey() view.ColumnKey {
|
||||
func (req ApplicationSearchQuery) GetKey() repository.ColumnKey {
|
||||
return ApplicationSearchKey(req.Key)
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@ package model
|
||||
import (
|
||||
global_model "github.com/caos/zitadel/internal/model"
|
||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||
"github.com/caos/zitadel/internal/view"
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
)
|
||||
|
||||
type ProjectGrantMemberSearchRequest proj_model.ProjectGrantMemberSearchRequest
|
||||
@@ -18,7 +18,7 @@ func (req ProjectGrantMemberSearchRequest) GetOffset() uint64 {
|
||||
return req.Offset
|
||||
}
|
||||
|
||||
func (req ProjectGrantMemberSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
func (req ProjectGrantMemberSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||
if req.SortingColumn == proj_model.ProjectGrantMemberSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
@@ -29,15 +29,15 @@ func (req ProjectGrantMemberSearchRequest) GetAsc() bool {
|
||||
return req.Asc
|
||||
}
|
||||
|
||||
func (req ProjectGrantMemberSearchRequest) GetQueries() []view.SearchQuery {
|
||||
result := make([]view.SearchQuery, len(req.Queries))
|
||||
func (req ProjectGrantMemberSearchRequest) GetQueries() []repository.SearchQuery {
|
||||
result := make([]repository.SearchQuery, len(req.Queries))
|
||||
for i, q := range req.Queries {
|
||||
result[i] = ProjectGrantMemberSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (req ProjectGrantMemberSearchQuery) GetKey() view.ColumnKey {
|
||||
func (req ProjectGrantMemberSearchQuery) GetKey() repository.ColumnKey {
|
||||
return ProjectGrantMemberSearchKey(req.Key)
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@ package model
|
||||
import (
|
||||
global_model "github.com/caos/zitadel/internal/model"
|
||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||
"github.com/caos/zitadel/internal/view"
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
)
|
||||
|
||||
type ProjectGrantSearchRequest proj_model.ProjectGrantViewSearchRequest
|
||||
@@ -18,7 +18,7 @@ func (req ProjectGrantSearchRequest) GetOffset() uint64 {
|
||||
return req.Offset
|
||||
}
|
||||
|
||||
func (req ProjectGrantSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
func (req ProjectGrantSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||
if req.SortingColumn == proj_model.GrantedProjectSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
@@ -29,15 +29,15 @@ func (req ProjectGrantSearchRequest) GetAsc() bool {
|
||||
return req.Asc
|
||||
}
|
||||
|
||||
func (req ProjectGrantSearchRequest) GetQueries() []view.SearchQuery {
|
||||
result := make([]view.SearchQuery, len(req.Queries))
|
||||
func (req ProjectGrantSearchRequest) GetQueries() []repository.SearchQuery {
|
||||
result := make([]repository.SearchQuery, len(req.Queries))
|
||||
for i, q := range req.Queries {
|
||||
result[i] = ProjectGrantSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (req ProjectGrantSearchQuery) GetKey() view.ColumnKey {
|
||||
func (req ProjectGrantSearchQuery) GetKey() repository.ColumnKey {
|
||||
return ProjectGrantSearchKey(req.Key)
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@ package model
|
||||
import (
|
||||
global_model "github.com/caos/zitadel/internal/model"
|
||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||
"github.com/caos/zitadel/internal/view"
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
)
|
||||
|
||||
type ProjectMemberSearchRequest proj_model.ProjectMemberSearchRequest
|
||||
@@ -18,7 +18,7 @@ func (req ProjectMemberSearchRequest) GetOffset() uint64 {
|
||||
return req.Offset
|
||||
}
|
||||
|
||||
func (req ProjectMemberSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
func (req ProjectMemberSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||
if req.SortingColumn == proj_model.ProjectMemberSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
@@ -29,15 +29,15 @@ func (req ProjectMemberSearchRequest) GetAsc() bool {
|
||||
return req.Asc
|
||||
}
|
||||
|
||||
func (req ProjectMemberSearchRequest) GetQueries() []view.SearchQuery {
|
||||
result := make([]view.SearchQuery, len(req.Queries))
|
||||
func (req ProjectMemberSearchRequest) GetQueries() []repository.SearchQuery {
|
||||
result := make([]repository.SearchQuery, len(req.Queries))
|
||||
for i, q := range req.Queries {
|
||||
result[i] = ProjectMemberSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (req ProjectMemberSearchQuery) GetKey() view.ColumnKey {
|
||||
func (req ProjectMemberSearchQuery) GetKey() repository.ColumnKey {
|
||||
return ProjectMemberSearchKey(req.Key)
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@ package model
|
||||
import (
|
||||
global_model "github.com/caos/zitadel/internal/model"
|
||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||
"github.com/caos/zitadel/internal/view"
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
)
|
||||
|
||||
type ProjectSearchRequest proj_model.ProjectViewSearchRequest
|
||||
@@ -18,7 +18,7 @@ func (req ProjectSearchRequest) GetOffset() uint64 {
|
||||
return req.Offset
|
||||
}
|
||||
|
||||
func (req ProjectSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
func (req ProjectSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||
if req.SortingColumn == proj_model.ProjectViewSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
@@ -29,15 +29,15 @@ func (req ProjectSearchRequest) GetAsc() bool {
|
||||
return req.Asc
|
||||
}
|
||||
|
||||
func (req ProjectSearchRequest) GetQueries() []view.SearchQuery {
|
||||
result := make([]view.SearchQuery, len(req.Queries))
|
||||
func (req ProjectSearchRequest) GetQueries() []repository.SearchQuery {
|
||||
result := make([]repository.SearchQuery, len(req.Queries))
|
||||
for i, q := range req.Queries {
|
||||
result[i] = ProjectSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (req ProjectSearchQuery) GetKey() view.ColumnKey {
|
||||
func (req ProjectSearchQuery) GetKey() repository.ColumnKey {
|
||||
return ProjectSearchKey(req.Key)
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@ package model
|
||||
import (
|
||||
global_model "github.com/caos/zitadel/internal/model"
|
||||
proj_model "github.com/caos/zitadel/internal/project/model"
|
||||
"github.com/caos/zitadel/internal/view"
|
||||
"github.com/caos/zitadel/internal/view/repository"
|
||||
)
|
||||
|
||||
type ProjectRoleSearchRequest proj_model.ProjectRoleSearchRequest
|
||||
@@ -18,7 +18,7 @@ func (req ProjectRoleSearchRequest) GetOffset() uint64 {
|
||||
return req.Offset
|
||||
}
|
||||
|
||||
func (req ProjectRoleSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
func (req ProjectRoleSearchRequest) GetSortingColumn() repository.ColumnKey {
|
||||
if req.SortingColumn == proj_model.ProjectRoleSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
@@ -29,15 +29,15 @@ func (req ProjectRoleSearchRequest) GetAsc() bool {
|
||||
return req.Asc
|
||||
}
|
||||
|
||||
func (req ProjectRoleSearchRequest) GetQueries() []view.SearchQuery {
|
||||
result := make([]view.SearchQuery, len(req.Queries))
|
||||
func (req ProjectRoleSearchRequest) GetQueries() []repository.SearchQuery {
|
||||
result := make([]repository.SearchQuery, len(req.Queries))
|
||||
for i, q := range req.Queries {
|
||||
result[i] = ProjectRoleSearchQuery{Key: q.Key, Value: q.Value, Method: q.Method}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
func (req ProjectRoleSearchQuery) GetKey() view.ColumnKey {
|
||||
func (req ProjectRoleSearchQuery) GetKey() repository.ColumnKey {
|
||||
return ProjectRoleSearchKey(req.Key)
|
||||
}
|
||||
|
||||
|
@@ -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,14 +13,14 @@ func ProjectGrantMemberByIDs(db *gorm.DB, table, grantID, userID string) (*model
|
||||
|
||||
grantIDQuery := model.ProjectGrantMemberSearchQuery{Key: proj_model.ProjectGrantMemberSearchKeyGrantID, Value: grantID, Method: global_model.SearchMethodEquals}
|
||||
userIDQuery := model.ProjectGrantMemberSearchQuery{Key: proj_model.ProjectGrantMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, grantIDQuery, userIDQuery)
|
||||
query := repository.PrepareGetByQuery(table, grantIDQuery, userIDQuery)
|
||||
err := query(db, role)
|
||||
return role, err
|
||||
}
|
||||
|
||||
func SearchProjectGrantMembers(db *gorm.DB, table string, req *proj_model.ProjectGrantMemberSearchRequest) ([]*model.ProjectGrantMemberView, int, error) {
|
||||
roles := make([]*model.ProjectGrantMemberView, 0)
|
||||
query := view.PrepareSearchQuery(table, model.ProjectGrantMemberSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||
query := repository.PrepareSearchQuery(table, model.ProjectGrantMemberSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||
count, err := query(db, &roles)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
@@ -33,7 +33,7 @@ func ProjectGrantMembersByUserID(db *gorm.DB, table, userID string) ([]*model.Pr
|
||||
queries := []*proj_model.ProjectGrantMemberSearchQuery{
|
||||
&proj_model.ProjectGrantMemberSearchQuery{Key: proj_model.ProjectGrantMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.ProjectGrantMemberSearchRequest{Queries: queries})
|
||||
query := repository.PrepareSearchQuery(table, model.ProjectGrantMemberSearchRequest{Queries: queries})
|
||||
_, err := query(db, &members)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -42,7 +42,7 @@ func ProjectGrantMembersByUserID(db *gorm.DB, table, userID string) ([]*model.Pr
|
||||
}
|
||||
|
||||
func PutProjectGrantMember(db *gorm.DB, table string, role *model.ProjectGrantMemberView) error {
|
||||
save := view.PrepareSave(table)
|
||||
save := repository.PrepareSave(table)
|
||||
return save(db, role)
|
||||
}
|
||||
|
||||
@@ -51,6 +51,6 @@ func DeleteProjectGrantMember(db *gorm.DB, table, grantID, userID string) error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
delete := view.PrepareDeleteByObject(table, role)
|
||||
delete := repository.PrepareDeleteByObject(table, role)
|
||||
return delete(db)
|
||||
}
|
||||
|
@@ -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)
|
||||
}
|
||||
|
@@ -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,14 +13,14 @@ func ProjectMemberByIDs(db *gorm.DB, table, projectID, userID string) (*model.Pr
|
||||
|
||||
projectIDQuery := model.ProjectMemberSearchQuery{Key: proj_model.ProjectMemberSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
||||
userIDQuery := model.ProjectMemberSearchQuery{Key: proj_model.ProjectMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, projectIDQuery, userIDQuery)
|
||||
query := repository.PrepareGetByQuery(table, projectIDQuery, userIDQuery)
|
||||
err := query(db, role)
|
||||
return role, err
|
||||
}
|
||||
|
||||
func SearchProjectMembers(db *gorm.DB, table string, req *proj_model.ProjectMemberSearchRequest) ([]*model.ProjectMemberView, int, error) {
|
||||
roles := make([]*model.ProjectMemberView, 0)
|
||||
query := view.PrepareSearchQuery(table, model.ProjectMemberSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||
query := repository.PrepareSearchQuery(table, model.ProjectMemberSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||
count, err := query(db, &roles)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
@@ -32,7 +32,7 @@ func ProjectMembersByUserID(db *gorm.DB, table string, userID string) ([]*model.
|
||||
queries := []*proj_model.ProjectMemberSearchQuery{
|
||||
&proj_model.ProjectMemberSearchQuery{Key: proj_model.ProjectMemberSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.ProjectMemberSearchRequest{Queries: queries})
|
||||
query := repository.PrepareSearchQuery(table, model.ProjectMemberSearchRequest{Queries: queries})
|
||||
_, err := query(db, &members)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -41,7 +41,7 @@ func ProjectMembersByUserID(db *gorm.DB, table string, userID string) ([]*model.
|
||||
}
|
||||
|
||||
func PutProjectMember(db *gorm.DB, table string, role *model.ProjectMemberView) error {
|
||||
save := view.PrepareSave(table)
|
||||
save := repository.PrepareSave(table)
|
||||
return save(db, role)
|
||||
}
|
||||
|
||||
@@ -50,6 +50,6 @@ func DeleteProjectMember(db *gorm.DB, table, projectID, userID string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
delete := view.PrepareDeleteByObject(table, role)
|
||||
delete := repository.PrepareDeleteByObject(table, role)
|
||||
return delete(db)
|
||||
}
|
||||
|
@@ -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"
|
||||
)
|
||||
|
||||
@@ -14,7 +14,7 @@ func ProjectRoleByIDs(db *gorm.DB, table, projectID, orgID, key string) (*model.
|
||||
projectIDQuery := model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
||||
grantIDQuery := model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyOrgID, Value: orgID, Method: global_model.SearchMethodEquals}
|
||||
keyQuery := model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyKey, Value: orgID, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, projectIDQuery, grantIDQuery, keyQuery)
|
||||
query := repository.PrepareGetByQuery(table, projectIDQuery, grantIDQuery, keyQuery)
|
||||
err := query(db, role)
|
||||
return role, err
|
||||
}
|
||||
@@ -26,7 +26,7 @@ func ResourceOwnerProjectRolesByKey(db *gorm.DB, table, projectID, resourceOwner
|
||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyResourceOwner, Value: resourceOwner, Method: global_model.SearchMethodEquals},
|
||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyKey, Value: key, Method: global_model.SearchMethodEquals},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.ProjectRoleSearchRequest{Queries: queries})
|
||||
query := repository.PrepareSearchQuery(table, model.ProjectRoleSearchRequest{Queries: queries})
|
||||
_, err := query(db, &roles)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -40,7 +40,7 @@ func ResourceOwnerProjectRoles(db *gorm.DB, table, projectID, resourceOwner stri
|
||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
||||
&proj_model.ProjectRoleSearchQuery{Key: proj_model.ProjectRoleSearchKeyResourceOwner, Value: resourceOwner, Method: global_model.SearchMethodEquals},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.ProjectRoleSearchRequest{Queries: queries})
|
||||
query := repository.PrepareSearchQuery(table, model.ProjectRoleSearchRequest{Queries: queries})
|
||||
_, err := query(db, &roles)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -50,7 +50,7 @@ func ResourceOwnerProjectRoles(db *gorm.DB, table, projectID, resourceOwner stri
|
||||
|
||||
func SearchProjectRoles(db *gorm.DB, table string, req *proj_model.ProjectRoleSearchRequest) ([]*model.ProjectRoleView, int, error) {
|
||||
roles := make([]*model.ProjectRoleView, 0)
|
||||
query := view.PrepareSearchQuery(table, model.ProjectRoleSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||
query := repository.PrepareSearchQuery(table, model.ProjectRoleSearchRequest{Limit: req.Limit, Offset: req.Offset, Queries: req.Queries})
|
||||
count, err := query(db, &roles)
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
@@ -59,7 +59,7 @@ func SearchProjectRoles(db *gorm.DB, table string, req *proj_model.ProjectRoleSe
|
||||
}
|
||||
|
||||
func PutProjectRole(db *gorm.DB, table string, role *model.ProjectRoleView) error {
|
||||
save := view.PrepareSave(table)
|
||||
save := repository.PrepareSave(table)
|
||||
return save(db, role)
|
||||
}
|
||||
|
||||
@@ -68,6 +68,6 @@ func DeleteProjectRole(db *gorm.DB, table, projectID, orgID, key string) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
delete := view.PrepareDeleteByObject(table, role)
|
||||
delete := repository.PrepareDeleteByObject(table, role)
|
||||
return delete(db)
|
||||
}
|
||||
|
@@ -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)
|
||||
}
|
||||
|
Reference in New Issue
Block a user