usecase

package
v0.0.0-...-41a9250 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AdminUseCase

type AdminUseCase struct {
	AdminRepository      repository.IAdminRepository
	ParkingLotRepository repository.IParkingLotRepository
}

func (*AdminUseCase) CompleteAdminProfile

func (uc *AdminUseCase) CompleteAdminProfile(adminID string, profileData domain.AdminProfileData) error

func (*AdminUseCase) GetAdminProfile

func (uc *AdminUseCase) GetAdminProfile(adminID string) (*domain.Admin, error)

func (*AdminUseCase) GetParkingLotsByAdmin

func (uc *AdminUseCase) GetParkingLotsByAdmin(adminUUID string) ([]domain.ParkingLot, error)

func (*AdminUseCase) RegisterAdmin

func (uc *AdminUseCase) RegisterAdmin(adminID string) error

type CreateEsp32DeviceRequest

type CreateEsp32DeviceRequest struct {
	DeviceIdentifier string `json:"device_identifier"`
}

type CreateParkingLotRequest

type CreateParkingLotRequest struct {
	Name      string  `json:"name"`
	Address   string  `json:"address"`
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
	AdminUUID string  `json:"admin_uuid"`
}

type CreateSensorRequest

type CreateSensorRequest struct {
	ParkingLotID     uint   `json:"parking_lot_id"`
	DeviceIdentifier string `json:"device_identifier"` // Dirección MAC
	SensorNumber     int    `json:"sensor_number"`
	Status           string `json:"status"`
}

type Esp32DeviceResponse

type Esp32DeviceResponse struct {
	ID                uint64          `json:"id"`
	DeviceIdentifier  string          `json:"device_identifier"`
	LastCommunication string          `json:"last_communication"`
	Sensors           []domain.Sensor `json:"sensors"`
}

type Esp32DeviceUseCase

type Esp32DeviceUseCase struct {
	Esp32DeviceRepository repository.IEsp32DeviceRepository
	SensorRepository      repository.ISensorRepository
}

func (*Esp32DeviceUseCase) CreateEsp32Device

func (uc *Esp32DeviceUseCase) CreateEsp32Device(req CreateEsp32DeviceRequest) error

func (*Esp32DeviceUseCase) DeleteEsp32Device

func (uc *Esp32DeviceUseCase) DeleteEsp32Device(id uint64) error

func (*Esp32DeviceUseCase) GetEsp32Device

func (uc *Esp32DeviceUseCase) GetEsp32Device(id uint64) (*Esp32DeviceResponse, error)

func (*Esp32DeviceUseCase) GetEsp32DeviceByIdentifier

func (uc *Esp32DeviceUseCase) GetEsp32DeviceByIdentifier(identifier string) (*domain.Esp32Device, error)

func (*Esp32DeviceUseCase) ListEsp32Devices

func (uc *Esp32DeviceUseCase) ListEsp32Devices() ([]domain.Esp32Device, error)

func (*Esp32DeviceUseCase) UpdateEsp32Device

func (uc *Esp32DeviceUseCase) UpdateEsp32Device(id uint64, req UpdateEsp32DeviceRequest) error

type IAdminUseCase

type IAdminUseCase interface {
	RegisterAdmin(adminID string) error
	CompleteAdminProfile(adminID string, profileData domain.AdminProfileData) error
	GetAdminProfile(adminID string) (*domain.Admin, error)
	GetParkingLotsByAdmin(adminUUID string) ([]domain.ParkingLot, error)
}

func NewAdminUseCase

func NewAdminUseCase(adminRepo repository.IAdminRepository) IAdminUseCase

type IEsp32DeviceUseCase

type IEsp32DeviceUseCase interface {
	CreateEsp32Device(req CreateEsp32DeviceRequest) error
	GetEsp32Device(id uint64) (*Esp32DeviceResponse, error)
	GetEsp32DeviceByIdentifier(identifier string) (*domain.Esp32Device, error)
	UpdateEsp32Device(id uint64, req UpdateEsp32DeviceRequest) error
	DeleteEsp32Device(id uint64) error
	ListEsp32Devices() ([]domain.Esp32Device, error)
}

func NewEsp32DeviceUseCase

func NewEsp32DeviceUseCase(esp32DeviceRepo repository.IEsp32DeviceRepository, sensorRepo repository.ISensorRepository) IEsp32DeviceUseCase

type IParkingLotUseCase

type IParkingLotUseCase interface {
	CreateParkingLot(req CreateParkingLotRequest) (*ParkingLotResponse, error)
	GetParkingLot(parkingLotID uint) (*ParkingLotResponse, error)
	GetParkingLotWithOwnership(parkingLotID uint, adminUUID string) (*ParkingLotResponse, error)
	UpdateParkingLot(parkingLotID uint, req UpdateParkingLotRequest, adminUUID string) error
	DeleteParkingLot(parkingLotID uint, adminUUID string) error
	ListParkingLots() ([]ParkingLotResponse, error)
}

func NewParkingLotUseCase

func NewParkingLotUseCase(parkingLotRepo repository.IParkingLotRepository, sensorRepository repository.ISensorRepository, adminRepository repository.IAdminRepository) IParkingLotUseCase

NewParkingLotUseCase creates a new instance of ParkingLotUseCase.

type ISensorUseCase

type ISensorUseCase interface {
	CreateSensor(req CreateSensorRequest) error
	GetSensor(sensorID uint) (*SensorResponse, error)
	UpdateSensor(sensorID uint, req UpdateSensorRequest) error
	DeleteSensor(sensorID uint) error
	ListSensorsByParkingLot(parkingLotID uint) ([]SensorResponse, error)
	GetSensorByDeviceAndNumber(deviceIdentifier string, sensorNumber int) (*SensorResponse, error)
}

func NewSensorUseCase

func NewSensorUseCase(sensorRepo repository.ISensorRepository, esp32DeviceRepo repository.IEsp32DeviceRepository) ISensorUseCase

type IUserUseCase

type IUserUseCase interface {
	Register(username, password, email string) (*domain.User, error)
	FindByID(id uint) (*domain.User, error)
	UpdateUser(id uint, username, email, password string) (*domain.User, error)
	DeleteUser(id uint) error
}

func NewUserUseCase

func NewUserUseCase(userRepo repository.IUserRepository) IUserUseCase

type ParkingLotResponse

type ParkingLotResponse struct {
	ID              uint    `json:"id"`
	Name            string  `json:"name"`
	Address         string  `json:"address"`
	Latitude        float64 `json:"latitude"`
	Longitude       float64 `json:"longitude"`
	AvailableSpaces uint    `json:"available_spaces"`
}

type ParkingLotUseCase

type ParkingLotUseCase struct {
	ParkingLotRepository repository.IParkingLotRepository
	SensorRepository     repository.ISensorRepository
	AdminRepository      repository.IAdminRepository
}

func (*ParkingLotUseCase) CreateParkingLot

func (uc *ParkingLotUseCase) CreateParkingLot(req CreateParkingLotRequest) (*ParkingLotResponse, error)

CreateParkingLot creates a new parking lot.

func (*ParkingLotUseCase) DeleteParkingLot

func (uc *ParkingLotUseCase) DeleteParkingLot(parkingLotID uint, adminUUID string) error

DeleteParkingLot deletes a parking lot with ownership validation.

func (*ParkingLotUseCase) GetParkingLot

func (uc *ParkingLotUseCase) GetParkingLot(parkingLotID uint) (*ParkingLotResponse, error)

GetParkingLot retrieves a parking lot by ID.

func (*ParkingLotUseCase) GetParkingLotWithOwnership

func (uc *ParkingLotUseCase) GetParkingLotWithOwnership(parkingLotID uint, adminUUID string) (*ParkingLotResponse, error)

GetParkingLotWithOwnership retrieves a parking lot if it belongs to the admin.

func (*ParkingLotUseCase) ListParkingLots

func (uc *ParkingLotUseCase) ListParkingLots() ([]ParkingLotResponse, error)

ListParkingLots retrieves all parking lots with their available spaces.

func (*ParkingLotUseCase) UpdateParkingLot

func (uc *ParkingLotUseCase) UpdateParkingLot(parkingLotID uint, req UpdateParkingLotRequest, adminUUID string) error

UpdateParkingLot updates a parking lot.

type SensorResponse

type SensorResponse struct {
	ID               uint   `json:"id"`
	ParkingLotID     uint   `json:"parking_lot_id"`
	DeviceIdentifier string `json:"device_identifier"`
	Status           string `json:"status"`
}

type SensorUseCase

type SensorUseCase struct {
	SensorRepository      repository.ISensorRepository
	Esp32DeviceRepository repository.IEsp32DeviceRepository
}

func (*SensorUseCase) CreateSensor

func (uc *SensorUseCase) CreateSensor(req CreateSensorRequest) error

func (*SensorUseCase) DeleteSensor

func (uc *SensorUseCase) DeleteSensor(sensorID uint) error

func (*SensorUseCase) GetSensor

func (uc *SensorUseCase) GetSensor(sensorID uint) (*SensorResponse, error)

func (*SensorUseCase) GetSensorByDeviceAndNumber

func (uc *SensorUseCase) GetSensorByDeviceAndNumber(deviceIdentifier string, sensorNumber int) (*SensorResponse, error)

func (*SensorUseCase) ListSensorsByParkingLot

func (uc *SensorUseCase) ListSensorsByParkingLot(parkingLotID uint) ([]SensorResponse, error)

func (*SensorUseCase) UpdateSensor

func (uc *SensorUseCase) UpdateSensor(sensorID uint, req UpdateSensorRequest) error

type UpdateEsp32DeviceRequest

type UpdateEsp32DeviceRequest struct {
	DeviceIdentifier string `json:"device_identifier"`
}

type UpdateParkingLotRequest

type UpdateParkingLotRequest struct {
	Name      string  `json:"name"`
	Address   string  `json:"address"`
	Latitude  float64 `json:"latitude"`
	Longitude float64 `json:"longitude"`
}

type UpdateSensorRequest

type UpdateSensorRequest struct {
	Status           string `json:"status"`
	DeviceIdentifier string `json:"device_identifier"`
	SensorNumber     int    `json:"sensor_number"`
}

type UserUseCase

type UserUseCase struct {
	UserRepository repository.IUserRepository
}

func (*UserUseCase) DeleteUser

func (u *UserUseCase) DeleteUser(id uint) error

func (*UserUseCase) FindByID

func (u *UserUseCase) FindByID(id uint) (*domain.User, error)

func (*UserUseCase) Register

func (u *UserUseCase) Register(username, password, email string) (*domain.User, error)

func (*UserUseCase) UpdateUser

func (u *UserUseCase) UpdateUser(id uint, username, email, password string) (*domain.User, error)

Jump to

Keyboard shortcuts

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