76 lines
2.3 KiB
Go
76 lines
2.3 KiB
Go
package wishlist
|
|
|
|
import (
|
|
"wish-list-api/api/presenter"
|
|
"wish-list-api/pkg/entities"
|
|
)
|
|
|
|
type Service interface {
|
|
CreateWishList(wishList *entities.WishList) (*entities.WishList, error)
|
|
GetWishList(ID string) (*entities.WishList, error)
|
|
GetAllWishLists(userID string) (*[]presenter.WishList, error)
|
|
GetPublicWishLists() (*[]presenter.WishList, error)
|
|
UpdateWishList(wishList *entities.WishList) (*entities.WishList, error)
|
|
DeleteWishList(ID string) error
|
|
|
|
CreateWishListItem(item *entities.WishListItem) (*entities.WishListItem, error)
|
|
GetWishListItem(ID string) (*entities.WishListItem, error)
|
|
GetAllWishListItems(wishListID string) (*[]presenter.WishListItem, error)
|
|
UpdateWishListItem(item *entities.WishListItem) (*entities.WishListItem, error)
|
|
DeleteWishListItem(ID string) error
|
|
}
|
|
|
|
type service struct {
|
|
repository Repository
|
|
}
|
|
|
|
func NewService(r Repository) Service {
|
|
return &service{
|
|
repository: r,
|
|
}
|
|
}
|
|
|
|
func (s *service) CreateWishList(wishList *entities.WishList) (*entities.WishList, error) {
|
|
return s.repository.CreateWishList(wishList)
|
|
}
|
|
|
|
func (s *service) GetWishList(ID string) (*entities.WishList, error) {
|
|
return s.repository.ReadWishList(ID)
|
|
}
|
|
|
|
func (s *service) GetAllWishLists(userID string) (*[]presenter.WishList, error) {
|
|
return s.repository.ReadAllWishLists(userID)
|
|
}
|
|
|
|
func (s *service) GetPublicWishLists() (*[]presenter.WishList, error) {
|
|
return s.repository.ReadPublicWishLists()
|
|
}
|
|
|
|
func (s *service) UpdateWishList(wishList *entities.WishList) (*entities.WishList, error) {
|
|
return s.repository.UpdateWishList(wishList)
|
|
}
|
|
|
|
func (s *service) DeleteWishList(ID string) error {
|
|
return s.repository.DeleteWishList(ID)
|
|
}
|
|
|
|
func (s *service) CreateWishListItem(item *entities.WishListItem) (*entities.WishListItem, error) {
|
|
return s.repository.CreateWishListItem(item)
|
|
}
|
|
|
|
func (s *service) GetWishListItem(ID string) (*entities.WishListItem, error) {
|
|
return s.repository.ReadWishListItem(ID)
|
|
}
|
|
|
|
func (s *service) GetAllWishListItems(wishListID string) (*[]presenter.WishListItem, error) {
|
|
return s.repository.ReadAllWishListItems(wishListID)
|
|
}
|
|
|
|
func (s *service) UpdateWishListItem(item *entities.WishListItem) (*entities.WishListItem, error) {
|
|
return s.repository.UpdateWishListItem(item)
|
|
}
|
|
|
|
func (s *service) DeleteWishListItem(ID string) error {
|
|
return s.repository.DeleteWishListItem(ID)
|
|
}
|