domain

package
v0.0.0-...-ade451b Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Drug

type Drug struct {
	ID          int       `json:"id"`
	Name        string    `json:"name"`
	Approved    bool      `json:"approved"`
	MinDose     int       `json:"min_dose"`
	MaxDose     int       `json:"max_dose"`
	AvailableAt time.Time `json:"available_at"`
}

type DrugRepository

type DrugRepository interface {
	Create(ctx context.Context, drug *Drug) error
	Update(ctx context.Context, id int, drug *Drug) error
	FindByID(ctx context.Context, id int) (*Drug, error)
	FindAll(ctx context.Context, pagination *Pagination) ([]*Drug, error)
	Delete(ctx context.Context, id int) error
}

type DrugUsecase

type DrugUsecase interface {
	CreateDrug(ctx context.Context, drug *Drug) error
	UpdateDrug(ctx context.Context, id int, drug *Drug) error
	GetDrugById(ctx context.Context, id int) (*Drug, error)
	GetAllDrugs(ctx context.Context, pagination *Pagination) ([]*Drug, error)
	DeleteDrug(ctx context.Context, id int) error
}

type ErrorResponse

type ErrorResponse struct {
	Message string `json:"message"`
}

type JwtCustomClaims

type JwtCustomClaims struct {
	Email string `json:"email"`
	ID    int    `json:"id"`
	jwt.StandardClaims
}

JwtCustomClaims representa los claims personalizados que se incluyen en el JWT de la plataforma .

type JwtCustomRefreshClaims

type JwtCustomRefreshClaims struct {
	ID int `json:"id"`
	jwt.StandardClaims
}

JwtCustomRefreshClaims representa los claims personalizados que se incluyen en el JWT de actualización en la plataforma .

type LoginRequest

type LoginRequest struct {
	Email    string `json:"email,omitempty" jsonschema:"required,description=Email of the user,title=Email"`
	Password string `json:"password,omitempty" jsonschema:"required,description=Password of the user,title=Password"`
}

type LoginResponse

type LoginResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

type LoginUsecase

type LoginUsecase interface {
	GetUserByEmail(c context.Context, email string) (*User, error)
	CreateAccessToken(user *User, secret string, expiry int) (accessToken string, err error)
	CreateRefreshToken(user *User, secret string, expiry int) (refreshToken string, err error)
}

type Pagination

type Pagination struct {
	Limit  *int `json:"limit,omitempty"`
	Offset *int `json:"offset,omitempty"`
}

type RefreshTokenRequest

type RefreshTokenRequest struct {
	RefreshToken string `form:"refreshToken" binding:"required"`
}

type RefreshTokenResponse

type RefreshTokenResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

type RefreshTokenUsecase

type RefreshTokenUsecase interface {
	GetUserByID(c context.Context, id int) (*User, error)
	GetUserByEmail(c context.Context, email string) (*User, error)
	CreateAccessToken(user *User, secret string, expiry int) (accessToken string, err error)
	CreateRefreshToken(user *User, secret string, expiry int) (refreshToken string, err error)
	ExtractIDFromToken(requestToken string, secret string) (int, error)
}

type SignupRequest

type SignupRequest struct {
	Email    string `json:"email,omitempty" jsonschema:"description=Email,format=email,title=Email,required"`
	Name     string `json:"name,omitempty" jsonschema:"description=Name,title=Name"`
	Password string `json:"password,omitempty" jsonschema:"description=Password,title=Password,required"`
}

type SignupResponse

type SignupResponse struct {
	AccessToken  string `json:"accessToken"`
	RefreshToken string `json:"refreshToken"`
}

type SignupUsecase

type SignupUsecase interface {
	Create(c context.Context, user *User) (*User, error)
	GetUserByEmail(c context.Context, email string) (*User, error)
	CreateAccessToken(user *User, secret string, expiry int) (accessToken string, err error)
	CreateRefreshToken(user *User, secret string, expiry int) (refreshToken string, err error)
}

type SuccessResponse

type SuccessResponse struct {
	Message string `json:"message"`
}

type User

type User struct {
	ID       int     `json:"id"`
	Name     *string `json:"name"`
	Email    string  `json:"email"`
	Password string  `json:"password,omitempty"`
}

func (*User) ComparePassword

func (u *User) ComparePassword(password string) error

ComparePassword compara la contraseña proporcionada con la contraseña almacenada del usuario.

func (*User) SetPassword

func (u *User) SetPassword(password string) error

SetPassword encripta la contraseña y la asigna al usuario.

type UserRepository

type UserRepository interface {
	Create(ctx context.Context, user *User) (*User, error)
	FindByID(ctx context.Context, id int) (*User, error)
	FindByEmail(ctx context.Context, email string) (*User, error)
	Update(ctx context.Context, user *User) (*User, error)
}

UserRepository define los métodos necesarios para interactuar con la base de datos de registros de usuarios.

type UserUseCase

type UserUseCase interface {
	GetByID(ctx context.Context, id int) (*User, error)
	GetByEmail(ctx context.Context, email string) (*User, error)
	Create(ctx context.Context, user *User) error
	Update(ctx context.Context, user *User) error
	Delete(ctx context.Context, id int) error
}

UserUseCase define los métodos necesarios para interactuar con la lógica de negocio de registros de usuarios.

type Vaccination

type Vaccination struct {
	ID     int       `json:"id"`
	Name   string    `json:"name"`
	DrugID int       `json:"drug_id"`
	Dose   int       `json:"dose"`
	Date   time.Time `json:"date"`
}

type VaccinationRepository

type VaccinationRepository interface {
	Create(ctx context.Context, vac *Vaccination) error
	Update(ctx context.Context, id int, vac *Vaccination) error
	FindByID(ctx context.Context, id int) (*Vaccination, error)
	FindAll(ctx context.Context, pagination *Pagination) ([]*Vaccination, error)
	Delete(ctx context.Context, id int) error
}

type VaccinationUsecase

type VaccinationUsecase interface {
	CreateVaccination(ctx context.Context, vac *Vaccination) error
	UpdateVaccination(ctx context.Context, id int, vac *Vaccination) error
	GetVaccinationById(ctx context.Context, id int) (*Vaccination, error)
	GetAllVaccinations(ctx context.Context, pagination *Pagination) ([]*Vaccination, error)
	DeleteVaccination(ctx context.Context, id int) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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