service

package
v0.0.0-...-072db41 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

Types

type AquahubListService

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

func NewAquahubListService

func NewAquahubListService(repo IStoreAquahubs) *AquahubListService

Также в нашем сервисе и понадобится репозиторий Добавим его в качестве поля нашей структуры и будем передавать в конструкторе.

func (*AquahubListService) AppendDataOfSensor

func (s *AquahubListService) AppendDataOfSensor(list []domain.SensorDataSet) error

func (*AquahubListService) DeviceCreateOrUpdate

func (s *AquahubListService) DeviceCreateOrUpdate(aquahub_id int, device_local_id int, value string) error

func (*AquahubListService) GetAllAquahubOfUser

func (s *AquahubListService) GetAllAquahubOfUser(userId int) ([]domain.AquahubList, error)

Метод GetAll, который будет принимать id пользователя и возвращать слайс списка вместе с ошибкой.

func (*AquahubListService) GetDataSetOfSensor

func (s *AquahubListService) GetDataSetOfSensor(sensorId int) ([]domain.SensorDataSet, error)

func (*AquahubListService) GetDevicesOfAquahub

func (s *AquahubListService) GetDevicesOfAquahub(aquahubId int) ([]domain.AquahubList, error)

func (*AquahubListService) GetNameOfDeviceSensor

func (s *AquahubListService) GetNameOfDeviceSensor(sensor_id int) (domain.NameOfDeviceSensor, error)

func (*AquahubListService) GetSensorsOfDevice

func (s *AquahubListService) GetSensorsOfDevice(deviceId int) ([]domain.AquahubList, error)

func (*AquahubListService) SensorCreateOrUpdate

func (s *AquahubListService) SensorCreateOrUpdate(aquahub_id, device_local_id, sensor_local_id int, value string) error

type AuthService

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

func NewAuthService

func NewAuthService(cache cachememory.Cache, repo IStoreAuthorization) *AuthService

func (*AuthService) Authenticate

func (s *AuthService) Authenticate(email, password string) (*domain.User, error)

Authenticate finds a user by their email and verifies their password. On success it returns a User

func (*AuthService) CreateUser

func (s *AuthService) CreateUser(user domain.User) (int, error)

Принимает структуру User в качестве аргумента Возвращает ID созданного нового пользователя из БД

func (*AuthService) GetAquahubIdfromTokens

func (s *AuthService) GetAquahubIdfromTokens(h_token, u_token string) (int, error)

Запросить по токенам из БД id_шки аккаунта, аквахаба, устройств и сенсоров

func (*AuthService) GetUserHWfromTokens

func (s *AuthService) GetUserHWfromTokens(h_token, u_token string) ([]domain.SensorDataSet, error)

Запросить по токенам из БД id_шки аккаунта, аквахаба, устройств и сенсоров

func (*AuthService) GetUser_LoginPassword

func (s *AuthService) GetUser_LoginPassword(email, password string) (domain.User, error)

type ChecklistItemService

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

func NewChecklistItemService

func NewChecklistItemService(repo IStoreChecklistItem, listRepo IStoreChecklist) *ChecklistItemService

func (*ChecklistItemService) Create

func (s *ChecklistItemService) Create(userId, listId int, item domain.ChecklistItem) (int, error)

func (*ChecklistItemService) Delete

func (s *ChecklistItemService) Delete(userId, listId, itemId int) error

func (*ChecklistItemService) GetAll

func (s *ChecklistItemService) GetAll(userId, listId int) ([]domain.ChecklistItem, error)

func (*ChecklistItemService) GetById

func (s *ChecklistItemService) GetById(userId, listId, itemId int) (domain.ChecklistItem, error)

func (*ChecklistItemService) Update

func (s *ChecklistItemService) Update(userId, listId, itemId int, input domain.UpdateChecklistItem) error

type ChecklistService

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

func NewChecklistService

func NewChecklistService(repo IStoreChecklist) *ChecklistService

Также в нашем сервисе и понадобится репозиторий Добавим его в качестве поля нашей структуры и будем передавать в конструкторе.

func (*ChecklistService) Create

func (s *ChecklistService) Create(userId int, list domain.CreateChecklist) (int, error)

При создании списка мы будем передавать данные на следующий уровень - в репозиторий, поэтому в сервисе мы лишь будем возвращать аналогичный метод репозитория. Дополнительной логики мы реализовывать не будем.

func (*ChecklistService) Delete

func (s *ChecklistService) Delete(userId, listId int) error

func (*ChecklistService) GetAllChecklistOfUser

func (s *ChecklistService) GetAllChecklistOfUser(userId int) ([]domain.Checklist, error)

Метод GetAll, который будет принимать id пользователя и возвращать слайс списка вместе с ошибкой.

func (*ChecklistService) GetById

func (s *ChecklistService) GetById(userId, listId int) (*domain.Checklist, error)

func (*ChecklistService) Update

func (s *ChecklistService) Update(userId int, input domain.UpdateChecklist) error

type IStoreAquahubs

type IStoreAquahubs interface {
	GetAquahubs_OfUser(userId int) ([]domain.AquahubList, error)
	GetDevices_OfAquahub(aquahubId int) ([]domain.AquahubList, error)
	GetSensors_OfDevice(deviceId int) ([]domain.AquahubList, error)
	GetDataSet_OfSensor(sensorId int) ([]domain.SensorDataSet, error)

	AppendData_OfSensor(list []domain.SensorDataSet) error
	Device_CreateOrUpdate(aquahub_id, device_local_id int, value string) error
	Sensor_CreateOrUpdate(aquahub_id, device_local_id, sensor_local_id int, value string) error

	GetName_DeviceSensor(sensor_id int) (domain.NameOfDeviceSensor, error)
}

type IStoreAuthorization

type IStoreAuthorization interface {
	GetUserByEmail(email string) (*domain.User, error)

	// Принимает структуру User в качестве аргумента
	// Возвращает ID созданного нового пользователя из БД
	CreateUser(user domain.User) (int, error)

	GetUser_LoginPassword(username, password string) (domain.User, error)

	GetUserHW_fromTokens(h_token, u_token string) ([]domain.SensorDataSet, error) // user_id, aquahub_id, []{device_id, sensor_id}
	GetAquahubId_fromTokens(h_token, u_token string) (int, error)
}

type IStoreChecklist

type IStoreChecklist interface {
	Create(userId int, list domain.CreateChecklist) (int, error)
	// GetAll_Checklist() ([]domain.Checklist, error)
	GetAll_ChecklistOfUser(userId int) ([]domain.Checklist, error)
	GetById(userId, listId int) (*domain.Checklist, error)
	Delete(userId, listId int) error
	Update(userId int, input domain.UpdateChecklist) error
}

type IStoreChecklistItem

type IStoreChecklistItem interface {
	Create(listId int, item domain.ChecklistItem) (int, error)
	GetAll(userId, listId int) ([]domain.ChecklistItem, error)
	GetById(userId, listId, itemId int) (domain.ChecklistItem, error)
	Delete(userId, listId, itemId int) error
	Update(userId, listId, itemId int, input domain.UpdateChecklistItem) error
}

Jump to

Keyboard shortcuts

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