2020-05-26 14:46:16 +00:00
|
|
|
package view
|
|
|
|
|
|
|
|
import (
|
2020-12-18 15:47:45 +00:00
|
|
|
"github.com/caos/zitadel/internal/eventstore/models"
|
2020-05-26 14:46:16 +00:00
|
|
|
org_model "github.com/caos/zitadel/internal/org/model"
|
|
|
|
org_view "github.com/caos/zitadel/internal/org/repository/view"
|
2020-06-16 09:40:18 +00:00
|
|
|
"github.com/caos/zitadel/internal/org/repository/view/model"
|
2020-06-25 06:01:13 +00:00
|
|
|
"github.com/caos/zitadel/internal/view/repository"
|
2020-05-26 14:46:16 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
2020-07-07 14:53:54 +00:00
|
|
|
orgTable = "adminapi.orgs"
|
2020-05-26 14:46:16 +00:00
|
|
|
)
|
|
|
|
|
2020-06-16 09:40:18 +00:00
|
|
|
func (v *View) OrgByID(orgID string) (*model.OrgView, error) {
|
2020-05-26 14:46:16 +00:00
|
|
|
return org_view.OrgByID(v.Db, orgTable, orgID)
|
|
|
|
}
|
|
|
|
|
2020-07-30 12:37:55 +00:00
|
|
|
func (v *View) SearchOrgs(query *org_model.OrgSearchRequest) ([]*model.OrgView, uint64, error) {
|
2020-05-26 14:46:16 +00:00
|
|
|
return org_view.SearchOrgs(v.Db, orgTable, query)
|
|
|
|
}
|
|
|
|
|
2020-12-18 15:47:45 +00:00
|
|
|
func (v *View) PutOrg(org *model.OrgView, event *models.Event) error {
|
2020-05-26 14:46:16 +00:00
|
|
|
err := org_view.PutOrg(v.Db, orgTable, org)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2020-12-18 15:47:45 +00:00
|
|
|
return v.ProcessedOrgSequence(event)
|
2020-05-26 14:46:16 +00:00
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (v *View) GetLatestOrgFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
2020-05-26 14:46:16 +00:00
|
|
|
return v.latestFailedEvent(orgTable, sequence)
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (v *View) ProcessedOrgFailedEvent(failedEvent *repository.FailedEvent) error {
|
2020-05-26 14:46:16 +00:00
|
|
|
return v.saveFailedEvent(failedEvent)
|
|
|
|
}
|
|
|
|
|
2020-12-02 07:50:59 +00:00
|
|
|
func (v *View) UpdateOrgSpoolerRunTimestamp() error {
|
|
|
|
return v.updateSpoolerRunSequence(orgTable)
|
|
|
|
}
|
|
|
|
|
2020-12-18 15:47:45 +00:00
|
|
|
func (v *View) GetLatestOrgSequence(aggregateType string) (*repository.CurrentSequence, error) {
|
|
|
|
return v.latestSequence(orgTable, aggregateType)
|
2020-05-26 14:46:16 +00:00
|
|
|
}
|
|
|
|
|
2020-12-18 15:47:45 +00:00
|
|
|
func (v *View) ProcessedOrgSequence(event *models.Event) error {
|
|
|
|
return v.saveCurrentSequence(orgTable, event)
|
2020-05-26 14:46:16 +00:00
|
|
|
}
|