feat: organizations and API keys
This commit is contained in:
+41
-6
@@ -2,13 +2,48 @@ package domain
|
||||
|
||||
import "gitlab.com/unboundsoftware/eventsourced/eventsourced"
|
||||
|
||||
type OrganizationAdded struct {
|
||||
eventsourced.EventAggregateId
|
||||
eventsourced.EventTime
|
||||
Name string `json:"name"`
|
||||
Initiator string `json:"initiator"`
|
||||
}
|
||||
|
||||
func (a *OrganizationAdded) UpdateOrganization(o *Organization) {
|
||||
o.Name = a.Name
|
||||
o.Users = []string{a.Initiator}
|
||||
o.CreatedBy = a.Initiator
|
||||
o.CreatedAt = a.When()
|
||||
o.ChangedBy = a.Initiator
|
||||
o.ChangedAt = a.When()
|
||||
}
|
||||
|
||||
type APIKeyAdded struct {
|
||||
eventsourced.EventAggregateId
|
||||
eventsourced.EventTime
|
||||
OrganizationId string `json:"organizationId"`
|
||||
Name string `json:"name"`
|
||||
Key string `json:"key"`
|
||||
Refs []string `json:"refs"`
|
||||
Read bool `json:"read"`
|
||||
Publish bool `json:"publish"`
|
||||
Initiator string `json:"initiator"`
|
||||
}
|
||||
|
||||
func (a *APIKeyAdded) EnrichFromAggregate(aggregate eventsourced.Aggregate) {
|
||||
a.OrganizationId = aggregate.Identity().String()
|
||||
}
|
||||
|
||||
var _ eventsourced.EnrichableEvent = &APIKeyAdded{}
|
||||
|
||||
type SubGraphUpdated struct {
|
||||
eventsourced.EventAggregateId
|
||||
eventsourced.EventTime
|
||||
Ref string
|
||||
Service string
|
||||
Url *string
|
||||
WSUrl *string
|
||||
Sdl string
|
||||
Initiator string
|
||||
OrganizationId string `json:"organizationId"`
|
||||
Ref string `json:"ref"`
|
||||
Service string `json:"service"`
|
||||
Url *string `json:"url"`
|
||||
WSUrl *string `json:"wsUrl"`
|
||||
Sdl string `json:"sdl"`
|
||||
Initiator string `json:"initiator"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user