2020-05-26 14:46:16 +00:00
|
|
|
package view
|
|
|
|
|
|
|
|
import (
|
|
|
|
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-06-16 09:40:18 +00:00
|
|
|
func (v *View) PutOrg(org *model.OrgView) error {
|
2020-05-26 14:46:16 +00:00
|
|
|
err := org_view.PutOrg(v.Db, orgTable, org)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return v.ProcessedOrgSequence(org.Sequence)
|
|
|
|
}
|
|
|
|
|
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-07-15 11:24:36 +00:00
|
|
|
func (v *View) GetLatestOrgSequence() (*repository.CurrentSequence, error) {
|
2020-05-26 14:46:16 +00:00
|
|
|
return v.latestSequence(orgTable)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) ProcessedOrgSequence(eventSequence uint64) error {
|
|
|
|
return v.saveCurrentSequence(orgTable, eventSequence)
|
|
|
|
}
|