mirror of
https://github.com/zitadel/zitadel.git
synced 2025-08-12 11:07:32 +00:00
chore: move the go code into a subfolder
This commit is contained in:
41
apps/api/internal/command/resource_owner_model.go
Normal file
41
apps/api/internal/command/resource_owner_model.go
Normal file
@@ -0,0 +1,41 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"github.com/zitadel/zitadel/internal/eventstore"
|
||||
)
|
||||
|
||||
// resourceOwnerModel can be used to retrieve the resourceOwner of an aggregate
|
||||
// by checking the first event it.
|
||||
type resourceOwnerModel struct {
|
||||
instanceID string
|
||||
aggregateType eventstore.AggregateType
|
||||
aggregateID string
|
||||
|
||||
resourceOwner string
|
||||
}
|
||||
|
||||
func NewResourceOwnerModel(instanceID string, aggregateType eventstore.AggregateType, aggregateID string) *resourceOwnerModel {
|
||||
return &resourceOwnerModel{
|
||||
instanceID: instanceID,
|
||||
aggregateType: aggregateType,
|
||||
aggregateID: aggregateID,
|
||||
}
|
||||
}
|
||||
|
||||
func (r *resourceOwnerModel) Reduce() error {
|
||||
return nil
|
||||
}
|
||||
func (r *resourceOwnerModel) AppendEvents(events ...eventstore.Event) {
|
||||
if len(events) == 1 {
|
||||
r.resourceOwner = events[0].Aggregate().ResourceOwner
|
||||
}
|
||||
}
|
||||
func (r *resourceOwnerModel) Query() *eventstore.SearchQueryBuilder {
|
||||
return eventstore.NewSearchQueryBuilder(eventstore.ColumnsEvent).
|
||||
InstanceID(r.instanceID).
|
||||
AddQuery().
|
||||
AggregateTypes(r.aggregateType).
|
||||
AggregateIDs(r.aggregateID).
|
||||
Builder().
|
||||
Limit(1)
|
||||
}
|
Reference in New Issue
Block a user