fix: delete org domain (#234)

This commit is contained in:
Fabi 2020-06-17 17:23:39 +02:00 committed by GitHub
parent b5376b2e5a
commit 5e39a5f813
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

View File

@ -84,7 +84,7 @@ func (d *OrgDomain) processOrgDomain(event *models.Event) (err error) {
if err != nil {
return err
}
return d.view.DeleteOrgDomain(domain.Domain, event.Sequence)
return d.view.DeleteOrgDomain(event.AggregateID, domain.Domain, event.Sequence)
default:
return d.view.ProcessedOrgDomainSequence(event.Sequence)
}

View File

@ -38,8 +38,8 @@ func (v *View) PutOrgDomain(org *model.OrgDomainView, sequence uint64) error {
return nil
}
func (v *View) DeleteOrgDomain(domain string, eventSequence uint64) error {
err := view.DeleteOrgDomain(v.Db, orgDomainTable, domain)
func (v *View) DeleteOrgDomain(orgID, domain string, eventSequence uint64) error {
err := view.DeleteOrgDomain(v.Db, orgDomainTable, orgID, domain)
if err != nil {
return nil
}

View File

@ -58,7 +58,10 @@ func PutOrgDomain(db *gorm.DB, table string, role *model.OrgDomainView) error {
return save(db, role)
}
func DeleteOrgDomain(db *gorm.DB, table, domain string) error {
delete := view.PrepareDeleteByKey(table, model.OrgSearchKey(org_model.ORGDOMAINSEARCHKEY_DOMAIN), domain)
func DeleteOrgDomain(db *gorm.DB, table, orgID, domain string) error {
delete := view.PrepareDeleteByKeys(table,
view.Key{Key: model.OrgDomainSearchKey(org_model.ORGDOMAINSEARCHKEY_DOMAIN), Value: domain},
view.Key{Key: model.OrgDomainSearchKey(org_model.ORGDOMAINSEARCHKEY_ORG_ID), Value: orgID},
)
return delete(db)
}