controllers

package
v0.0.0-...-06bc701 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2025 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrFetchUsers = "Could not fetch users"
	ErrParseId    = "Invalid ID format"
	ErrJSONFormat = "Invalid JSON format or fields"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BoardController

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

func NewBoardController

func NewBoardController(db *sql.DB) *BoardController

func (*BoardController) CreateBoard

func (c *BoardController) CreateBoard(w http.ResponseWriter, r *http.Request)

func (*BoardController) RegisterRoutes

func (c *BoardController) RegisterRoutes(r chi.Router)

type UserController

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

func NewUserController

func NewUserController(db *sql.DB, jwt *services.JWTService, blacklistRepo *services.TokenBlacklist, emService *services.EmailService) *UserController

func (*UserController) CreateUser

func (c *UserController) CreateUser(w http.ResponseWriter, r *http.Request)

CreateUser godoc @Summary Create a new user @Description Creates a new user in the system @Tags users @Accept json @Produce json @Param user body commands.CreateUserCommand true "User creation payload" @Success 201 {object} helpers.GetUserResponse @Failure 400 {object} helpers.GetUserResponse "Invalid request body" @Failure 500 {object} helpers.GetUserResponse "Server error" @Router /users/create [post]

func (*UserController) DeleteUser

func (c *UserController) DeleteUser(w http.ResponseWriter, r *http.Request)

DeleteUser godoc @Summary Delete a user @Description Deletes a user by ID @Tags users @Accept json @Produce json @Param id path string true "User ID" @Success 200 {object} helpers.GetUserResponse "Deleted user" @Failure 400 {object} helpers.GetUserResponse "Invalid UUID" @Failure 500 {object} helpers.GetUserResponse "Server error" @Router /users/{id} [delete]

func (*UserController) GetAllUsers

func (c *UserController) GetAllUsers(w http.ResponseWriter, r *http.Request)

GetAllUsers godoc @Summary Get all users @Description Returns a list of all registered users @Tags users @Produce json @Success 200 {object} helpers.GetListUsersDTO @Failure 500 {object} helpers.GetListUsersDTO "Server error" @Router /users/all [get]

func (*UserController) GetListUsers

func (c *UserController) GetListUsers(w http.ResponseWriter, r *http.Request)

GetListUsers godoc @Summary Get list of active users @Description Returns all users where deleted_at IS NULL @Tags Users @Produce json @Success 200 {object} helpers.GetListUsersDTO @Failure 500 {object} helpers.GetListUsersDTO "Server error" @Router /users/list [get]

func (*UserController) GetUserByEmail

func (c *UserController) GetUserByEmail(w http.ResponseWriter, r *http.Request)

GetUserByEmail godoc @Summary Get user by email @Description Returns a single user by email address @Tags users @Produce json @Param email path string true "User email" @Success 200 {object} helpers.GetUserDTO @Failure 400 {object} helpers.GetUserDTO "Invalid email" @Failure 500 {object} helpers.GetUserDTO "Server error" @Router /users/email/{email} [get]

func (*UserController) GetUserById

func (c *UserController) GetUserById(w http.ResponseWriter, r *http.Request)

GetUserById godoc @Summary Get user by ID @Description Returns a single user by UUID @Tags users @Produce json @Param id path string true "User ID (UUID)" @Success 200 {object} helpers.GetUserDTO @Failure 400 {object} helpers.GetUserDTO "Invalid id" @Failure 500 {object} helpers.GetUserDTO "Server error" @Router /users/id/{id} [get]

func (*UserController) GetUserByUsername

func (c *UserController) GetUserByUsername(w http.ResponseWriter, r *http.Request)

GetUserByUsername godoc @Summary Get user by username @Description Returns a single user by username @Tags users @Produce json @Param username path string true "Username" @Success 200 {object} helpers.GetUserDTO @Failure 400 {object} helpers.GetUserDTO "Invalid username" @Failure 500 {object} helpers.GetUserDTO "Server error" @Router /users/username/{username} [get]

func (*UserController) GetUsersByCountry

func (c *UserController) GetUsersByCountry(w http.ResponseWriter, r *http.Request)

GetUsersByCountry godoc @Summary Get users by country @Description Returns a list of users filtered by country @Tags users @Produce json @Param country path string true "Country name" @Success 200 {object} helpers.GetListUsersDTO @Failure 400 {object} helpers.GetListUsersDTO "Invalid country" @Failure 500 {object} helpers.GetListUsersDTO "Server error" @Router /users/country/{country} [get]

func (*UserController) GetUsersByLanguage

func (c *UserController) GetUsersByLanguage(w http.ResponseWriter, r *http.Request)

GetUsersByLanguage godoc @Summary Get users by language @Description Returns a list of users filtered by language @Tags users @Produce json @Param country path string true "Country name" @Success 200 {object} helpers.GetListUsersDTO @Failure 400 {object} helpers.GetListUsersDTO "Invalid country" @Failure 500 {object} helpers.GetListUsersDTO "Server error" @Router /users/language/{language} [get]

func (*UserController) GetUsersLikeUsername

func (c *UserController) GetUsersLikeUsername(w http.ResponseWriter, r *http.Request)

GetUsersLikeUsername godoc @Summary Get users by partial username @Description Returns a list of users whose usernames match the provided pattern @Tags users @Produce json @Param username path string true "Username pattern" @Success 200 {object} helpers.GetListUsersDTO @Failure 400 {object} helpers.GetListUsersDTO "Invalid username" @Failure 500 {object} helpers.GetListUsersDTO "Server error" @Router /users/like-username/{username} [get]

func (*UserController) ListCountries

func (c *UserController) ListCountries(w http.ResponseWriter, r *http.Request)

ListCountries godoc @Summary List all countries @Description Returns a list of available countries @Tags users @Produce json @Success 200 {object} helpers.GetCountriesList "List of countries" @Router /users/countries [get]

func (*UserController) ListLanguages

func (c *UserController) ListLanguages(w http.ResponseWriter, r *http.Request)

ListLanguages godoc @Summary List all languages @Description Returns a list of available languages @Tags users @Produce json @Success 200 {object} helpers.GetLanguagesList "List of languages" @Router /users/languages [get]

func (*UserController) LoginUser

func (c *UserController) LoginUser(w http.ResponseWriter, r *http.Request)

LoginUser godoc @Summary Login a user @Description Authenticates a user and returns a JWT token @Tags users @Accept json @Produce json @Param credentials body commands.LoginUserCommand true "User login payload" @Success 200 {object} helpers.LoginSuccessResponse "User data and token" @Failure 400 {object} helpers.GetUserResponse "Invalid request body" @Failure 401 {object} helpers.GetUserResponse "Authentication failed" @Failure 500 {object} helpers.GetUserResponse "Server error" @Router /users/login [post]

func (*UserController) Logout

func (c *UserController) Logout(w http.ResponseWriter, r *http.Request)

Logout godoc @Summary Logout user @Description Revokes the current JWT token @Tags users @Produce json @Param Authorization header string true "Bearer token" @Success 200 {object} helpers.LogoutSuccessResponse "Logout successful" @Failure 401 {object} helpers.GetUserResponse "Missing or invalid token" @Failure 500 {object} helpers.GetUserResponse "Logout failed" @Router /users/logout [post]

func (*UserController) RegisterRoutes

func (c *UserController) RegisterRoutes(r chi.Router)

func (*UserController) RestoreUser

func (c *UserController) RestoreUser(w http.ResponseWriter, r *http.Request)

RestoreUser godoc @Summary Restore a deleted user @Description Restores a user by ID that was previously soft-deleted @Tags users @Accept json @Produce json @Param id path string true "User ID" @Success 200 {object} helpers.GetUserResponse "Restored user" @Failure 400 {object} helpers.GetUserResponse "Invalid UUID" @Failure 500 {object} helpers.GetUserResponse "Server error" @Router /users/restore/{id} [patch]

func (*UserController) UpdateUser

func (c *UserController) UpdateUser(w http.ResponseWriter, r *http.Request)

UpdateUser godoc @Summary Update a user @Description Updates the authenticated user's information @Tags users @Accept json @Produce json @Param user body commands.UpdateUserCommand true "User update payload" @Success 200 {object} helpers.GetUserResponse @Failure 400 {object} helpers.GetUserResponse "Invalid request body" @Failure 403 {object} helpers.GetUserResponse "Forbidden: cannot update another user" @Failure 500 {object} helpers.GetUserResponse "Server error" @Router /users/ [put]

func (*UserController) UploadProfilePic

func (c *UserController) UploadProfilePic(w http.ResponseWriter, r *http.Request)

UploadProfilePic godoc @Summary Upload a user's profile picture @Description Uploads a profile picture for the given user @Tags users @Accept multipart/form-data @Produce json @Param id path string true "User ID" @Param profile_pic formData file true "Profile picture file" @Success 200 {object} helpers.LogoutSuccessResponse "Uploaded file info" @Failure 400 {object} helpers.GetUserDTO "Bad request / missing file" @Failure 500 {object} helpers.GetUserDTO "Server error" @Router /users/profilepic/{id} [patch]

func (*UserController) VerifyEmail

func (c *UserController) VerifyEmail(w http.ResponseWriter, r *http.Request)

VerifyEmail godoc @Summary Verify user's email @Description Verifies the email of a user using a token @Tags users @Accept json @Produce json @Param token query string true "Verification token" @Success 303 "Redirects to login page with verification success" @Failure 400 {string} string "Missing or invalid token" @Router /verify-email [get]

Jump to

Keyboard shortcuts

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