user

package
v0.0.0-...-5dc8f6f Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

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

func NewApi

func NewApi(service *Service, l *slog.Logger) *API

func (*API) Create

func (a *API) Create(c *gin.Context)

SaveUser godoc @Summary Save User @Description Save a user by giver form @Tags users @Accept json @Produce json @Param user body CreateDTO true "Add User" @Success 201 {object} DTO @Failure 500 @Router /users [post]

func (*API) Find

func (a *API) Find(c *gin.Context)

FilterUsers godoc @Summary Filter Users @Description Filter Users by query paramenters @Tags users @Accept json @Produce json @Param name query string false "User name" @Param email query string false "User email" @Param start query string false "User createdAt start date" @Param end query string false "User createdAt end date" @Param populate query string false "User populate properties" @Param limit query int false "User pagination limit" @Param offset query int false "User pagination limit" @Success 200 {object} []DTO @Failure 400 @Failure 500 @Router /users [get]

func (*API) FindById

func (a *API) FindById(c *gin.Context)

FindOneUser godoc @Summary Find one an User @Description Find one User by ID @Tags users @Accept json @Produce json @Param id path string true "User ID" @Success 200 {object} DTO @Failure 400 @Failure 404 @Failure 500 @Router /users/{id} [get]

func (*API) UpdateById

func (a *API) UpdateById(c *gin.Context)

UpdateOneUser godoc @Summary Update one an User @Description Update one User by ID @Tags users @Accept json @Produce json @Param id path string true "User ID" @Param user body UpdateDTO true "Update User" @Success 200 {object} DTO @Failure 400 @Failure 404 @Failure 500 @Router /users/{id} [post]

type CreateDTO

type CreateDTO struct {
	Name  string `json:"name"`
	Email string `json:"email"`
}

type DTO

type DTO struct {
	ID        string    `json:"id"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
	Name      string    `json:"name"`
	Email     string    `json:"email"`
}

func (*DTO) ToModel

func (m *DTO) ToModel() Model

type FindOptions

type FindOptions struct {
	Name  string
	Email string
	Start string
	End   string
}

type Model

type Model struct {
	gorm.Model
	ID        uuid.UUID `gorm:"type:uuid;default:gen_random_uuid()"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
	Name      string
	Email     string `gorm:"uniqueIndex"`
	Password  string
	Expenses  []shared.ExpenseRefModel `gorm:"foreignKey:UserID;references:ID"`
}

func (Model) TableName

func (Model) TableName() string

func (Model) ToDTO

func (m Model) ToDTO() DTO

type Models

type Models []*Model

func (*Models) ToDTO

func (m *Models) ToDTO() []DTO

type Repository

type Repository struct {
	shared.BaseRepository[Model]
}

type Router

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

func NewRouter

func NewRouter(db *gorm.DB, rg *gin.RouterGroup, l *slog.Logger) *Router

func (*Router) Route

func (r *Router) Route()

type Service

type Service struct {
	shared.BaseService[Model, DTO, CreateDTO, UpdateDTO]
}

type Tabler

type Tabler interface {
	TableName() string
}

type UpdateDTO

type UpdateDTO struct {
	CreateDTO
}

Jump to

Keyboard shortcuts

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