new routes for notifiers

This commit is contained in:
Hayden 2023-03-05 11:06:30 -09:00
parent d79d0b45bf
commit 882f86f6f4
No known key found for this signature in database
GPG key ID: 17CF79474E257545
8 changed files with 741 additions and 5 deletions

View file

@ -36,13 +36,13 @@ func NewNotifierRepository(db *ent.Client) *NotifierRepository {
type (
NotifierCreate struct {
Name string `json:"name" validate:"required,min=1,max=255"`
IsActive bool `json:"isEnabled" validate:"required,min=1,max=255"`
IsActive bool `json:"isActive"`
URL string `json:"url" validate:"required"`
}
NotifierUpdate struct {
Name string `json:"name" validate:"required,min=1,max=255"`
IsActive bool `json:"isEnabled" validate:"required,min=1,max=255"`
IsActive bool `json:"isActive"`
URL *string `json:"url" extensions:"x-nullable"`
}
@ -54,13 +54,13 @@ type (
UpdatedAt time.Time `json:"updatedAt"`
Name string `json:"name"`
IsActive bool `json:"isEnabled"`
IsActive bool `json:"isActive"`
URL string `json:"-"` // URL field is not exposed to the client
}
)
func (r *NotifierRepository) GetByUser(ctx context.Context, userID uuid.UUID) ([]NotifierOut, error) {
notifier, err := r.db.Notifier.Query().Where(notifier.GroupID(userID)).All(ctx)
notifier, err := r.db.Notifier.Query().Where(notifier.UserID(userID)).All(ctx)
return r.mapper.MapEachErr(notifier, err)
}

View file

@ -13,6 +13,7 @@ type AllRepos struct {
Docs *DocumentRepository
Attachments *AttachmentRepo
MaintEntry *MaintenanceEntryRepository
Notifiers *NotifierRepository
}
func New(db *ent.Client, root string) *AllRepos {
@ -26,5 +27,6 @@ func New(db *ent.Client, root string) *AllRepos {
Docs: &DocumentRepository{db, root},
Attachments: &AttachmentRepo{db},
MaintEntry: &MaintenanceEntryRepository{db},
Notifiers: NewNotifierRepository(db),
}
}