2022-08-13 23:33:50 +02:00
|
|
|
package services
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"basic-sensor-receiver/config"
|
|
|
|
|
"database/sql"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Services struct {
|
|
|
|
|
SensorConfig *SensorConfigService
|
|
|
|
|
SensorValues *SensorValuesService
|
|
|
|
|
Sensors *SensorsService
|
2022-08-21 19:33:30 +02:00
|
|
|
Sessions *SessionsService
|
|
|
|
|
Auth *AuthService
|
2022-08-13 23:33:50 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type Context struct {
|
|
|
|
|
DB *sql.DB
|
|
|
|
|
Config *config.Config
|
|
|
|
|
Services *Services
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func InitializeServices(ctx *Context) *Services {
|
|
|
|
|
services := Services{}
|
|
|
|
|
|
|
|
|
|
ctx.Services = &services
|
|
|
|
|
|
|
|
|
|
services.SensorConfig = &SensorConfigService{ctx: ctx}
|
|
|
|
|
services.SensorValues = &SensorValuesService{ctx: ctx}
|
|
|
|
|
services.Sensors = &SensorsService{ctx: ctx}
|
2022-08-21 19:33:30 +02:00
|
|
|
services.Sessions = &SessionsService{ctx: ctx}
|
|
|
|
|
services.Auth = &AuthService{ctx: ctx}
|
2022-08-13 23:33:50 +02:00
|
|
|
|
|
|
|
|
return &services
|
|
|
|
|
}
|