mirror of
https://github.com/ForFarmTeam/ForFarm.git
synced 2025-12-19 14:04:08 +01:00
Merge branch 'feature-inventory' of https://github.com/ForFarmTeam/ForFarm into feature-inventory
This commit is contained in:
commit
ac994f3d39
@ -20,6 +20,7 @@ import (
|
|||||||
"github.com/forfarm/backend/internal/domain"
|
"github.com/forfarm/backend/internal/domain"
|
||||||
m "github.com/forfarm/backend/internal/middlewares"
|
m "github.com/forfarm/backend/internal/middlewares"
|
||||||
"github.com/forfarm/backend/internal/repository"
|
"github.com/forfarm/backend/internal/repository"
|
||||||
|
"github.com/forfarm/backend/internal/services"
|
||||||
"github.com/forfarm/backend/internal/services/weather"
|
"github.com/forfarm/backend/internal/services/weather"
|
||||||
"github.com/forfarm/backend/internal/utilities"
|
"github.com/forfarm/backend/internal/utilities"
|
||||||
)
|
)
|
||||||
@ -29,22 +30,22 @@ type api struct {
|
|||||||
httpClient *http.Client
|
httpClient *http.Client
|
||||||
eventPublisher domain.EventPublisher
|
eventPublisher domain.EventPublisher
|
||||||
|
|
||||||
userRepo domain.UserRepository
|
userRepo domain.UserRepository
|
||||||
cropRepo domain.CroplandRepository
|
cropRepo domain.CroplandRepository
|
||||||
farmRepo domain.FarmRepository
|
farmRepo domain.FarmRepository
|
||||||
plantRepo domain.PlantRepository
|
plantRepo domain.PlantRepository
|
||||||
inventoryRepo domain.InventoryRepository
|
inventoryRepo domain.InventoryRepository
|
||||||
harvestRepo domain.HarvestRepository
|
harvestRepo domain.HarvestRepository
|
||||||
analyticsRepo domain.AnalyticsRepository
|
analyticsRepo domain.AnalyticsRepository
|
||||||
knowledgeHubRepo domain.KnowledgeHubRepository
|
knowledgeHubRepo domain.KnowledgeHubRepository
|
||||||
|
|
||||||
weatherFetcher domain.WeatherFetcher
|
weatherFetcher domain.WeatherFetcher
|
||||||
|
|
||||||
|
chatService *services.ChatService
|
||||||
}
|
}
|
||||||
|
|
||||||
var weatherFetcherInstance domain.WeatherFetcher
|
func (a *api) GetWeatherFetcher() domain.WeatherFetcher {
|
||||||
|
return a.weatherFetcher
|
||||||
func GetWeatherFetcher() domain.WeatherFetcher {
|
|
||||||
return weatherFetcherInstance
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAPI(
|
func NewAPI(
|
||||||
@ -76,22 +77,29 @@ func NewAPI(
|
|||||||
cleanupInterval = 5 * time.Minute
|
cleanupInterval = 5 * time.Minute
|
||||||
}
|
}
|
||||||
cachedWeatherFetcher := weather.NewCachedWeatherFetcher(owmFetcher, cacheTTL, cleanupInterval, logger)
|
cachedWeatherFetcher := weather.NewCachedWeatherFetcher(owmFetcher, cacheTTL, cleanupInterval, logger)
|
||||||
weatherFetcherInstance = cachedWeatherFetcher
|
|
||||||
|
chatService, chatErr := services.NewChatService(logger, analyticsRepo, farmRepo, croplandRepo, inventoryRepo, plantRepository)
|
||||||
|
if chatErr != nil {
|
||||||
|
logger.Error("Failed to initialize ChatService", "error", chatErr)
|
||||||
|
chatService = nil
|
||||||
|
}
|
||||||
|
|
||||||
return &api{
|
return &api{
|
||||||
logger: logger,
|
logger: logger,
|
||||||
httpClient: client,
|
httpClient: client,
|
||||||
eventPublisher: eventPublisher,
|
eventPublisher: eventPublisher,
|
||||||
|
|
||||||
userRepo: userRepository,
|
userRepo: userRepository,
|
||||||
cropRepo: croplandRepo,
|
cropRepo: croplandRepo,
|
||||||
farmRepo: farmRepo,
|
farmRepo: farmRepo,
|
||||||
plantRepo: plantRepository,
|
plantRepo: plantRepository,
|
||||||
inventoryRepo: inventoryRepo,
|
inventoryRepo: inventoryRepo,
|
||||||
harvestRepo: harvestRepository,
|
harvestRepo: harvestRepository,
|
||||||
analyticsRepo: analyticsRepo,
|
analyticsRepo: analyticsRepo,
|
||||||
knowledgeHubRepo: knowledgeHubRepository,
|
knowledgeHubRepo: knowledgeHubRepository,
|
||||||
weatherFetcher: cachedWeatherFetcher,
|
weatherFetcher: cachedWeatherFetcher,
|
||||||
|
|
||||||
|
chatService: chatService,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -134,6 +142,7 @@ func (a *api) Routes() *chi.Mux {
|
|||||||
a.registerPlantRoutes(r, api)
|
a.registerPlantRoutes(r, api)
|
||||||
a.registerKnowledgeHubRoutes(r, api)
|
a.registerKnowledgeHubRoutes(r, api)
|
||||||
a.registerOauthRoutes(r, api)
|
a.registerOauthRoutes(r, api)
|
||||||
|
a.registerChatRoutes(r, api)
|
||||||
a.registerInventoryRoutes(r, api)
|
a.registerInventoryRoutes(r, api)
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -142,9 +151,8 @@ func (a *api) Routes() *chi.Mux {
|
|||||||
a.registerHelloRoutes(r, api)
|
a.registerHelloRoutes(r, api)
|
||||||
a.registerFarmRoutes(r, api)
|
a.registerFarmRoutes(r, api)
|
||||||
a.registerUserRoutes(r, api)
|
a.registerUserRoutes(r, api)
|
||||||
a.registerInventoryRoutes(r, api)
|
|
||||||
a.registerAnalyticsRoutes(r, api)
|
a.registerAnalyticsRoutes(r, api)
|
||||||
})
|
})
|
||||||
|
|
||||||
return router
|
return router
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue
Block a user