| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- package routes
- import (
- "ems-backend/controllers"
- "ems-backend/middleware"
- "github.com/gin-gonic/gin"
- )
- func SetupRoutes(r *gin.Engine) {
- // Public Routes
- r.POST("/api/v1/login", controllers.Login)
- api := r.Group("/api/v1")
- api.Use(middleware.AuthRequired())
- {
- // Menu & Perms
- api.GET("/getRouters", controllers.GetRouters)
- api.GET("/system/menu/tree", controllers.GetMenuTree)
- api.GET("/system/role/:roleId/menus", controllers.GetRoleMenuIds)
- // Integration Sources
- api.GET("/sources", controllers.GetSources)
- api.POST("/sources", controllers.CreateSource)
- api.PUT("/sources/:id", controllers.UpdateSource)
- api.DELETE("/sources/:id", controllers.DeleteSource)
- api.POST("/sources/test", controllers.TestSourceConnection) // 测试连接
- api.GET("/sources/:id/candidates", controllers.GetSourceCandidates) // 获取候选设备 (Legacy)
- api.GET("/sources/:id/devices", controllers.GetSourceDevices) // 获取HA设备列表
- api.GET("/sources/:id/devices/:deviceId/entities", controllers.GetSourceDeviceEntities) // 获取HA设备实体
- api.POST("/sources/:id/sync", controllers.SyncSource) // 立即同步
- // Devices
- api.GET("/devices", controllers.GetDevices)
- api.GET("/devices/history", controllers.GetDeviceHistory)
- api.POST("/devices", controllers.CreateDevice)
- api.PUT("/devices/:id", controllers.UpdateDevice)
- api.DELETE("/devices/:id", controllers.DeleteDevice)
- // Locations
- api.GET("/locations", controllers.GetLocations)
- api.POST("/locations", controllers.CreateLocation)
- api.PUT("/locations/:id", controllers.UpdateLocation)
- api.DELETE("/locations/:id", controllers.DeleteLocation)
- // Dashboard & Control
- api.GET("/dashboard/stats", controllers.GetDashboardStats)
- api.POST("/control/:id", controllers.ControlDevice)
- // Alarms
- api.GET("/alarms", controllers.GetAlarms)
- api.POST("/alarms", controllers.CreateAlarm)
- api.PUT("/alarms/:id/ack", controllers.AcknowledgeAlarm)
- // Energy Analysis
- api.GET("/analysis/energy", controllers.GetEnergyAnalysis)
- // Inspections
- api.GET("/inspections", controllers.GetInspections)
- api.POST("/inspections", controllers.CreateInspection)
- // System & Settings
- sys := api.Group("/system")
- {
- // Roles
- sys.GET("/roles", controllers.GetRoles)
- sys.POST("/roles", controllers.CreateRole)
- sys.PUT("/roles/:id", controllers.UpdateRole)
- sys.DELETE("/roles/:id", controllers.DeleteRole)
- // Users
- sys.GET("/users", controllers.GetUsers)
- sys.POST("/users", controllers.CreateUser)
- sys.PUT("/users/:id", controllers.UpdateUser)
- sys.DELETE("/users/:id", controllers.DeleteUser)
- // User Profile (Self)
- sys.GET("/user/profile", controllers.GetProfile)
- sys.PUT("/user/profile/updatePwd", controllers.UpdateProfilePwd)
- // Configs
- sys.GET("/configs", controllers.GetAllConfigs)
- sys.GET("/config/:key", controllers.GetConfig)
- sys.POST("/config", controllers.UpdateConfig)
- }
- }
- }
|