handlers

package
v0.0.0-...-1911959 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnName

type ColumnName struct {
	ColumnName string `json:"name" form:"name" binding:"required"`
}

type ColumnNameExample

type ColumnNameExample struct {
	Name string `json:"name"`
}

type ContentTypeHandlers

type ContentTypeHandlers struct {
	Service service.ContentTypeService
}

func (*ContentTypeHandlers) AddCol

func (ch *ContentTypeHandlers) AddCol(ctx *gin.Context)

@Security bearerAuth @Summary adds column endpoint @Description takes userId and content type Id in path to add new column @Accept application/json @Produce application/json @Param userId path int true "User ID" @Param contentTypeId path int true "Content Type ID" @Param columnName body handlers.ColumnNameExample true "column name : its type" @Success 200 {object} response.Response @Failure 401 object} errs.ErrResponse "Unauthorized" @Failure 500 {object} errs.ErrResponse "Internal server error" @Failure 404 {object} errs.ErrResponse "Content type not found" @Failure 400 {object} errs.ErrResponse "Bad request" @Router /contentType/addcol/{userId}/{contentTypeId} [put]

func (*ContentTypeHandlers) CreateContentType

func (ch *ContentTypeHandlers) CreateContentType(ctx *gin.Context)

@Security bearerAuth @Summary Create content type endpoint @Description takes user id as path param to check his role and see if he is authorized to do this action, name is a required attribute @Accept application/json @Produce application/json @Param userId path int true "User ID" @Param contentType body contentType.ContentTypeExample true "Content Type body" @Success 200 {object} handlers.ID @Failure 500 {object} errs.ErrResponse "Internal server error" @Failure 400 {object} errs.ErrResponse "Bad request" @Failure 401 {object} errs.ErrResponse "Unauthorized error" @Router /contentType/{userId} [post]

func (*ContentTypeHandlers) DeleteCol

func (ch *ContentTypeHandlers) DeleteCol(ctx *gin.Context)

@Security bearerAuth @Summary deletes column endpoint @Description takes userId and content type Id in path to delete a column @Consume application/x-www-form-urlencoded @Produce application/json @Param userId path int true "User ID" @Param contentTypeId path int true "Content Type ID" @Param name formData string true "Column Name" @Success 200 {object} response.Response @Failure 401 object} errs.ErrResponse "Unauthorized" @Failure 500 {object} errs.ErrResponse "Internal server error" @Failure 404 {object} errs.ErrResponse "Content type not found" @Failure 400 {object} errs.ErrResponse "Bad request" @Router /contentType/delcol/{userId}/{contentTypeId} [put]

func (*ContentTypeHandlers) DeleteContentType

func (ch *ContentTypeHandlers) DeleteContentType(ctx *gin.Context)

@Security bearerAuth @Summary delete content type endpoint @Description takes userId and content type Id in path to delete content type @Accept application/json @Produce application/json @Param userId path int true "User ID" @Param contentTypeId path int true "Content Type ID" @Success 200 {object} response.Response @Failure 401 object} errs.ErrResponse "Unauthorized" @Failure 500 {object} errs.ErrResponse "Internal server error" @Failure 404 {object} errs.ErrResponse "Content type not found" @Failure 400 {object} errs.ErrResponse "Bad request" @Router /contentType/{userId}/{contentTypeId} [delete]

func (*ContentTypeHandlers) UpdateColName

func (ch *ContentTypeHandlers) UpdateColName(ctx *gin.Context)

@Security bearerAuth @Summary updates column name endpoint @Description takes userId and content type Id in path to update name of content type column @Accept application/json @Produce application/json @Param userId path int true "User ID" @Param contentTypeId path int true "Content Type ID" @Param columnName body handlers.ColumnNameExample true "oldname : newname" @Success 200 {object} response.Response @Failure 401 object} errs.ErrResponse "Unauthorized" @Failure 500 {object} errs.ErrResponse "Internal server error" @Failure 404 {object} errs.ErrResponse "Content type not found" @Failure 400 {object} errs.ErrResponse "Bad request" @Router /contentType/renamecol/{userId}/{contentTypeId} [put]

type ID

type ID struct {
	ID string `json:"table_id"`
}

type JWT

type JWT struct {
	Token string `json:"token"`
}

type Login

type Login struct {
	Email    string `json:"email" form:"email" binding:"required,email"`
	Password string `json:"password" form:"password" binding:"required"`
}

type RoleHandlers

type RoleHandlers struct {
	Service service.RoleService
}

func (RoleHandlers) Create

func (roleHandler RoleHandlers) Create(ctx *gin.Context)

@Summary Create role endpoint @Description Provide role name to create new role @Consume application/x-www-form-urlencoded @Produce application/json @Param name formData string true "Name" @Success 200 {object} role.Role @Failure 500 {object} errs.ErrResponse "Internal server error" @Failure 400 {object} errs.ErrResponse "Bad request" @Router /roles [post]

func (RoleHandlers) Delete

func (roleHandler RoleHandlers) Delete(ctx *gin.Context)

@Security bearerAuth @Summary delete a role endpoint @Description provide role id to delete the role @Accept application/json @Produce application/json @Param id path int true "Role ID" @Success 200 {object} response.Response @Failure 401 @Failure 500 {object} errs.ErrResponse "Internal server error" @Failure 400 {object} errs.ErrResponse "Bad request" @Router /roles/{id} [delete]

func (RoleHandlers) Read

func (roleHandler RoleHandlers) Read(ctx *gin.Context)

@Security bearerAuth @Summary read roles endpoint @Description returns all roles @Accept application/json @Produce application/json @Success 200 {array} role.Role @Failure 401 @Failure 500 {object} errs.ErrResponse "Internal server error" @Router /roles [get]

type Signup

type Signup struct {
	Email    string `json:"email" form:"email" binding:"required,email"`
	Password string `json:"password" form:"password" binding:"required"`
	Role     string `json:"role" form:"role" binding:"required"`
}

type UserHandlers

type UserHandlers struct {
	Service service.UserService
}

func (UserHandlers) Login

func (receiver UserHandlers) Login(ctx *gin.Context)

@Summary Login endpoint @Description Provide email and password to login, response is JWT @Consume application/x-www-form-urlencoded @Produce application/json @Param email formData string true "Email" @Param password formData string true "Password" @Success 200 {object} handlers.JWT @Failure 400 {object} errs.ErrResponse "Bad Request" @Failure 404 {object} errs.ErrResponse "User not found" @Failure 401 {object} errs.ErrResponse "Unauthorizes" @Failure 500 {object} errs.ErrResponse "Internal server error" @Router /login [post]

func (UserHandlers) Signup

func (receiver UserHandlers) Signup(ctx *gin.Context)

@Summary Signup endpoint @Description Provide email and password to login, response is JWT @Consume application/x-www-form-urlencoded @Produce application/json @Param email formData string true "Email" @Param password formData string true "Password" @Param role formData string true "Role" @Success 200 {object} user.User @Failure 400 {object} errs.ErrResponse "Bad Request" @Failure 500 {object} errs.ErrResponse "Internal server error" @Router /signup [post]

func (UserHandlers) VerifyEmail

func (receiver UserHandlers) VerifyEmail(ctx *gin.Context)

@Summary verify user email @Description provide user id and otp sent to his email, it consists of 6 characters @Consume application/x-www-form-urlencoded @Produce application/json @Param id path int true "User ID" @Param otp formData string true "OTP" @Success 200 {object} response.Response @Failure 401 {pbject} errs.ErrResponse @Failure 500 {object} errs.ErrResponse "Internal server error" @Failure 400 {object} errs.ErrResponse "Bad request" @Router /confirmEmail/{id} [post]

Jump to

Keyboard shortcuts

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