http.go 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. package server
  2. import (
  3. "city_chips/internal/handler"
  4. "city_chips/internal/middleware"
  5. "city_chips/pkg/log"
  6. "github.com/gin-gonic/gin"
  7. )
  8. func NewServerHTTP(
  9. logger *log.Logger,
  10. accessHandler *handler.AccessControlHandler,
  11. hikvision *handler.HikvisionHandler,
  12. conference *handler.ConferenceHandler,
  13. home *handler.HomeHandler,
  14. elevator *handler.ElevatorHandler,
  15. broadcast *handler.BroadcastHandler,
  16. property *handler.PropertyHandler,
  17. information *handler.InformationHandler,
  18. illuminating *handler.IlluminatingHandler,
  19. energy *handler.EnergyHandler,
  20. intell *handler.IntelligentBuildingControlHandler,
  21. ) *gin.Engine {
  22. gin.SetMode(gin.ReleaseMode)
  23. r := gin.Default()
  24. r.Use(
  25. middleware.CORSMiddleware(),
  26. )
  27. // 使用 HTTP/2 必须启用 HTTPS
  28. //r.RunTLS(":443", "cert.pem", "key.pem")
  29. r.LoadHTMLGlob("templates/h5player.html")
  30. r.Static("/static", "./templates/static")
  31. //出入口控制系统
  32. Access := r.Group("/Access")
  33. {
  34. Access.GET("/count", accessHandler.GetAccessControl)
  35. Access.GET("/getParkingLotInfo", accessHandler.GetParkingLotInfo)
  36. Access.GET("/getDriveway", accessHandler.GetDriveway)
  37. }
  38. //海康威视
  39. Hikvision := r.Group("/Hikvision")
  40. {
  41. Hikvision.GET("/getMonitoring", hikvision.GetHikvisionMonitoring)
  42. Hikvision.GET("/controlling", hikvision.Gimbalcontrol)
  43. Hikvision.GET("/visitorInfo", hikvision.VisitorInfoCount)
  44. Hikvision.GET("/monitor", hikvision.GetMonitor)
  45. Hikvision.GET("/invade", hikvision.GetInvade)
  46. Hikvision.GET("/endpoint", hikvision.GetElectronicInspections)
  47. Hikvision.GET("/visitor", hikvision.GetVisitor)
  48. Hikvision.GET("/passenger", hikvision.GetPassenger)
  49. Hikvision.GET("/access", hikvision.GetAccess)
  50. Hikvision.GET("/getDoorSearch", hikvision.GetDoorSearch)
  51. Hikvision.GET("/doControl", hikvision.DoControl)
  52. Hikvision.GET("/eventLogs", hikvision.RealTimeInspection)
  53. Hikvision.GET("/getPatrolPoint", hikvision.GetPatrolPoint)
  54. }
  55. //会议系统
  56. Conference := r.Group("/Conference")
  57. {
  58. Conference.GET("/roomOps", conference.RoomOps)
  59. Conference.GET("/dataAnalysis", conference.DataAnalysis)
  60. Conference.GET("/getRoomsByLocationId", conference.GetRoomsByLocationId)
  61. Conference.POST("/getRoomsByLocation", conference.GetRoomsByLocation)
  62. Conference.GET("/meetingRoomById", conference.MeetingRoomById)
  63. Conference.GET("/location", conference.Location)
  64. Conference.GET("/meeting", conference.GetRoomsMeeting)
  65. }
  66. //首页数据
  67. h := r.Group("/Home")
  68. {
  69. h.GET("/count", home.GetHome)
  70. }
  71. //电梯控制系统
  72. el := r.Group("/elevator")
  73. {
  74. el.GET("/count", elevator.GetElevator)
  75. el.GET("/elevatorData", elevator.GetElevatorData)
  76. }
  77. //广播控制系统
  78. bro := r.Group("/broadcast")
  79. {
  80. bro.GET("/count", broadcast.GetBroadcast)
  81. bro.GET("/getBroadcast", broadcast.GetBroadcastState)
  82. }
  83. //物业管理系统
  84. pro := r.Group("/property")
  85. {
  86. pro.GET("/count", property.GetProperty)
  87. }
  88. //信息发布管理平台
  89. info := r.Group("/information")
  90. {
  91. info.GET("/count", information.GetInformation)
  92. }
  93. //照明系统
  94. ill := r.Group("/illuminating")
  95. {
  96. ill.GET("/count", illuminating.GetIlluminating)
  97. ill.GET("/getLightingstatus", illuminating.GetLightingstatus)
  98. ill.POST("/updateLightingStatus", illuminating.UpdataLightingStatus)
  99. }
  100. //能源系统
  101. ener := r.Group("/energy")
  102. {
  103. ener.GET("/count", energy.GetEnergy)
  104. ener.GET("/GetWaterMmeter", energy.GetWaterMmeter)
  105. ener.GET("/getAmmeter", energy.GetAmmeter)
  106. ener.GET("/getTemperature", energy.GetTemperature)
  107. }
  108. //楼宇智控
  109. inte := r.Group("/intell")
  110. {
  111. inte.GET("/count", intell.GetIntelligentBuildingControl)
  112. inte.POST("/point", intell.GetPoint)
  113. inte.GET("/pointType", intell.GetPointType)
  114. }
  115. return r
  116. }