2023-02-11 20:31:39 +08:00
|
|
|
package store
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
)
|
|
|
|
|
2023-07-04 10:05:57 +08:00
|
|
|
type Storage struct {
|
2023-08-04 21:55:07 +08:00
|
|
|
ID int32
|
2023-02-24 00:02:51 +08:00
|
|
|
Name string
|
2023-07-04 10:05:57 +08:00
|
|
|
Type string
|
|
|
|
Config string
|
2023-02-11 20:31:39 +08:00
|
|
|
}
|
|
|
|
|
2023-07-04 10:05:57 +08:00
|
|
|
type FindStorage struct {
|
2023-08-04 21:55:07 +08:00
|
|
|
ID *int32
|
2023-02-11 20:31:39 +08:00
|
|
|
}
|
|
|
|
|
2023-07-04 10:05:57 +08:00
|
|
|
type UpdateStorage struct {
|
2023-08-04 21:55:07 +08:00
|
|
|
ID int32
|
2023-07-04 10:05:57 +08:00
|
|
|
Name *string
|
|
|
|
Config *string
|
|
|
|
}
|
2023-02-11 20:31:39 +08:00
|
|
|
|
2023-07-04 10:05:57 +08:00
|
|
|
type DeleteStorage struct {
|
2023-08-04 21:55:07 +08:00
|
|
|
ID int32
|
2023-02-11 20:31:39 +08:00
|
|
|
}
|
|
|
|
|
2023-07-04 10:05:57 +08:00
|
|
|
func (s *Store) CreateStorage(ctx context.Context, create *Storage) (*Storage, error) {
|
2023-09-26 19:43:55 +08:00
|
|
|
return s.driver.CreateStorage(ctx, create)
|
2023-02-11 20:31:39 +08:00
|
|
|
}
|
|
|
|
|
2023-07-04 10:05:57 +08:00
|
|
|
func (s *Store) ListStorages(ctx context.Context, find *FindStorage) ([]*Storage, error) {
|
2023-09-26 19:43:55 +08:00
|
|
|
return s.driver.ListStorages(ctx, find)
|
2023-02-11 20:31:39 +08:00
|
|
|
}
|
|
|
|
|
2023-07-04 10:05:57 +08:00
|
|
|
func (s *Store) GetStorage(ctx context.Context, find *FindStorage) (*Storage, error) {
|
2023-07-20 23:15:56 +08:00
|
|
|
list, err := s.ListStorages(ctx, find)
|
2023-02-13 19:36:48 +08:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
if len(list) == 0 {
|
2023-07-04 10:05:57 +08:00
|
|
|
return nil, nil
|
2023-02-13 19:36:48 +08:00
|
|
|
}
|
|
|
|
|
2023-07-04 10:05:57 +08:00
|
|
|
return list[0], nil
|
2023-02-13 19:36:48 +08:00
|
|
|
}
|
|
|
|
|
2023-07-04 10:05:57 +08:00
|
|
|
func (s *Store) UpdateStorage(ctx context.Context, update *UpdateStorage) (*Storage, error) {
|
2023-09-26 19:43:55 +08:00
|
|
|
return s.driver.UpdateStorage(ctx, update)
|
2023-02-11 20:31:39 +08:00
|
|
|
}
|
|
|
|
|
2023-07-04 10:05:57 +08:00
|
|
|
func (s *Store) DeleteStorage(ctx context.Context, delete *DeleteStorage) error {
|
2023-09-26 19:43:55 +08:00
|
|
|
return s.driver.DeleteStorage(ctx, delete)
|
2023-02-11 20:31:39 +08:00
|
|
|
}
|