memos/store/webhook.go

59 lines
1.1 KiB
Go
Raw Normal View History

2023-11-24 22:45:38 +08:00
package store
import (
"context"
)
2024-04-13 11:54:37 +08:00
type Webhook struct {
ID int32
CreatedTs int64
UpdatedTs int64
CreatorID int32
RowStatus RowStatus
Name string
2024-04-13 12:11:59 +08:00
URL string
2024-04-13 11:54:37 +08:00
}
2023-11-24 22:45:38 +08:00
type FindWebhook struct {
ID *int32
CreatorID *int32
}
type UpdateWebhook struct {
ID int32
2024-04-13 11:54:37 +08:00
RowStatus *RowStatus
2023-11-24 22:45:38 +08:00
Name *string
URL *string
}
type DeleteWebhook struct {
ID int32
}
2024-04-13 11:54:37 +08:00
func (s *Store) CreateWebhook(ctx context.Context, create *Webhook) (*Webhook, error) {
2023-11-24 22:45:38 +08:00
return s.driver.CreateWebhook(ctx, create)
}
2024-04-13 11:54:37 +08:00
func (s *Store) ListWebhooks(ctx context.Context, find *FindWebhook) ([]*Webhook, error) {
2023-11-24 22:45:38 +08:00
return s.driver.ListWebhooks(ctx, find)
}
2024-04-13 11:54:37 +08:00
func (s *Store) GetWebhook(ctx context.Context, find *FindWebhook) (*Webhook, error) {
2023-11-24 22:45:38 +08:00
list, err := s.ListWebhooks(ctx, find)
if err != nil {
return nil, err
}
if len(list) == 0 {
return nil, nil
}
return list[0], nil
}
2024-04-13 11:54:37 +08:00
func (s *Store) UpdateWebhook(ctx context.Context, update *UpdateWebhook) (*Webhook, error) {
2023-11-24 22:45:38 +08:00
return s.driver.UpdateWebhook(ctx, update)
}
func (s *Store) DeleteWebhook(ctx context.Context, delete *DeleteWebhook) error {
return s.driver.DeleteWebhook(ctx, delete)
}