2020-05-11 10:16:29 +00:00
|
|
|
package view
|
|
|
|
|
|
|
|
import (
|
|
|
|
proj_model "github.com/caos/zitadel/internal/project/model"
|
|
|
|
"github.com/caos/zitadel/internal/project/repository/view"
|
|
|
|
"github.com/caos/zitadel/internal/project/repository/view/model"
|
2020-06-25 06:01:13 +00:00
|
|
|
"github.com/caos/zitadel/internal/view/repository"
|
2020-05-11 10:16:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
projectGrantMemberTable = "management.project_grant_members"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (v *View) ProjectGrantMemberByIDs(projectID, userID string) (*model.ProjectGrantMemberView, error) {
|
|
|
|
return view.ProjectGrantMemberByIDs(v.Db, projectGrantMemberTable, projectID, userID)
|
|
|
|
}
|
|
|
|
|
2020-07-30 12:37:55 +00:00
|
|
|
func (v *View) SearchProjectGrantMembers(request *proj_model.ProjectGrantMemberSearchRequest) ([]*model.ProjectGrantMemberView, uint64, error) {
|
2020-05-11 10:16:29 +00:00
|
|
|
return view.SearchProjectGrantMembers(v.Db, projectGrantMemberTable, request)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) ProjectGrantMembersByUserID(userID string) ([]*model.ProjectGrantMemberView, error) {
|
|
|
|
return view.ProjectGrantMembersByUserID(v.Db, projectGrantMemberTable, userID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) PutProjectGrantMember(project *model.ProjectGrantMemberView, sequence uint64) error {
|
|
|
|
err := view.PutProjectGrantMember(v.Db, projectGrantMemberTable, project)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return v.ProcessedProjectGrantMemberSequence(sequence)
|
|
|
|
}
|
|
|
|
|
2020-07-09 15:56:37 +00:00
|
|
|
func (v *View) DeleteProjectGrantMember(grantID, userID string, eventSequence uint64) error {
|
|
|
|
err := view.DeleteProjectGrantMember(v.Db, projectGrantMemberTable, grantID, userID)
|
2020-05-11 10:16:29 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return v.ProcessedProjectGrantMemberSequence(eventSequence)
|
|
|
|
}
|
|
|
|
|
2020-07-15 11:24:36 +00:00
|
|
|
func (v *View) GetLatestProjectGrantMemberSequence() (*repository.CurrentSequence, error) {
|
2020-05-11 10:16:29 +00:00
|
|
|
return v.latestSequence(projectGrantMemberTable)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) ProcessedProjectGrantMemberSequence(eventSequence uint64) error {
|
|
|
|
return v.saveCurrentSequence(projectGrantMemberTable, eventSequence)
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (v *View) GetLatestProjectGrantMemberFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
2020-05-11 10:16:29 +00:00
|
|
|
return v.latestFailedEvent(projectGrantMemberTable, sequence)
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (v *View) ProcessedProjectGrantMemberFailedEvent(failedEvent *repository.FailedEvent) error {
|
2020-05-11 10:16:29 +00:00
|
|
|
return v.saveFailedEvent(failedEvent)
|
|
|
|
}
|