mirror of
https://github.com/idanoo/autobrr
synced 2025-07-22 16:29:12 +00:00
feat: add postgres support (#215)
* feat: add postgres support and refactor * feat: improve releases find * fix: autobrrctl create user
This commit is contained in:
parent
f6873e932e
commit
3185832708
30 changed files with 1708 additions and 831 deletions
|
@ -11,6 +11,7 @@ type Service interface {
|
|||
List(ctx context.Context) ([]domain.DownloadClient, error)
|
||||
FindByID(ctx context.Context, id int32) (*domain.DownloadClient, error)
|
||||
Store(ctx context.Context, client domain.DownloadClient) (*domain.DownloadClient, error)
|
||||
Update(ctx context.Context, client domain.DownloadClient) (*domain.DownloadClient, error)
|
||||
Delete(ctx context.Context, clientID int) error
|
||||
Test(client domain.DownloadClient) error
|
||||
}
|
||||
|
@ -43,6 +44,18 @@ func (s *service) Store(ctx context.Context, client domain.DownloadClient) (*dom
|
|||
return s.repo.Store(ctx, client)
|
||||
}
|
||||
|
||||
func (s *service) Update(ctx context.Context, client domain.DownloadClient) (*domain.DownloadClient, error) {
|
||||
// validate data
|
||||
if client.Host == "" {
|
||||
return nil, errors.New("validation error: no host")
|
||||
} else if client.Type == "" {
|
||||
return nil, errors.New("validation error: no type")
|
||||
}
|
||||
|
||||
// store
|
||||
return s.repo.Update(ctx, client)
|
||||
}
|
||||
|
||||
func (s *service) Delete(ctx context.Context, clientID int) error {
|
||||
return s.repo.Delete(ctx, clientID)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue