controller

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateBook

func CreateBook(c *fiber.Ctx) error

CreateBook func for creates a new book. @Description Create a new book. @Summary create a new book @Tags Book @Accept json @Produce json @Param createbook body model.Book true "Create new book" @Failure 400,401,500 {object} ErrorResponse status "Error" @Success 200 {object} model.Book status "Ok" @Security ApiKeyAuth @Router /v1/books [post]

func CreateUser

func CreateUser(c *fiber.Ctx) error

CreateUser func for creates a new user. @Description Create a new user. @Summary create a new user @Tags User @Accept json @Produce json @Param createuser body model.CreateUser true "Create new user" @Failure 400,401,409,500 {object} ErrorResponse status "Error" @Success 200 {object} dto.User status "Ok" @Security ApiKeyAuth @Router /v1/users [post]

func DeleteBook

func DeleteBook(c *fiber.Ctx) error

DeleteBook func delete a book. @Description delete book @Summary delete a book @Tags Book @Accept json @Produce json @Param id path string true "Book ID" @Success 200 {object} interface{} "Ok" @Failure 401,403,404,500 {object} ErrorResponse "Error" @Security ApiKeyAuth @Router /v1/books/{id} [delete]

func DeleteUser

func DeleteUser(c *fiber.Ctx) error

DeleteUser func delete a user. @Description delete user @Summary delete a user @Tags User @Accept json @Produce json @Param id path string true "User ID" @Success 200 {object} interface{} "Ok" @Failure 401,403,404,500 {object} ErrorResponse "Error" @Security ApiKeyAuth @Router /v1/users/{id} [delete]

func GenerateNewAccessToken

func GenerateNewAccessToken(userID int, isAdmin bool) (string, error)

func GeneratePasswordHash

func GeneratePasswordHash(password []byte) (string, error)

func GetBook

func GetBook(c *fiber.Ctx) error

GetBook func gets a book. @Description a book. @Summary get a book @Tags Book @Accept json @Produce json @Param id path string true "Book ID" @Success 200 {object} model.Book @Failure 400,404 {object} ErrorResponse "Error" @Router /v1/books/{id} [get]

func GetBooks

func GetBooks(c *fiber.Ctx) error

GetBooks func gets all exists book. @Description Get all exists book. @Summary get all exists book @Tags Book @Accept json @Produce json @Param page query integer false "Page no" @Param page_size query integer false "records per page" @Success 200 {array} model.Book @Failure 400 {object} ErrorResponse "Error" @Router /v1/books [get]

func GetNewAccessToken

func GetNewAccessToken(c *fiber.Ctx) error

GetNewAccessToken method for create a new access token. @Description Create a new access token. @Summary create a new access token @Tags Token @Accept json @Produce json @Param login body model.Auth true "Request for token" @Failure 400,404,401,500 {object} ErrorResponse status "Error" @Success 200 {object} TokenResponse status "Ok" @Router /v1/token/new [post]

func GetPagination

func GetPagination(c *fiber.Ctx) (pageNo, pageSize int)

func GetUser

func GetUser(c *fiber.Ctx) error

GetUser func gets a user. @Description a user. @Summary get a user @Tags User @Accept json @Produce json @Param id path string true "User ID" @Success 200 {object} dto.User @Failure 400,401,403,404 {object} ErrorResponse "Error" @Security ApiKeyAuth @Router /v1/users/{id} [get]

func GetUsers

func GetUsers(c *fiber.Ctx) error

GetUsers func gets all exists user. @Description Get all exists user. @Summary get all exists user @Tags User @Accept json @Produce json @Param page query integer false "Page no" @Param page_size query integer false "records per page" @Success 200 {array} dto.User @Failure 400,401,403 {object} ErrorResponse "Error" @Security ApiKeyAuth @Router /v1/users [get]

func IsValidPassword

func IsValidPassword(hash, password []byte) bool

func UpdateBook

func UpdateBook(c *fiber.Ctx) error

UpdateBook func update a book. @Description update book @Summary update a book @Tags Book @Accept json @Produce json @Param id path string true "Book ID" @Param updatebook body model.Book true "Update a book" @Success 200 {object} model.Book @Failure 400,401,403,404,500 {object} ErrorResponse "Error" @Security ApiKeyAuth @Router /v1/books/{id} [put]

func UpdateUser

func UpdateUser(c *fiber.Ctx) error

UpdateUser func update a user. @Description first_name, last_name, is_active, is_admin only @Summary update a user @Tags User @Accept json @Produce json @Param id path string true "User ID" @Param updateuser body model.UpdateUser true "Update a user" @Success 200 {object} dto.User @Failure 400,401,403,404,500 {object} ErrorResponse "Error" @Security ApiKeyAuth @Router /v1/users/{id} [put]

Types

type ErrorResponse

type ErrorResponse struct {
	Msg string `json:"msg"`
}

type TokenResponse

type TokenResponse struct {
	AccessToken string `json:"access_token"`
	Msg         string `json:"msg"`
}

Jump to

Keyboard shortcuts

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