mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-15 01:57:41 +00:00
fix: all enums same style (#262)
* fix: all enums same style * fix: rename process to reduce * add some missing enum renaming Co-authored-by: Livio Amstutz <livio.a@gmail.com>
This commit is contained in:
@@ -14,9 +14,9 @@ type UserGrant struct {
|
||||
type UserGrantState int32
|
||||
|
||||
const (
|
||||
USERGRANTSTATE_ACTIVE UserGrantState = iota
|
||||
USERGRANTSTATE_INACTIVE
|
||||
USERGRANTSTATE_REMOVED
|
||||
UserGrantStateActive UserGrantState = iota
|
||||
UserGrantStateInactive
|
||||
UserGrantStateRemoved
|
||||
)
|
||||
|
||||
func (u *UserGrant) IsValid() bool {
|
||||
@@ -24,11 +24,11 @@ func (u *UserGrant) IsValid() bool {
|
||||
}
|
||||
|
||||
func (u *UserGrant) IsActive() bool {
|
||||
return u.State == USERGRANTSTATE_ACTIVE
|
||||
return u.State == UserGrantStateActive
|
||||
}
|
||||
|
||||
func (u *UserGrant) IsInactive() bool {
|
||||
return u.State == USERGRANTSTATE_INACTIVE
|
||||
return u.State == UserGrantStateInactive
|
||||
}
|
||||
|
||||
func (u *UserGrant) RemoveRoleKeyIfExisting(key string) bool {
|
||||
|
@@ -37,14 +37,14 @@ type UserGrantSearchRequest struct {
|
||||
type UserGrantSearchKey int32
|
||||
|
||||
const (
|
||||
USERGRANTSEARCHKEY_UNSPECIFIED UserGrantSearchKey = iota
|
||||
USERGRANTSEARCHKEY_USER_ID
|
||||
USERGRANTSEARCHKEY_PROJECT_ID
|
||||
USERGRANTSEARCHKEY_RESOURCEOWNER
|
||||
USERGRANTSEARCHKEY_STATE
|
||||
USERGRANTSEARCHKEY_GRANT_ID
|
||||
USERGRANTSEARCHKEY_ORG_NAME
|
||||
USERGRANTSEARCHKEY_ROLE_KEY
|
||||
UserGrantSearchKeyUnspecified UserGrantSearchKey = iota
|
||||
UserGrantSearchKeyUserID
|
||||
UserGrantSearchKeyProjectID
|
||||
UserGrantSearchKeyResourceOwner
|
||||
UserGrantSearchKeyState
|
||||
UserGrantSearchKeyGrantID
|
||||
UserGrantSearchKeyOrgName
|
||||
UserGrantSearchKeyRoleKey
|
||||
)
|
||||
|
||||
type UserGrantSearchQuery struct {
|
||||
@@ -67,5 +67,5 @@ func (r *UserGrantSearchRequest) EnsureLimit(limit uint64) {
|
||||
}
|
||||
|
||||
func (r *UserGrantSearchRequest) AppendMyOrgQuery(orgID string) {
|
||||
r.Queries = append(r.Queries, &UserGrantSearchQuery{Key: USERGRANTSEARCHKEY_RESOURCEOWNER, Method: model.SEARCHMETHOD_EQUALS, Value: orgID})
|
||||
r.Queries = append(r.Queries, &UserGrantSearchQuery{Key: UserGrantSearchKeyResourceOwner, Method: model.SearchMethodEquals, Value: orgID})
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ func (es *UserGrantEventStore) UserGrantByID(ctx context.Context, id string) (*g
|
||||
return nil, err
|
||||
}
|
||||
es.userGrantCache.cacheUserGrant(grant)
|
||||
if grant.State == int32(grant_model.USERGRANTSTATE_REMOVED) {
|
||||
if grant.State == int32(grant_model.UserGrantStateRemoved) {
|
||||
return nil, caos_errs.ThrowNotFound(nil, "EVENT-2ks8d", "Errors.UserGrant.NotFound")
|
||||
}
|
||||
return model.UserGrantToModel(grant), nil
|
||||
|
@@ -317,7 +317,7 @@ func TestDeactivateUserGrant(t *testing.T) {
|
||||
res: res{
|
||||
result: &model.UserGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
|
||||
ProjectID: "ProjectID",
|
||||
State: model.USERGRANTSTATE_INACTIVE,
|
||||
State: model.UserGrantStateInactive,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -392,7 +392,7 @@ func TestReactivateUserGrant(t *testing.T) {
|
||||
},
|
||||
res: res{
|
||||
result: &model.UserGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "AggregateID", Sequence: 1},
|
||||
State: model.USERGRANTSTATE_ACTIVE,
|
||||
State: model.UserGrantStateActive,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@@ -72,12 +72,12 @@ func (g *UserGrant) AppendEvent(event *es_models.Event) error {
|
||||
UserGrantCascadeChanged:
|
||||
return g.setData(event)
|
||||
case UserGrantDeactivated:
|
||||
g.appendGrantStateEvent(model.USERGRANTSTATE_INACTIVE)
|
||||
g.appendGrantStateEvent(model.UserGrantStateInactive)
|
||||
case UserGrantReactivated:
|
||||
g.appendGrantStateEvent(model.USERGRANTSTATE_ACTIVE)
|
||||
g.appendGrantStateEvent(model.UserGrantStateActive)
|
||||
case UserGrantRemoved,
|
||||
UserGrantCascadeRemoved:
|
||||
g.appendGrantStateEvent(model.USERGRANTSTATE_REMOVED)
|
||||
g.appendGrantStateEvent(model.UserGrantStateRemoved)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@@ -24,9 +24,9 @@ func TestAppendGrantStateEvent(t *testing.T) {
|
||||
existing: &UserGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, UserID: "UserID", ProjectID: "ProjectID", RoleKeys: []string{"Key"}},
|
||||
grant: &UserGrantID{GrantID: "GrantID"},
|
||||
event: &es_models.Event{},
|
||||
state: model.USERGRANTSTATE_INACTIVE,
|
||||
state: model.UserGrantStateInactive,
|
||||
},
|
||||
result: &UserGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, UserID: "UserID", ProjectID: "ProjectID", RoleKeys: []string{"Key"}, State: int32(model.USERGRANTSTATE_INACTIVE)},
|
||||
result: &UserGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, UserID: "UserID", ProjectID: "ProjectID", RoleKeys: []string{"Key"}, State: int32(model.UserGrantStateInactive)},
|
||||
},
|
||||
{
|
||||
name: "append reactivate grant event",
|
||||
@@ -34,9 +34,9 @@ func TestAppendGrantStateEvent(t *testing.T) {
|
||||
existing: &UserGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, UserID: "UserID", ProjectID: "ProjectID", RoleKeys: []string{"Key"}},
|
||||
grant: &UserGrantID{GrantID: "GrantID"},
|
||||
event: &es_models.Event{},
|
||||
state: model.USERGRANTSTATE_ACTIVE,
|
||||
state: model.UserGrantStateActive,
|
||||
},
|
||||
result: &UserGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, UserID: "UserID", ProjectID: "ProjectID", RoleKeys: []string{"Key"}, State: int32(model.USERGRANTSTATE_ACTIVE)},
|
||||
result: &UserGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, UserID: "UserID", ProjectID: "ProjectID", RoleKeys: []string{"Key"}, State: int32(model.UserGrantStateActive)},
|
||||
},
|
||||
{
|
||||
name: "append remove grant event",
|
||||
@@ -44,9 +44,9 @@ func TestAppendGrantStateEvent(t *testing.T) {
|
||||
existing: &UserGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, UserID: "UserID", ProjectID: "ProjectID", RoleKeys: []string{"Key"}},
|
||||
grant: &UserGrantID{GrantID: "GrantID"},
|
||||
event: &es_models.Event{},
|
||||
state: model.USERGRANTSTATE_REMOVED,
|
||||
state: model.UserGrantStateRemoved,
|
||||
},
|
||||
result: &UserGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, UserID: "UserID", ProjectID: "ProjectID", RoleKeys: []string{"Key"}, State: int32(model.USERGRANTSTATE_REMOVED)},
|
||||
result: &UserGrant{ObjectRoot: es_models.ObjectRoot{AggregateID: "ID"}, UserID: "UserID", ProjectID: "ProjectID", RoleKeys: []string{"Key"}, State: int32(model.UserGrantStateRemoved)},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
@@ -217,7 +217,7 @@ func addUserGrantValidation(resourceOwner string, grant *model.UserGrant) func(.
|
||||
}
|
||||
|
||||
func checkProjectConditions(resourceOwner string, grant *model.UserGrant, project *proj_es_model.Project) error {
|
||||
if project.State == int32(proj_model.PROJECTSTATE_REMOVED) {
|
||||
if project.State == int32(proj_model.ProjectStateRemoved) {
|
||||
return errors.ThrowPreconditionFailed(nil, "EVENT-Lxp0s", "project doesn't exist")
|
||||
}
|
||||
if resourceOwner == project.ResourceOwner {
|
||||
|
@@ -95,16 +95,16 @@ func (g *UserGrantView) AppendEvent(event *models.Event) (err error) {
|
||||
g.Sequence = event.Sequence
|
||||
switch event.Type {
|
||||
case es_model.UserGrantAdded:
|
||||
g.State = int32(model.USERGRANTSTATE_ACTIVE)
|
||||
g.State = int32(model.UserGrantStateActive)
|
||||
g.CreationDate = event.CreationDate
|
||||
g.setRootData(event)
|
||||
err = g.setData(event)
|
||||
case es_model.UserGrantChanged, es_model.UserGrantCascadeChanged:
|
||||
err = g.setData(event)
|
||||
case es_model.UserGrantDeactivated:
|
||||
g.State = int32(model.USERGRANTSTATE_INACTIVE)
|
||||
g.State = int32(model.UserGrantStateInactive)
|
||||
case es_model.UserGrantReactivated:
|
||||
g.State = int32(model.USERGRANTSTATE_ACTIVE)
|
||||
g.State = int32(model.UserGrantStateActive)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
@@ -19,7 +19,7 @@ func (req UserGrantSearchRequest) GetOffset() uint64 {
|
||||
}
|
||||
|
||||
func (req UserGrantSearchRequest) GetSortingColumn() view.ColumnKey {
|
||||
if req.SortingColumn == grant_model.USERGRANTSEARCHKEY_UNSPECIFIED {
|
||||
if req.SortingColumn == grant_model.UserGrantSearchKeyUnspecified {
|
||||
return nil
|
||||
}
|
||||
return UserGrantSearchKey(req.SortingColumn)
|
||||
@@ -51,19 +51,19 @@ func (req UserGrantSearchQuery) GetValue() interface{} {
|
||||
|
||||
func (key UserGrantSearchKey) ToColumnName() string {
|
||||
switch grant_model.UserGrantSearchKey(key) {
|
||||
case grant_model.USERGRANTSEARCHKEY_USER_ID:
|
||||
case grant_model.UserGrantSearchKeyUserID:
|
||||
return UserGrantKeyUserID
|
||||
case grant_model.USERGRANTSEARCHKEY_PROJECT_ID:
|
||||
case grant_model.UserGrantSearchKeyProjectID:
|
||||
return UserGrantKeyProjectID
|
||||
case grant_model.USERGRANTSEARCHKEY_STATE:
|
||||
case grant_model.UserGrantSearchKeyState:
|
||||
return UserGrantKeyState
|
||||
case grant_model.USERGRANTSEARCHKEY_RESOURCEOWNER:
|
||||
case grant_model.UserGrantSearchKeyResourceOwner:
|
||||
return UserGrantKeyResourceOwner
|
||||
case grant_model.USERGRANTSEARCHKEY_GRANT_ID:
|
||||
case grant_model.UserGrantSearchKeyGrantID:
|
||||
return UserGrantKeyID
|
||||
case grant_model.USERGRANTSEARCHKEY_ORG_NAME:
|
||||
case grant_model.UserGrantSearchKeyOrgName:
|
||||
return UserGrantKeyOrgName
|
||||
case grant_model.USERGRANTSEARCHKEY_ROLE_KEY:
|
||||
case grant_model.UserGrantSearchKeyRoleKey:
|
||||
return UserGrantKeyRole
|
||||
default:
|
||||
return ""
|
||||
|
@@ -31,31 +31,31 @@ func TestUserAppendEvent(t *testing.T) {
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.UserGrantAdded, ResourceOwner: "OrgID", Data: mockUserGrantData(&es_model.UserGrant{UserID: "UserID", ProjectID: "ProjectID", RoleKeys: pq.StringArray{"Keys"}})},
|
||||
grant: &UserGrantView{},
|
||||
},
|
||||
result: &UserGrantView{ID: "AggregateID", ResourceOwner: "OrgID", UserID: "UserID", ProjectID: "ProjectID", RoleKeys: pq.StringArray{"Keys"}, State: int32(model.USERGRANTSTATE_ACTIVE)},
|
||||
result: &UserGrantView{ID: "AggregateID", ResourceOwner: "OrgID", UserID: "UserID", ProjectID: "ProjectID", RoleKeys: pq.StringArray{"Keys"}, State: int32(model.UserGrantStateActive)},
|
||||
},
|
||||
{
|
||||
name: "append change grant profile event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.UserGrantChanged, ResourceOwner: "OrgID", Data: mockUserGrantData(&es_model.UserGrant{RoleKeys: pq.StringArray{"KeysChanged"}})},
|
||||
grant: &UserGrantView{ID: "AggregateID", ResourceOwner: "OrgID", UserID: "UserID", ProjectID: "ProjectID", RoleKeys: pq.StringArray{"Keys"}, State: int32(model.USERGRANTSTATE_ACTIVE)},
|
||||
grant: &UserGrantView{ID: "AggregateID", ResourceOwner: "OrgID", UserID: "UserID", ProjectID: "ProjectID", RoleKeys: pq.StringArray{"Keys"}, State: int32(model.UserGrantStateActive)},
|
||||
},
|
||||
result: &UserGrantView{ID: "AggregateID", ResourceOwner: "OrgID", UserID: "UserID", ProjectID: "ProjectID", RoleKeys: pq.StringArray{"KeysChanged"}, State: int32(model.USERGRANTSTATE_ACTIVE)},
|
||||
result: &UserGrantView{ID: "AggregateID", ResourceOwner: "OrgID", UserID: "UserID", ProjectID: "ProjectID", RoleKeys: pq.StringArray{"KeysChanged"}, State: int32(model.UserGrantStateActive)},
|
||||
},
|
||||
{
|
||||
name: "append grant deactivate event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.UserGrantDeactivated, ResourceOwner: "OrgID"},
|
||||
grant: &UserGrantView{ID: "AggregateID", ResourceOwner: "OrgID", UserID: "UserID", ProjectID: "ProjectID", RoleKeys: pq.StringArray{"Keys"}, State: int32(model.USERGRANTSTATE_ACTIVE)},
|
||||
grant: &UserGrantView{ID: "AggregateID", ResourceOwner: "OrgID", UserID: "UserID", ProjectID: "ProjectID", RoleKeys: pq.StringArray{"Keys"}, State: int32(model.UserGrantStateActive)},
|
||||
},
|
||||
result: &UserGrantView{ID: "AggregateID", ResourceOwner: "OrgID", UserID: "UserID", ProjectID: "ProjectID", RoleKeys: pq.StringArray{"Keys"}, State: int32(model.USERGRANTSTATE_INACTIVE)},
|
||||
result: &UserGrantView{ID: "AggregateID", ResourceOwner: "OrgID", UserID: "UserID", ProjectID: "ProjectID", RoleKeys: pq.StringArray{"Keys"}, State: int32(model.UserGrantStateInactive)},
|
||||
},
|
||||
{
|
||||
name: "append grant reactivate event",
|
||||
args: args{
|
||||
event: &es_models.Event{AggregateID: "AggregateID", Sequence: 1, Type: es_model.UserGrantReactivated, ResourceOwner: "OrgID"},
|
||||
grant: &UserGrantView{ID: "AggregateID", ResourceOwner: "OrgID", UserID: "UserID", ProjectID: "ProjectID", RoleKeys: pq.StringArray{"Keys"}, State: int32(model.USERGRANTSTATE_INACTIVE)},
|
||||
grant: &UserGrantView{ID: "AggregateID", ResourceOwner: "OrgID", UserID: "UserID", ProjectID: "ProjectID", RoleKeys: pq.StringArray{"Keys"}, State: int32(model.UserGrantStateInactive)},
|
||||
},
|
||||
result: &UserGrantView{ID: "AggregateID", ResourceOwner: "OrgID", UserID: "UserID", ProjectID: "ProjectID", RoleKeys: pq.StringArray{"Keys"}, State: int32(model.USERGRANTSTATE_ACTIVE)},
|
||||
result: &UserGrantView{ID: "AggregateID", ResourceOwner: "OrgID", UserID: "UserID", ProjectID: "ProjectID", RoleKeys: pq.StringArray{"Keys"}, State: int32(model.UserGrantStateActive)},
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
|
@@ -10,7 +10,7 @@ import (
|
||||
|
||||
func UserGrantByID(db *gorm.DB, table, grantID string) (*model.UserGrantView, error) {
|
||||
user := new(model.UserGrantView)
|
||||
query := view.PrepareGetByKey(table, model.UserGrantSearchKey(grant_model.USERGRANTSEARCHKEY_GRANT_ID), grantID)
|
||||
query := view.PrepareGetByKey(table, model.UserGrantSearchKey(grant_model.UserGrantSearchKeyGrantID), grantID)
|
||||
err := query(db, user)
|
||||
return user, err
|
||||
}
|
||||
@@ -18,9 +18,9 @@ func UserGrantByID(db *gorm.DB, table, grantID string) (*model.UserGrantView, er
|
||||
func UserGrantByIDs(db *gorm.DB, table, resourceOwnerID, projectID, userID string) (*model.UserGrantView, error) {
|
||||
user := new(model.UserGrantView)
|
||||
|
||||
resourceOwnerIDQuery := model.UserGrantSearchQuery{Key: grant_model.USERGRANTSEARCHKEY_RESOURCEOWNER, Value: resourceOwnerID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
projectIDQuery := model.UserGrantSearchQuery{Key: grant_model.USERGRANTSEARCHKEY_PROJECT_ID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
userIDQuery := model.UserGrantSearchQuery{Key: grant_model.USERGRANTSEARCHKEY_USER_ID, Value: userID, Method: global_model.SEARCHMETHOD_EQUALS}
|
||||
resourceOwnerIDQuery := model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyResourceOwner, Value: resourceOwnerID, Method: global_model.SearchMethodEquals}
|
||||
projectIDQuery := model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals}
|
||||
userIDQuery := model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals}
|
||||
query := view.PrepareGetByQuery(table, resourceOwnerIDQuery, projectIDQuery, userIDQuery)
|
||||
err := query(db, user)
|
||||
return user, err
|
||||
@@ -39,7 +39,7 @@ func SearchUserGrants(db *gorm.DB, table string, req *grant_model.UserGrantSearc
|
||||
func UserGrantsByUserID(db *gorm.DB, table, userID string) ([]*model.UserGrantView, error) {
|
||||
users := make([]*model.UserGrantView, 0)
|
||||
queries := []*grant_model.UserGrantSearchQuery{
|
||||
&grant_model.UserGrantSearchQuery{Key: grant_model.USERGRANTSEARCHKEY_USER_ID, Value: userID, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyUserID, Value: userID, Method: global_model.SearchMethodEquals},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.UserGrantSearchRequest{Queries: queries})
|
||||
_, err := query(db, &users)
|
||||
@@ -52,7 +52,7 @@ func UserGrantsByUserID(db *gorm.DB, table, userID string) ([]*model.UserGrantVi
|
||||
func UserGrantsByProjectID(db *gorm.DB, table, projectID string) ([]*model.UserGrantView, error) {
|
||||
users := make([]*model.UserGrantView, 0)
|
||||
queries := []*grant_model.UserGrantSearchQuery{
|
||||
&grant_model.UserGrantSearchQuery{Key: grant_model.USERGRANTSEARCHKEY_PROJECT_ID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.UserGrantSearchRequest{Queries: queries})
|
||||
_, err := query(db, &users)
|
||||
@@ -65,8 +65,8 @@ func UserGrantsByProjectID(db *gorm.DB, table, projectID string) ([]*model.UserG
|
||||
func UserGrantsByProjectIDAndRole(db *gorm.DB, table, projectID, roleKey string) ([]*model.UserGrantView, error) {
|
||||
users := make([]*model.UserGrantView, 0)
|
||||
queries := []*grant_model.UserGrantSearchQuery{
|
||||
&grant_model.UserGrantSearchQuery{Key: grant_model.USERGRANTSEARCHKEY_PROJECT_ID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||
&grant_model.UserGrantSearchQuery{Key: grant_model.USERGRANTSEARCHKEY_ROLE_KEY, Value: roleKey, Method: global_model.SEARCHMETHOD_LIST_CONTAINS},
|
||||
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
||||
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyRoleKey, Value: roleKey, Method: global_model.SearchMethodListContains},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.UserGrantSearchRequest{Queries: queries})
|
||||
_, err := query(db, &users)
|
||||
@@ -79,8 +79,8 @@ func UserGrantsByProjectIDAndRole(db *gorm.DB, table, projectID, roleKey string)
|
||||
func UserGrantsByOrgIDAndProjectID(db *gorm.DB, table, orgID, projectID string) ([]*model.UserGrantView, error) {
|
||||
users := make([]*model.UserGrantView, 0)
|
||||
queries := []*grant_model.UserGrantSearchQuery{
|
||||
&grant_model.UserGrantSearchQuery{Key: grant_model.USERGRANTSEARCHKEY_RESOURCEOWNER, Value: orgID, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||
&grant_model.UserGrantSearchQuery{Key: grant_model.USERGRANTSEARCHKEY_PROJECT_ID, Value: projectID, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyResourceOwner, Value: orgID, Method: global_model.SearchMethodEquals},
|
||||
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyProjectID, Value: projectID, Method: global_model.SearchMethodEquals},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.UserGrantSearchRequest{Queries: queries})
|
||||
_, err := query(db, &users)
|
||||
@@ -93,7 +93,7 @@ func UserGrantsByOrgIDAndProjectID(db *gorm.DB, table, orgID, projectID string)
|
||||
func UserGrantsByOrgID(db *gorm.DB, table, orgID string) ([]*model.UserGrantView, error) {
|
||||
users := make([]*model.UserGrantView, 0)
|
||||
queries := []*grant_model.UserGrantSearchQuery{
|
||||
&grant_model.UserGrantSearchQuery{Key: grant_model.USERGRANTSEARCHKEY_RESOURCEOWNER, Value: orgID, Method: global_model.SEARCHMETHOD_EQUALS},
|
||||
&grant_model.UserGrantSearchQuery{Key: grant_model.UserGrantSearchKeyResourceOwner, Value: orgID, Method: global_model.SearchMethodEquals},
|
||||
}
|
||||
query := view.PrepareSearchQuery(table, model.UserGrantSearchRequest{Queries: queries})
|
||||
_, err := query(db, &users)
|
||||
@@ -109,6 +109,6 @@ func PutUserGrant(db *gorm.DB, table string, grant *model.UserGrantView) error {
|
||||
}
|
||||
|
||||
func DeleteUserGrant(db *gorm.DB, table, grantID string) error {
|
||||
delete := view.PrepareDeleteByKey(table, model.UserGrantSearchKey(grant_model.USERGRANTSEARCHKEY_GRANT_ID), grantID)
|
||||
delete := view.PrepareDeleteByKey(table, model.UserGrantSearchKey(grant_model.UserGrantSearchKeyGrantID), grantID)
|
||||
return delete(db)
|
||||
}
|
||||
|
Reference in New Issue
Block a user