domain

package
v0.0.0-...-a70ed68 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ConsumptionTable = "consumptions"
)

table name

View Source
const (
	MeterTable = "meters"
)
View Source
const (
	UserTable = "users"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Consumption

type Consumption struct {
	ID                 uuid.UUID `json:"id"`
	MeterID            int       `json:"meter_id"`
	Active             float64   `json:"active"`
	ReactiveInductive  float64   `json:"reactive_inductive"`
	ReactiveCapacitive float64   `json:"reactive_capacitive"`
	Exported           float64   `json:"exported"`
	Period             string    `json:"period"`
	Timestamp          time.Time `json:"timestamp"`
}

type ConsumptionRepository

type ConsumptionRepository interface {
	Save(ctx context.Context, consumption *Consumption) error
	FindByID(c context.Context, id uuid.UUID) (*Consumption, error)
	FindByPeriod(c context.Context, period_type, start, end string, meterIDs []int, pagination *Pagination) (*Response, error)
}

type ConsumptionUsecase

type ConsumptionUsecase interface {
	GetConsumptionByID(id uuid.UUID) (*Consumption, error)
	GetConsumptionsByPeriod(period_type, start, end string, meterIDs []int, pagination *Pagination) (*Response, error)
}

type ErrorResponse

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

type JwtCustomClaims

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

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

type JwtCustomRefreshClaims

type JwtCustomRefreshClaims struct {
	ID uuid.UUID `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 Meter

type Meter struct {
	ID      uuid.UUID
	Address string
}

type MeterRepository

type MeterRepository interface {
	FindByID(ctx context.Context, id uuid.UUID) (*Meter, error)
	FindMany(ctx context.Context, pagination *Pagination) ([]*Meter, error)
}

type MeterUsecase

type MeterUsecase interface {
	GetMeterById(id uuid.UUID) (*Meter, error)
	GetManyMeters(pagination *Pagination) ([]*Meter, 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 {
	GetUserByEmail(c context.Context, id 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) (string, error)
}

type Response

type Response struct {
	Period    []string                 `json:"period"`
	DataGraph []map[string]interface{} `json:"data_graph"`
}

type SignupRequest

type SignupRequest struct {
	Email    string `json:"email,omitempty" jsonschema:"description=Email,format=email,title=Email,required"`
	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       uuid.UUID `json:"id"`
	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 uuid.UUID) (*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 uuid.UUID) (*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 uuid.UUID) error
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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