storage.go 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. package store
  2. import (
  3. "context"
  4. )
  5. type Storage struct {
  6. ID int32
  7. Name string
  8. Type string
  9. Config string
  10. }
  11. type FindStorage struct {
  12. ID *int32
  13. }
  14. type UpdateStorage struct {
  15. ID int32
  16. Name *string
  17. Config *string
  18. }
  19. type DeleteStorage struct {
  20. ID int32
  21. }
  22. func (s *Store) CreateStorage(ctx context.Context, create *Storage) (*Storage, error) {
  23. return s.driver.CreateStorage(ctx, create)
  24. }
  25. func (s *Store) ListStorages(ctx context.Context, find *FindStorage) ([]*Storage, error) {
  26. return s.driver.ListStorages(ctx, find)
  27. }
  28. func (s *Store) GetStorage(ctx context.Context, find *FindStorage) (*Storage, error) {
  29. list, err := s.ListStorages(ctx, find)
  30. if err != nil {
  31. return nil, err
  32. }
  33. if len(list) == 0 {
  34. return nil, nil
  35. }
  36. return list[0], nil
  37. }
  38. func (s *Store) UpdateStorage(ctx context.Context, update *UpdateStorage) (*Storage, error) {
  39. return s.driver.UpdateStorage(ctx, update)
  40. }
  41. func (s *Store) DeleteStorage(ctx context.Context, delete *DeleteStorage) error {
  42. return s.driver.DeleteStorage(ctx, delete)
  43. }