service

package
v0.0.0-...-5a72114 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 22, 2024 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAdvertNotFound      = errors.New("advert not found")
	ErrAdvertBadRequest    = errors.New("bad request: invalid advert data")
	ErrAdvertAlreadyExists = errors.New("advert already exists")
	ErrForbidden           = errors.New("forbidden: you cannot modify this source")
)

Functions

This section is empty.

Types

type AdvertService

type AdvertService struct {
	// contains filtered or unexported fields
}

func NewAdvertService

func NewAdvertService(advertRepo repository.AdvertRepository,
	sellerRepo repository.Seller,
	userRepo repository.User,
	historyRepo repository.HistoryRepository,
) *AdvertService

func (*AdvertService) Add

func (s *AdvertService) Add(advert *dto.AdvertRequest, userId uuid.UUID) (*dto.Advert, error)

func (*AdvertService) AddToSaved

func (s *AdvertService) AddToSaved(advertId, userId uuid.UUID) error

func (*AdvertService) AddViewed

func (s *AdvertService) AddViewed(advertId, userId uuid.UUID) error

func (*AdvertService) DeleteById

func (s *AdvertService) DeleteById(advertId uuid.UUID, userId uuid.UUID) error

func (*AdvertService) Get

func (s *AdvertService) Get(limit, offset int, userId uuid.UUID) ([]*dto.PreviewAdvertCard, error)

func (*AdvertService) GetByCartId

func (s *AdvertService) GetByCartId(cartId, userId uuid.UUID) ([]*dto.PreviewAdvertCard, error)

func (*AdvertService) GetByCategoryId

func (s *AdvertService) GetByCategoryId(categoryId, userId uuid.UUID) ([]*dto.PreviewAdvertCard, error)

func (*AdvertService) GetById

func (s *AdvertService) GetById(advertId, userId uuid.UUID) (*dto.AdvertCard, error)

func (*AdvertService) GetBySellerId

func (s *AdvertService) GetBySellerId(userId, sellerId uuid.UUID) ([]*dto.PreviewAdvertCard, error)

func (*AdvertService) GetByUserId

func (s *AdvertService) GetByUserId(userId uuid.UUID) ([]*dto.MyPreviewAdvertCard, error)

func (*AdvertService) GetSavedByUserId

func (s *AdvertService) GetSavedByUserId(userId uuid.UUID) ([]*dto.PreviewAdvertCard, error)

func (*AdvertService) RemoveFromSaved

func (s *AdvertService) RemoveFromSaved(advertId, userId uuid.UUID) error

func (*AdvertService) Search

func (s *AdvertService) Search(query string, batchSize, limit, offset int, userId uuid.UUID) ([]*dto.PreviewAdvertCard, error)

func (*AdvertService) Update

func (s *AdvertService) Update(advert *dto.AdvertRequest, userId uuid.UUID, advertId uuid.UUID) error

func (*AdvertService) UpdateStatus

func (s *AdvertService) UpdateStatus(advertId, userId uuid.UUID, status dto.AdvertStatus) error

func (*AdvertService) UploadImage

func (s *AdvertService) UploadImage(advertId uuid.UUID, imageId uuid.UUID, userId uuid.UUID) error

type AuthService

type AuthService struct {
	// contains filtered or unexported fields
}

func NewAuthService

func NewAuthService(authRepo repository.Session) *AuthService

func (*AuthService) CreateSession

func (a *AuthService) CreateSession(userId uuid.UUID) (string, error)

func (*AuthService) GetUserIdBySession

func (a *AuthService) GetUserIdBySession(session string) (uuid.UUID, error)

func (*AuthService) Logout

func (a *AuthService) Logout(session string) error

type CartService

type CartService struct {
	// contains filtered or unexported fields
}

func NewCartService

func NewCartService(cartRepo repository.Cart, advertRepo repository.AdvertRepository) *CartService

func (*CartService) AddAdvert

func (c *CartService) AddAdvert(userID, advertID uuid.UUID) error

func (*CartService) CheckExists

func (c *CartService) CheckExists(userID uuid.UUID) (uuid.UUID, error)

func (*CartService) DeleteAdvert

func (c *CartService) DeleteAdvert(cartID uuid.UUID, advertID uuid.UUID) error

func (*CartService) GetById

func (c *CartService) GetById(cartID uuid.UUID) (dto.Cart, error)

func (*CartService) GetByUserId

func (c *CartService) GetByUserId(userID uuid.UUID) (dto.Cart, error)

type CategoryService

type CategoryService struct {
	// contains filtered or unexported fields
}

func NewCategoryService

func NewCategoryService(categoryRepo repository.CategoryRepository) *CategoryService

func (*CategoryService) Get

func (s *CategoryService) Get() ([]*entity.Category, error)

type PaymentRequest

type PaymentRequest struct {
	Amount struct {
		Value    string `json:"value"`
		Currency string `json:"currency"`
	} `json:"amount"`
	Capture      bool `json:"capture"`
	Confirmation struct {
		Type      string `json:"type"`
		ReturnURL string `json:"return_url"`
	} `json:"confirmation"`
	Description string `json:"description"`
	Metadata    struct {
		OrderID string `json:"order_id"`
		ItemID  string `json:"item_id"`
	} `json:"metadata"`
}

type PaymentResponse

type PaymentResponse struct {
	ID           string `json:"id"`
	Status       string `json:"status"`
	Confirmation struct {
		ConfirmationURL string `json:"confirmation_url"`
	} `json:"confirmation"`
}

type PaymentService

type PaymentService struct {
	// contains filtered or unexported fields
}

func NewPaymentService

func NewPaymentService(paymentShopID, paymentSecret string,
	paymentRepo repository.PaymentRepository, advertRepo repository.AdvertRepository,
	promotionRepo repository.PromotionRepository,
) *PaymentService

func (*PaymentService) InitPayment

func (s *PaymentService) InitPayment(itemId string) (*string, error)

func (*PaymentService) PaymentProcessor

func (s *PaymentService) PaymentProcessor(ctx context.Context)

type PromotionService

type PromotionService struct {
	// contains filtered or unexported fields
}

func NewPromotionService

func NewPromotionService(promotionRepo repository.PromotionRepository) *PromotionService

func (*PromotionService) GetPromotionInfo

func (s *PromotionService) GetPromotionInfo() (*entity.Promotion, error)

type PurchaseService

type PurchaseService struct {
	// contains filtered or unexported fields
}

func NewPurchaseService

func NewPurchaseService(purchaseRepo repository.PurchaseRepository, advertRepo repository.AdvertRepository, cartRepo repository.Cart) *PurchaseService

func (*PurchaseService) Add

func (s *PurchaseService) Add(purchaseRequest dto.PurchaseRequest, userId uuid.UUID) ([]*dto.PurchaseResponse, error)

func (*PurchaseService) GetByUserId

func (s *PurchaseService) GetByUserId(userID uuid.UUID) ([]*dto.PurchaseResponse, error)

type StaticService

type StaticService struct {
	// contains filtered or unexported fields
}

func NewStaticService

func NewStaticService(staticRepo repository.StaticRepository) *StaticService

func (*StaticService) GetAvatar

func (s *StaticService) GetAvatar(staticID uuid.UUID) (string, error)

func (*StaticService) GetStatic

func (s *StaticService) GetStatic(id uuid.UUID) (string, error)

func (*StaticService) GetStaticFile

func (s *StaticService) GetStaticFile(staticURI string) (io.ReadSeeker, error)

func (*StaticService) UploadStatic

func (s *StaticService) UploadStatic(reader io.ReadSeeker) (uuid.UUID, error)

type UserService

type UserService struct {
	// contains filtered or unexported fields
}

func NewUserService

func NewUserService(userRepo repository.User, sellerRepo repository.Seller) *UserService

func (*UserService) ChangePassword

func (u *UserService) ChangePassword(userID uuid.UUID, password *dto.UpdatePassword) error

func (*UserService) Delete

func (u *UserService) Delete(userID uuid.UUID) error

func (*UserService) Get

func (u *UserService) Get(userID uuid.UUID) (*dto.User, error)

func (*UserService) Login

func (u *UserService) Login(loginInfo *dto.Login) (uuid.UUID, error)

func (*UserService) Signup

func (u *UserService) Signup(signupInfo *dto.Signup) (uuid.UUID, error)

func (*UserService) UpdateInfo

func (u *UserService) UpdateInfo(user *dto.UserUpdate) error

func (*UserService) UploadImage

func (u *UserService) UploadImage(userID uuid.UUID, imageId uuid.UUID) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL