2020-06-16 09:40:18 +00:00
|
|
|
package view
|
|
|
|
|
|
|
|
import (
|
|
|
|
org_model "github.com/caos/zitadel/internal/org/model"
|
|
|
|
"github.com/caos/zitadel/internal/org/repository/view"
|
|
|
|
"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-06-16 09:40:18 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
orgDomainTable = "management.org_domains"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (v *View) OrgDomainByOrgIDAndDomain(orgID, domain string) (*model.OrgDomainView, error) {
|
|
|
|
return view.OrgDomainByOrgIDAndDomain(v.Db, orgDomainTable, orgID, domain)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) OrgDomainsByOrgID(domain string) ([]*model.OrgDomainView, error) {
|
|
|
|
return view.OrgDomainsByOrgID(v.Db, orgDomainTable, domain)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) VerifiedOrgDomain(domain string) (*model.OrgDomainView, error) {
|
|
|
|
return view.VerifiedOrgDomain(v.Db, orgDomainTable, domain)
|
|
|
|
}
|
|
|
|
|
2020-07-30 12:37:55 +00:00
|
|
|
func (v *View) SearchOrgDomains(request *org_model.OrgDomainSearchRequest) ([]*model.OrgDomainView, uint64, error) {
|
2020-06-16 09:40:18 +00:00
|
|
|
return view.SearchOrgDomains(v.Db, orgDomainTable, request)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) PutOrgDomain(org *model.OrgDomainView, sequence uint64) error {
|
|
|
|
err := view.PutOrgDomain(v.Db, orgDomainTable, org)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if sequence != 0 {
|
|
|
|
return v.ProcessedOrgDomainSequence(sequence)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2020-08-26 11:01:37 +00:00
|
|
|
func (v *View) PutOrgDomains(domains []*model.OrgDomainView, sequence uint64) error {
|
|
|
|
err := view.PutOrgDomains(v.Db, orgDomainTable, domains...)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return v.ProcessedUserSequence(sequence)
|
|
|
|
}
|
|
|
|
|
2020-06-17 15:23:39 +00:00
|
|
|
func (v *View) DeleteOrgDomain(orgID, domain string, eventSequence uint64) error {
|
|
|
|
err := view.DeleteOrgDomain(v.Db, orgDomainTable, orgID, domain)
|
2020-06-16 09:40:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
return v.ProcessedOrgDomainSequence(eventSequence)
|
|
|
|
}
|
|
|
|
|
2020-07-15 11:24:36 +00:00
|
|
|
func (v *View) GetLatestOrgDomainSequence() (*repository.CurrentSequence, error) {
|
2020-06-16 09:40:18 +00:00
|
|
|
return v.latestSequence(orgDomainTable)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (v *View) ProcessedOrgDomainSequence(eventSequence uint64) error {
|
|
|
|
return v.saveCurrentSequence(orgDomainTable, eventSequence)
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (v *View) GetLatestOrgDomainFailedEvent(sequence uint64) (*repository.FailedEvent, error) {
|
2020-06-16 09:40:18 +00:00
|
|
|
return v.latestFailedEvent(orgDomainTable, sequence)
|
|
|
|
}
|
|
|
|
|
2020-06-25 06:01:13 +00:00
|
|
|
func (v *View) ProcessedOrgDomainFailedEvent(failedEvent *repository.FailedEvent) error {
|
2020-06-16 09:40:18 +00:00
|
|
|
return v.saveFailedEvent(failedEvent)
|
|
|
|
}
|