Added uuid middleware

This commit is contained in:
Nedim
2023-11-21 18:28:30 +01:00
parent a7ab058d01
commit d54b643378
11 changed files with 133 additions and 27 deletions

14
main.go
View File

@@ -13,6 +13,7 @@ import (
"gitlab.com/pactual1/backend/shared"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"github.com/jinzhu/gorm"
"github.com/qor/admin"
)
@@ -80,6 +81,19 @@ func main() {
http.ListenAndServe(":"+port, mux)
}()
// Temp fix to add UUID to existing contracts
var contracts []models.Contract
result := shared.GetDb().Where("uuid IS NULL").Find(&contracts)
if result.Error != nil {
log.Printf("Error fetching contracts: %v", result.Error)
return
}
for _, contract := range contracts {
contract.UUID = uuid.New().String()
shared.GetDb().Save(&contract)
}
// Initialize channels
// messagingChannel := make(chan string)
erpChannel := make(chan string)