Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Router ¶
func Router(configs *config.Config, router *gin.Engine, handler *Handler, authMiddleware *jwt.GinJWTMiddleware)
Router sets up the routes for the user-related API endpoints. It takes in the application configuration, the Gin router instance, the handler for user operations, and the authentication middleware to secure the endpoints.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler struct represents the HTTP handler for user-related operations. It contains a reference to the userService which handles the business logic.
func NewUserHandler ¶
NewUserHandler creates a new Handler instance with the provided userService. It returns a pointer to the Handler struct.
type Repository ¶
type Repository interface { // Insert adds a new user to the database. // It returns the inserted user and an error if something goes wrong. Insert(ctx context.Context, user *entity.User) (*entity.User, error) // FindByEmail retrieves a user by their email address. // It returns the user if found or an error if something goes wrong or the user does not exist. FindByEmail(ctx context.Context, email string) (*entity.User, error) // FindByID retrieves a user by their unique identifier (ID). // It returns the user if found or an error if something goes wrong or the user does not exist. FindByID(ctx context.Context, id string) (*entity.User, error) // Update modifies the details of an existing user identified by ID. // It takes a map of field names and values to update and returns an error if the update fails. Update(ctx context.Context, id string, updates map[string]interface{}) error }
Repository defines the interface for user-related data operations.
func NewUserRepository ¶
func NewUserRepository(db *gorm.DB) Repository
NewUserRepository creates a new instance of userRepositoryImpl with the provided database connection.
type Service ¶
type Service interface { CreateUser(ctx context.Context, user *dto.RegisterRequestDto) (*dto.UserResponseDto, error) UpdateUser(ctx context.Context, userID string, updates map[string]interface{}) error GetUserByID(ctx context.Context, userID string) (*dto.UserResponseDto, error) GetUserByEmail(ctx context.Context, email string) (*dto.UserResponseDto, error) }
Service defines the methods that our User Service should implement.
func NewUserService ¶
func NewUserService(userRepository Repository, transactionManager postgres.TransactionManager) Service
NewUserService creates a new instance of userServiceImpl with the provided Repository. This function initializes the user service with the repository it will use for data operations.