Upstream sync

This commit is contained in:
Senad Uka
2023-09-18 12:27:40 +02:00
parent 9750aa2c37
commit 1f30f85787
30 changed files with 309 additions and 150 deletions

20
main.go
View File

@@ -8,7 +8,7 @@ import (
"gitlab.com/pactual1/backend/config"
"gitlab.com/pactual1/backend/models"
"gitlab.com/pactual1/backend/routes"
"gitlab.com/pactual1/backend/services/contact"
"gitlab.com/pactual1/backend/services/contract"
"gitlab.com/pactual1/backend/services/erp"
"gitlab.com/pactual1/backend/services/messaging"
"gitlab.com/pactual1/backend/shared"
@@ -22,7 +22,6 @@ var DB *gorm.DB
func main() {
// LOAD APPLICATION CONFIGURATION
err := config.Load()
if err != nil {
@@ -44,7 +43,7 @@ func main() {
company.Meta(&admin.Meta{Name: "Users", Config: &admin.SelectManyConfig{SelectMode: "bottom_sheet"}})
company.Meta(&admin.Meta{Name: "Devices", Config: &admin.SelectManyConfig{SelectMode: "bottom_sheet"}})
// company.Meta(&admin.Meta{Name: "DeviceInfos", Config: &admin.SelectManyConfig{SelectMode: "bottom_sheet"}})
// Add User and Device resources
Admin.AddResource(&models.User{})
Admin.AddResource(&models.Device{})
@@ -55,31 +54,34 @@ func main() {
// Start the admin server in a separate goroutine
go func() {
port := config.AppConfig.Service.Port
port := config.AppConfig.Service.Port
fmt.Println("Admin server listening on :" + port)
http.ListenAndServe(":" + port, mux)
http.ListenAndServe(":"+port, mux)
}()
// Initialize channels
messagingChannel := make(chan string)
erpChannel := make(chan string)
contactChannel := make(chan string)
contractChannel := make(chan string)
// Start services and pass the respective channels
go messaging.MessagingService(messagingChannel)
go erp.ERPService(erpChannel)
go contact.ContactService(contactChannel)
encryptionClient := shared.NewEncryptionClient(config.AppConfig.Service.BlockchainSecret)
contractService := contract.NewService(contractChannel, shared.GetDb(), encryptionClient)
go contractService.ContractService()
// Sending messages via channels
messagingChannel <- "Send an email"
erpChannel <- "Update ERP record"
contactChannel <- "Update contact info"
contractChannel <- "Update contract info"
// Initialize Gin
r := gin.Default()
routes.InitRouter(r)
// Start the Gin server on another port
port := config.AppConfig.AdminService.Port
port := config.AppConfig.AdminService.Port
fmt.Println("Application server listening on :" + port)
r.Run(":" + port)