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 (
|
|
|
|
projectMemberTable = "management.project_members"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (v *View) ProjectMemberByIDs(projectID, userID string) (*model.ProjectMemberView, error) {
|
|
|
|
return view.ProjectMemberByIDs(v.Db, projectMemberTable, projectID, userID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) SearchProjectMembers(request *proj_model.ProjectMemberSearchRequest) ([]*model.ProjectMemberView, int, error) {
|
|
|
|
return view.SearchProjectMembers(v.Db, projectMemberTable, request)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) ProjectMembersByUserID(userID string) ([]*model.ProjectMemberView, error) {
|
|
|
|
return view.ProjectMembersByUserID(v.Db, projectMemberTable, userID)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) PutProjectMember(project *model.ProjectMemberView, sequence uint64) error {
|
|
|
|
err := view.PutProjectMember(v.Db, projectMemberTable, project)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return v.ProcessedProjectMemberSequence(sequence)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) DeleteProjectMember(projectID, userID string, eventSequence uint64) error {
|
|
|
|
err := view.DeleteProjectMember(v.Db, projectMemberTable, projectID, userID)
|
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return v.ProcessedProjectMemberSequence(eventSequence)
|
|
|
|
}
|
|
|
|
|
2020-07-15 11:24:36 +00:00
|
|
|
func (v *View) GetLatestProjectMemberSequence() (*repository.CurrentSequence, error) {
|
2020-05-11 10:16:29 +00:00
|
|
|
return v.latestSequence(projectMemberTable)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) ProcessedProjectMemberSequence(eventSequence uint64) error {
|
|
|
|
return v.saveCurrentSequence(projectMemberTable, eventSequence)
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (v *View) GetLatestProjectMemberFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
2020-05-11 10:16:29 +00:00
|
|
|
return v.latestFailedEvent(projectMemberTable, sequence)
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (v *View) ProcessedProjectMemberFailedEvent(failedEvent *repository.FailedEvent) error {
|
2020-05-11 10:16:29 +00:00
|
|
|
return v.saveFailedEvent(failedEvent)
|
|
|
|
}
|