Documentation
¶
Overview ¶
Package expensecmd provides functionality for handling commands related to expenses.
Package expensecmd provides functionality for handling commands related to expenses.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddCommand ¶
type AddCommand struct { // UserId: The unique identifier of the user to whom the expense belongs. UserId uuid.UUID // Date: The date when the expense occurred. Date time.Time // Description: A brief description of the expense. Description string // Amount: The amount of the expense. Must be a positive float value. Amount float32 }
AddCommand represents the command to add an expense.
type AddHandler ¶
type AddHandler struct {
// contains filtered or unexported fields
}
AddHandler handles commands for adding new expenses.
func NewAddHandler ¶
func NewAddHandler(config Config) *AddHandler
NewAddHandler creates a new AddHandler with the specified configuration.
func (*AddHandler) Handle ¶
func (h *AddHandler) Handle(command *AddCommand) (*expensemodel.Expense, error)
Handle processes an AddCommand to create a new expense and returns the expense.
type Config ¶
type Config struct { UserRepository irepository.IUserRepository // Repository for user data TimeService itimeservice.IService // Service for time-related operations }
Config holds dependencies required for creating an AddHandler.
type PatchCommand ¶
type PatchCommand struct { Description *string // Optional new description for the expense Amount *float32 // Optional new amount for the expense Date *time.Time // Optional new date for the expense Id uuid.UUID // Unique identifier of the expense to be updated UserId uuid.UUID // Identifier of the user who owns the expense }
PatchCommand represents a command to update an existing expense.
type PatchHandler ¶
type PatchHandler struct {
// contains filtered or unexported fields
}
PatchHandler manages the patching of expenses.
func NewPatchHandler ¶
func NewPatchHandler(expenseRepository irepository.IExpenseRepository) *PatchHandler
NewPatchHandler creates a new PatchHandler with the provided expense repository.
func (*PatchHandler) Handle ¶
func (h *PatchHandler) Handle(cmd *PatchCommand) (*expensemodel.Expense, error)
Handle processes a PatchCommand to update an existing expense. It retrieves the expense by its ID and user ID, updates the expense fields if provided, and saves the changes to the repository.
Returns:
- *expensemodel.Expense: The updated expense.
- error: An error if the update fails. Possible errors include issues with retrieving or updating the expense, or saving the changes to the repository.