Added temperature exceded event

This commit is contained in:
Nedim
2023-10-16 19:43:35 +02:00
parent 44efa194fc
commit 2e60460131
7 changed files with 109 additions and 70 deletions

View File

@@ -11,20 +11,20 @@ import (
)
func GetNotifications(c *gin.Context) {
// Get the User ID and Time from query parameters
userIDStr := c.DefaultQuery("user_id", "")
// Get the Company ID and Time from query parameters
companyIDStr := c.DefaultQuery("company_id", "")
timeStr := c.DefaultQuery("time", "")
if userIDStr == "" || timeStr == "" {
log.Printf("GetNotifications Error: User ID and Time are required")
c.JSON(http.StatusBadRequest, gin.H{"error": "User ID and Time are required"})
if companyIDStr == "" || timeStr == "" {
log.Printf("GetNotifications Error: Company ID and Time are required")
c.JSON(http.StatusBadRequest, gin.H{"error": "Company ID and Time are required"})
return
}
// Convert string to int for UserID
userID, err := strconv.Atoi(userIDStr)
userID, err := strconv.Atoi(companyIDStr)
if err != nil {
log.Printf("GetNotifications Error: Invalid User ID: %v", err)
log.Printf("GetNotifications Error: Invalid Company ID: %v", err)
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid User ID"})
return
}
@@ -37,8 +37,8 @@ func GetNotifications(c *gin.Context) {
}
afterTime := time.Unix(timestamp, 0)
log.Printf("This is the User ID: %v and Time: %v", userID, afterTime)
notifications, st, err := notification.GetNotificationsForUserID(userID, afterTime)
log.Printf("This is the Company ID: %v and Time: %v", userID, afterTime)
notifications, st, err := notification.GetNotificationsForCompanyID(userID, afterTime)
if err != nil {
c.JSON(st, gin.H{"error": err.Error()})