v1

package
v0.0.0-...-a60134b Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ErrorResponse

type ErrorResponse struct {
	Error   string `json:"error" example:"Invalid request parameters"`
	Message string `json:"message,omitempty" example:"Email is already taken"`
}

ErrorResponse represents the error response structure

type ListUserResponse

type ListUserResponse struct {
	Users      []UserResponse `json:"users"`
	TotalCount int64          `json:"total_count" example:"100"`
	Page       int            `json:"page" example:"1"`
	PerPage    int            `json:"per_page" example:"10"`
}

ListUserResponse represents the paginated response for user listing

type UserController

type UserController struct{}

func NewUserController

func NewUserController() *UserController

func (*UserController) Create

func (uc *UserController) Create(c *gin.Context)

Create godoc @Summary Create user @Description Create a new user @Tags v1/users @Accept json @Produce json @Param request body user.CreateRequest true "User Information" @Success 201 {object} user.Response @Failure 400 {object} common.ErrorResponse @Failure 409 {object} common.ErrorResponse @Router /api/v1/users [post]

func (*UserController) Delete

func (uc *UserController) Delete(c *gin.Context)

Delete godoc @Summary Delete user @Description Delete user by ID @Tags v1/users @Accept json @Produce json @Param id path uint true "User ID" @Success 204 {object} nil @Failure 404 {object} ErrorResponse @Router /api/v1/users/{id} [delete]

func (*UserController) Get

func (uc *UserController) Get(c *gin.Context)

Get godoc @Summary Get user @Description Get user by ID @Tags v1/users @Accept json @Produce json @Param id path uint true "User ID" @Success 200 {object} UserResponse @Failure 404 {object} ErrorResponse @Router /api/v1/users/{id} [get]

func (*UserController) List

func (uc *UserController) List(c *gin.Context)

List godoc @Summary List users @Description Get paginated list of users @Tags v1/users @Accept json @Produce json @Param request query common.PaginationQuery false "Pagination params" @Success 200 {object} user.ListResponse @Failure 400 {object} common.ErrorResponse @Router /api/v1/users [get]

func (*UserController) Update

func (uc *UserController) Update(c *gin.Context)

Update godoc @Summary Update user @Description Update user by ID @Tags v1/users @Accept json @Produce json @Param id path uint true "User ID" @Param request body UserUpdateRequest true "User Information" @Success 200 {object} UserResponse @Failure 400 {object} ErrorResponse @Failure 404 {object} ErrorResponse @Router /api/v1/users/{id} [put]

type UserCreateRequest

type UserCreateRequest struct {
	Username string `json:"username" binding:"required" example:"johndoe"`
	Email    string `json:"email" binding:"required,email" example:"john@example.com"`
	Password string `json:"password" binding:"required" example:"secretpassword123"`
}

UserCreateRequest represents the request body for creating a user

type UserResponse

type UserResponse struct {
	ID        uint      `json:"id" example:"1"`
	Username  string    `json:"username" example:"johndoe"`
	Email     string    `json:"email" example:"john@example.com"`
	CreatedAt time.Time `json:"created_at" example:"2024-10-26T12:34:56Z"`
	UpdatedAt time.Time `json:"updated_at" example:"2024-10-26T12:34:56Z"`
}

UserResponse represents the response structure for user data

type UserUpdateRequest

type UserUpdateRequest struct {
	Username string `json:"username" example:"johndoe"`
	Email    string `json:"email" binding:"email" example:"john@example.com"`
	Password string `json:"password" example:"newpassword123"`
}

UserUpdateRequest represents the request body for updating a user

Jump to

Keyboard shortcuts

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