mirror of
https://github.com/zitadel/zitadel.git
synced 2025-12-07 05:13:49 +00:00
fix: query side (#257)
* fix: project by id return projectview * fix: return always view model on query side * fix: return always view model on query side
This commit is contained in:
@@ -20,12 +20,15 @@ type OrgRepository struct {
|
||||
Roles []string
|
||||
}
|
||||
|
||||
func (repo *OrgRepository) OrgByID(ctx context.Context, id string) (*org_model.Org, error) {
|
||||
org := org_model.NewOrg(id)
|
||||
return repo.OrgEventstore.OrgByID(ctx, org)
|
||||
func (repo *OrgRepository) OrgByID(ctx context.Context, id string) (*org_model.OrgView, error) {
|
||||
org, err := repo.View.OrgByID(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model.OrgToModel(org), nil
|
||||
}
|
||||
|
||||
func (repo *OrgRepository) OrgByDomainGlobal(ctx context.Context, domain string) (*org_model.Org, error) {
|
||||
func (repo *OrgRepository) OrgByDomainGlobal(ctx context.Context, domain string) (*org_model.OrgView, error) {
|
||||
verifiedDomain, err := repo.View.VerifiedOrgDomain(domain)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -82,9 +85,12 @@ func (repo *OrgRepository) OrgChanges(ctx context.Context, id string, lastSequen
|
||||
return changes, nil
|
||||
}
|
||||
|
||||
func (repo *OrgRepository) OrgMemberByID(ctx context.Context, orgID, userID string) (member *org_model.OrgMember, err error) {
|
||||
member = org_model.NewOrgMember(orgID, userID)
|
||||
return repo.OrgEventstore.OrgMemberByIDs(ctx, member)
|
||||
func (repo *OrgRepository) OrgMemberByID(ctx context.Context, orgID, userID string) (*org_model.OrgMemberView, error) {
|
||||
member, err := repo.View.OrgMemberByIDs(orgID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model.OrgMemberToModel(member), nil
|
||||
}
|
||||
|
||||
func (repo *OrgRepository) AddMyOrgMember(ctx context.Context, member *org_model.OrgMember) (*org_model.OrgMember, error) {
|
||||
|
||||
@@ -31,8 +31,12 @@ type ProjectRepo struct {
|
||||
Roles []string
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) ProjectByID(ctx context.Context, id string) (project *proj_model.Project, err error) {
|
||||
return repo.ProjectEvents.ProjectByID(ctx, id)
|
||||
func (repo *ProjectRepo) ProjectByID(ctx context.Context, id string) (*proj_model.ProjectView, error) {
|
||||
project, err := repo.View.ProjectByID(id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model.ProjectToModel(project), nil
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) CreateProject(ctx context.Context, name string) (*proj_model.Project, error) {
|
||||
@@ -81,9 +85,12 @@ func (repo *ProjectRepo) ProjectGrantViewByID(ctx context.Context, grantID strin
|
||||
return model.ProjectGrantToModel(p), nil
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) ProjectMemberByID(ctx context.Context, projectID, userID string) (member *proj_model.ProjectMember, err error) {
|
||||
member = proj_model.NewProjectMember(projectID, userID)
|
||||
return repo.ProjectEvents.ProjectMemberByIDs(ctx, member)
|
||||
func (repo *ProjectRepo) ProjectMemberByID(ctx context.Context, projectID, userID string) (*proj_model.ProjectMemberView, error) {
|
||||
member, err := repo.View.ProjectMemberByIDs(projectID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model.ProjectMemberToModel(member), nil
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) AddProjectMember(ctx context.Context, member *proj_model.ProjectMember) (*proj_model.ProjectMember, error) {
|
||||
@@ -185,8 +192,12 @@ func (repo *ProjectRepo) ProjectChanges(ctx context.Context, id string, lastSequ
|
||||
return changes, nil
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) ApplicationByID(ctx context.Context, projectID, appID string) (app *proj_model.Application, err error) {
|
||||
return repo.ProjectEvents.ApplicationByIDs(ctx, projectID, appID)
|
||||
func (repo *ProjectRepo) ApplicationByID(ctx context.Context, appID string) (*proj_model.ApplicationView, error) {
|
||||
app, err := repo.View.ApplicationByID(appID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model.ApplicationViewToModel(app), nil
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) AddApplication(ctx context.Context, app *proj_model.Application) (*proj_model.Application, error) {
|
||||
@@ -240,8 +251,12 @@ func (repo *ProjectRepo) ChangeOIDConfigSecret(ctx context.Context, projectID, a
|
||||
return repo.ProjectEvents.ChangeOIDCConfigSecret(ctx, projectID, appID)
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) ProjectGrantByID(ctx context.Context, projectID, appID string) (app *proj_model.ProjectGrant, err error) {
|
||||
return repo.ProjectEvents.ProjectGrantByIDs(ctx, projectID, appID)
|
||||
func (repo *ProjectRepo) ProjectGrantByID(ctx context.Context, grantID string) (*proj_model.ProjectGrantView, error) {
|
||||
grant, err := repo.View.ProjectGrantByID(grantID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model.ProjectGrantToModel(grant), nil
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) SearchProjectGrants(ctx context.Context, request *proj_model.ProjectGrantViewSearchRequest) (*proj_model.ProjectGrantViewSearchResponse, error) {
|
||||
@@ -354,9 +369,12 @@ func (repo *ProjectRepo) RemoveProjectGrant(ctx context.Context, projectID, gran
|
||||
return nil
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) ProjectGrantMemberByID(ctx context.Context, projectID, grantID, userID string) (member *proj_model.ProjectGrantMember, err error) {
|
||||
member = proj_model.NewProjectGrantMember(projectID, grantID, userID)
|
||||
return repo.ProjectEvents.ProjectGrantMemberByIDs(ctx, member)
|
||||
func (repo *ProjectRepo) ProjectGrantMemberByID(ctx context.Context, projectID, userID string) (*proj_model.ProjectGrantMemberView, error) {
|
||||
member, err := repo.View.ProjectGrantMemberByIDs(projectID, userID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model.ProjectGrantMemberToModel(member), nil
|
||||
}
|
||||
|
||||
func (repo *ProjectRepo) AddProjectGrantMember(ctx context.Context, member *proj_model.ProjectGrantMember) (*proj_model.ProjectGrantMember, error) {
|
||||
|
||||
@@ -14,8 +14,12 @@ type UserGrantRepo struct {
|
||||
View *view.View
|
||||
}
|
||||
|
||||
func (repo *UserGrantRepo) UserGrantByID(ctx context.Context, grantID string) (*grant_model.UserGrant, error) {
|
||||
return repo.UserGrantEvents.UserGrantByID(ctx, grantID)
|
||||
func (repo *UserGrantRepo) UserGrantByID(ctx context.Context, grantID string) (*grant_model.UserGrantView, error) {
|
||||
grant, err := repo.View.UserGrantByID(grantID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return model.UserGrantToModel(grant), nil
|
||||
}
|
||||
|
||||
func (repo *UserGrantRepo) AddUserGrant(ctx context.Context, grant *grant_model.UserGrant) (*grant_model.UserGrant, error) {
|
||||
|
||||
Reference in New Issue
Block a user