feat(announcements): add admin/user announcement system
Implements announcements end-to-end (admin CRUD + read status, user list + mark read) with OR-of-AND targeting. Also breaks the ent<->service import cycle by moving schema-facing constants/targeting into a new domain package.
This commit is contained in:
@@ -61,6 +61,8 @@ type UserEdges struct {
|
||||
Subscriptions []*UserSubscription `json:"subscriptions,omitempty"`
|
||||
// AssignedSubscriptions holds the value of the assigned_subscriptions edge.
|
||||
AssignedSubscriptions []*UserSubscription `json:"assigned_subscriptions,omitempty"`
|
||||
// AnnouncementReads holds the value of the announcement_reads edge.
|
||||
AnnouncementReads []*AnnouncementRead `json:"announcement_reads,omitempty"`
|
||||
// AllowedGroups holds the value of the allowed_groups edge.
|
||||
AllowedGroups []*Group `json:"allowed_groups,omitempty"`
|
||||
// UsageLogs holds the value of the usage_logs edge.
|
||||
@@ -73,7 +75,7 @@ type UserEdges struct {
|
||||
UserAllowedGroups []*UserAllowedGroup `json:"user_allowed_groups,omitempty"`
|
||||
// loadedTypes holds the information for reporting if a
|
||||
// type was loaded (or requested) in eager-loading or not.
|
||||
loadedTypes [9]bool
|
||||
loadedTypes [10]bool
|
||||
}
|
||||
|
||||
// APIKeysOrErr returns the APIKeys value or an error if the edge
|
||||
@@ -112,10 +114,19 @@ func (e UserEdges) AssignedSubscriptionsOrErr() ([]*UserSubscription, error) {
|
||||
return nil, &NotLoadedError{edge: "assigned_subscriptions"}
|
||||
}
|
||||
|
||||
// AnnouncementReadsOrErr returns the AnnouncementReads value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e UserEdges) AnnouncementReadsOrErr() ([]*AnnouncementRead, error) {
|
||||
if e.loadedTypes[4] {
|
||||
return e.AnnouncementReads, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "announcement_reads"}
|
||||
}
|
||||
|
||||
// AllowedGroupsOrErr returns the AllowedGroups value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e UserEdges) AllowedGroupsOrErr() ([]*Group, error) {
|
||||
if e.loadedTypes[4] {
|
||||
if e.loadedTypes[5] {
|
||||
return e.AllowedGroups, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "allowed_groups"}
|
||||
@@ -124,7 +135,7 @@ func (e UserEdges) AllowedGroupsOrErr() ([]*Group, error) {
|
||||
// UsageLogsOrErr returns the UsageLogs value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e UserEdges) UsageLogsOrErr() ([]*UsageLog, error) {
|
||||
if e.loadedTypes[5] {
|
||||
if e.loadedTypes[6] {
|
||||
return e.UsageLogs, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "usage_logs"}
|
||||
@@ -133,7 +144,7 @@ func (e UserEdges) UsageLogsOrErr() ([]*UsageLog, error) {
|
||||
// AttributeValuesOrErr returns the AttributeValues value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e UserEdges) AttributeValuesOrErr() ([]*UserAttributeValue, error) {
|
||||
if e.loadedTypes[6] {
|
||||
if e.loadedTypes[7] {
|
||||
return e.AttributeValues, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "attribute_values"}
|
||||
@@ -142,7 +153,7 @@ func (e UserEdges) AttributeValuesOrErr() ([]*UserAttributeValue, error) {
|
||||
// PromoCodeUsagesOrErr returns the PromoCodeUsages value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e UserEdges) PromoCodeUsagesOrErr() ([]*PromoCodeUsage, error) {
|
||||
if e.loadedTypes[7] {
|
||||
if e.loadedTypes[8] {
|
||||
return e.PromoCodeUsages, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "promo_code_usages"}
|
||||
@@ -151,7 +162,7 @@ func (e UserEdges) PromoCodeUsagesOrErr() ([]*PromoCodeUsage, error) {
|
||||
// UserAllowedGroupsOrErr returns the UserAllowedGroups value or an error if the edge
|
||||
// was not loaded in eager-loading.
|
||||
func (e UserEdges) UserAllowedGroupsOrErr() ([]*UserAllowedGroup, error) {
|
||||
if e.loadedTypes[8] {
|
||||
if e.loadedTypes[9] {
|
||||
return e.UserAllowedGroups, nil
|
||||
}
|
||||
return nil, &NotLoadedError{edge: "user_allowed_groups"}
|
||||
@@ -313,6 +324,11 @@ func (_m *User) QueryAssignedSubscriptions() *UserSubscriptionQuery {
|
||||
return NewUserClient(_m.config).QueryAssignedSubscriptions(_m)
|
||||
}
|
||||
|
||||
// QueryAnnouncementReads queries the "announcement_reads" edge of the User entity.
|
||||
func (_m *User) QueryAnnouncementReads() *AnnouncementReadQuery {
|
||||
return NewUserClient(_m.config).QueryAnnouncementReads(_m)
|
||||
}
|
||||
|
||||
// QueryAllowedGroups queries the "allowed_groups" edge of the User entity.
|
||||
func (_m *User) QueryAllowedGroups() *GroupQuery {
|
||||
return NewUserClient(_m.config).QueryAllowedGroups(_m)
|
||||
|
||||
Reference in New Issue
Block a user