update timer auto cut off mcb

This commit is contained in:
[Valentino Heman Budiarto]
2026-06-22 23:45:01 +07:00
parent e210d2a424
commit 122115b5e9
3 changed files with 174 additions and 9 deletions
+8 -1
View File
@@ -14,6 +14,9 @@ func main() {
// 1. Konek Database
config.ConnectDatabase()
// 🌟 TAMBAHAN UNTUK TIMER: Nyalakan mesin Cron Timer di background
controllers.StartPowerCronWorker()
// 2. AutoMigrate
config.DB.AutoMigrate(&models.User{}, &models.Room{}, &models.Booking{}, &models.ClassSchedule{})
@@ -65,7 +68,7 @@ func main() {
protected.DELETE("/schedules/:id", controllers.DeleteSchedule)
}
// 5. Jalur IoT ESP32
// 5. Jalur IoT ESP32 & Kontrol Daya
r.POST("/api/sensor/energy", controllers.UpdateRoomPower)
r.POST("/api/hardware/verify", controllers.VerifyHardwareCode)
r.POST("/api/hardware/control", controllers.ControlHardware)
@@ -73,6 +76,10 @@ func main() {
r.GET("/api/hardware/power-status", controllers.GetPowerStatus)
r.POST("/api/power/global", controllers.GlobalPowerControl)
// 🌟 RUTE BARU UNTUK TIMER AUTO-CUTOFF
r.GET("/api/power/timer", controllers.GetTimerConfig)
r.POST("/api/power/timer", controllers.SetTimerConfig)
r.Run(":8080")
}