Protected routes
This commit is contained in:
@@ -85,7 +85,6 @@ func SaveDeviceInfo(c *gin.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
log.Printf("Successfully received and saved device info: %v", deviceInfo)
|
||||
c.JSON(http.StatusOK, gin.H{"message": "Successfully received and saved device info", "data": deviceInfo})
|
||||
}
|
||||
@@ -153,6 +152,7 @@ func GetDevicesByContract(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Contract ID is required"})
|
||||
return
|
||||
}
|
||||
companyID := c.GetInt("companyID")
|
||||
|
||||
// Convert string to uint
|
||||
contractID, err := strconv.ParseUint(contractIDStr, 10, 32)
|
||||
@@ -163,7 +163,7 @@ func GetDevicesByContract(c *gin.Context) {
|
||||
}
|
||||
|
||||
log.Printf("This is the ID: %v", contractID)
|
||||
devices, st, err := device.GetDevicesForContract(contractID)
|
||||
devices, st, err := device.GetDevicesForContract(contractID, companyID)
|
||||
|
||||
if err != nil {
|
||||
c.JSON(st, gin.H{"error": err.Error()})
|
||||
@@ -230,7 +230,7 @@ func GetCompanyRelatedDeviceInfoCountWithTempRange(c *gin.Context) {
|
||||
// Convert Unix timestamps to time.Time
|
||||
startTime := time.Unix(startUnix, 0)
|
||||
endTime := time.Unix(endUnix, 0)
|
||||
|
||||
|
||||
// Convert string to uint for CompanyID
|
||||
companyID, err := strconv.ParseUint(companyIDStr, 10, 32)
|
||||
if err != nil {
|
||||
@@ -238,7 +238,6 @@ func GetCompanyRelatedDeviceInfoCountWithTempRange(c *gin.Context) {
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid Company ID"})
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
// Get the counts
|
||||
inRangeCount, outOfRangeCount, monthlyCount, err := device.CountDeviceBreachedAndNormalDevicesByCompany(uint(companyID), startTime, endTime)
|
||||
@@ -253,7 +252,6 @@ func GetCompanyRelatedDeviceInfoCountWithTempRange(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, gin.H{"data": data})
|
||||
}
|
||||
|
||||
|
||||
func GetContractsMatchingDeviceLocation(c *gin.Context) {
|
||||
startTimeStr := c.DefaultQuery("start_time", "")
|
||||
endTimeStr := c.DefaultQuery("end_time", "")
|
||||
|
||||
Reference in New Issue
Block a user