interfaces

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ISlotRepository

type ISlotRepository interface {
	// AddSpin records a new spin for a user in the repository.
	//
	// Parameters:
	//   - ctx: Context for managing request-scoped values and cancellation signals.
	//   - spin: A pointer to a Spin model containing spin data to be recorded.
	//
	// Returns:
	//   - An error if any issues occur during recording of the spin.
	AddSpin(ctx context.Context, spin *models.Spin) error

	// GetSpins retrieves a user's spin history from the repository.
	//
	// Parameters:
	//   - ctx: Context for managing request-scoped values and cancellation signals.
	//   - userId: The unique numeric ID of the user whose spin history is being retrieved.
	//
	// Returns:
	//   - A slice of pointers to Spin models representing the user's spin history.
	//   - An error if any issues occur during retrieval.
	GetSpins(ctx context.Context, userID uint) ([]*models.Spin, error)
}

ISlotRepository defines methods for slot game data operations in the repository layer.

type ISlotService

type ISlotService interface {
	RetrySpin(ctx context.Context, userID *uuid.UUID, betAmount float64) (*models.Spin, error)

	// History retrieves the spin history for a specified user.
	//
	// Parameters:
	//   - ctx: Context for managing request-scoped values and cancellation signals.
	//   - userID: A UUID representing the user's external identifier.
	//
	// Returns:
	//   - A slice of pointers to spin models representing the user's spin history.
	//   - An error if retrieval fails or any issues occur.
	History(ctx context.Context, userID *uuid.UUID) ([]*models.Spin, error)
}

ISlotService defines service-level methods for handling slot game actions, including spinning and retrieving a user's spin history.

type IUserRepository

type IUserRepository interface {
	// GetByLogin retrieves a user by their login name.
	// Returns the user if found, otherwise returns nil and an error if any issues occur.
	//
	// Parameters:
	//   - ctx: Context for managing request-scoped values and cancellation signals.
	//   - login: The login name of the user to retrieve.
	//
	// Returns:
	//   - A pointer to a User model if found.
	//   - An error if any issues occur during retrieval.
	GetByLogin(ctx context.Context, login string) (*models.User, error)

	// Create adds a new user to the repository.
	// Takes a User model as input and returns the created user and an error if any issues occur.
	//
	// Parameters:
	//   - ctx: Context for managing request-scoped values and cancellation signals.
	//   - user: A pointer to a User model representing the new user to add.
	//
	// Returns:
	//   - A pointer to the created User model.
	//   - An error if any issues occur during creation.
	Create(ctx context.Context, user *models.User) (*models.User, error)

	// GetByExternalId retrieves a user by their UUID identifier.
	//
	// Parameters:
	//   - ctx: Context for managing request-scoped values and cancellation signals.
	//   - id: A UUID representing the external identifier of the user.
	//
	// Returns:
	//   - A pointer to a User model if found.
	//   - An error if any issues occur during retrieval.
	GetByExternalID(ctx context.Context, id *uuid.UUID) (*models.User, error)

	// GetById retrieves a user by their numeric ID.
	//
	// Parameters:
	//   - ctx: Context for managing request-scoped values and cancellation signals.
	//   - id: The unique numeric ID of the user to retrieve.
	//
	// Returns:
	//   - A pointer to a User model if found.
	//   - An error if any issues occur during retrieval.
	GetByID(ctx context.Context, id uint) (*models.User, error)

	// Deposit increases the balance of a specified user by the given amount.
	//
	// Parameters:
	//   - ctx: Context for managing request-scoped values and cancellation signals.
	//   - userId: The unique numeric ID of the user to deposit funds into.
	//   - amount: The amount to deposit to the user's balance.
	//
	// Returns:
	//   - A pointer to the updated balance as a float64.
	//   - An error if any issues occur during the deposit.
	Deposit(ctx context.Context, userID uint, amount float64) (*float64, error)

	// Withdraw decreases the balance of a specified user by the given amount.
	//
	// Parameters:
	//   - ctx: Context for managing request-scoped values and cancellation signals.
	//   - userId: The unique numeric ID of the user to withdraw funds from.
	//   - amount: The amount to withdraw from the user's balance.
	//
	// Returns:
	//   - A pointer to the updated balance as a float64.
	//   - An error if any issues occur during the withdrawal.
	Withdraw(ctx context.Context, userID uint, amount float64) (*float64, error)
}

IUserRepository defines methods for user data operations in the repository layer.

type IUserService

type IUserService interface {
	// Login authenticates a user based on the provided login and password.
	//
	// Parameters:
	//   - ctx: Context for managing request-scoped values and cancellation signals.
	//   - login: The user's login identifier.
	//   - password: The user's password.
	//
	// Returns:
	//   - A pointer to a User model if authentication is successful.
	//   - An error if authentication fails or an issue occurs.
	Login(ctx context.Context, login, password string) (*models.User, error)

	// Register creates a new user account with the specified login and password.
	//
	// Parameters:
	//   - ctx: Context for managing request-scoped values and cancellation signals.
	//   - login: The user's desired login identifier.
	//   - password: The user's chosen password.
	//
	// Returns:
	//   - A pointer to the created User model.
	//   - An error if registration fails or an issue occurs.
	Register(ctx context.Context, login, password string) (*models.User, error)

	// GetByExternalID retrieves a user by their UUID identifier.
	//
	// Parameters:
	//   - ctx: Context for managing request-scoped values and cancellation signals.
	//   - id: A UUID representing the user's external identifier.
	//
	// Returns:
	//   - A pointer to a User model if found.
	//   - An error if the user is not found or if any issues occur.
	GetByExternalID(ctx context.Context, id *uuid.UUID) (*models.User, error)

	// GetByID retrieves a user by their numeric ID.
	//
	// Parameters:
	//   - ctx: Context for managing request-scoped values and cancellation signals.
	//   - id: The unique numeric ID of the user to retrieve.
	//
	// Returns:
	//   - A pointer to a User model if found.
	//   - An error if the user is not found or if any issues occur.
	GetByID(ctx context.Context, id uint) (*models.User, error)

	// Deposit adds a specified amount to the balance of a user identified by their UUID.
	//
	// Parameters:
	//   - ctx: Context for managing request-scoped values and cancellation signals.
	//   - userID: A UUID representing the user's external identifier.
	//   - amount: The amount to be deposited to the user's balance.
	//
	// Returns:
	//   - A pointer to the updated balance as a float64.
	//   - An error if the deposit fails or any issues occur.
	Deposit(ctx context.Context, userID *uuid.UUID, amount float64) (*float64, error)

	// Withdraw deducts a specified amount from the balance of a user identified by their UUID.
	//
	// Parameters:
	//   - ctx: Context for managing request-scoped values and cancellation signals.
	//   - userId: A UUID representing the user's external identifier.
	//   - amount: The amount to be withdrawn from the user's balance.
	//
	// Returns:
	//   - A pointer to the updated balance as a float64.
	//   - An error if the withdrawal fails or any issues occur.
	Withdraw(ctx context.Context, userID *uuid.UUID, amount float64) (*float64, error)
}

IUserService defines service-level methods for handling user-related actions, including authentication, registration, and balance management operations.

type IWalletRepository

type IWalletRepository interface {
	// GetBalance retrieves the balance of a specified user.
	//
	// Parameters:
	//   - ctx: Context for managing request-scoped values and cancellation signals.
	//   - userId: The unique numeric ID of the user whose balance is being retrieved.
	//
	// Returns:
	//   - The user's balance as a float64.
	//   - An error if any issues occur during retrieval.
	GetBalance(ctx context.Context, userID uint) (float64, error)
}

IWalletRepository defines methods for wallet-related data operations in the repository layer.

Directories

Path Synopsis
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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