123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- // Copyright 2019 github.com. All rights reserved.
- // Use of this source code is governed by github.com.
- package route
- import (
- "net/http"
- "github.com/gin-gonic/gin"
- "smart-site-management-gateway/controller/v1"
- _ "smart-site-management-gateway/docs"
- "smart-site-management-gateway/route/middleware"
- )
- func SetupRoute(engine *gin.Engine) {
- // 404页面
- engine.NoRoute(func(c *gin.Context) {
- c.String(http.StatusNotFound, "Not Found")
- })
- // 服务健康检查
- engine.GET("/ping", func(c *gin.Context) {
- // TODO 心跳检查
- c.String(http.StatusOK, "pong")
- })
- //engine.Use(middleware.Session("smart-site-supplier"))
- // version 1
- apiv1 := engine.Group("/api/v1")
- {
- c := v1.NewController()
- apiv1.POST("/upload", c.Upload)
- apiv1.GET("/vcode", c.Vcode)
- apiv1.GET("/user/mail", c.MailUpdate)
- engine.POST("/api/v1/user/login_front", c.LoginFront)
- engine.GET("/api/v1/user/captcha_id", c.CaptchaId)
- engine.GET("/api/v1/user/captcha_png/:captcha_id", c.CaptchaPng)
- engine.GET("/api/v1/camera/ping", c.VedioPing)
- apiv1.PUT("/token_refresh", c.TokenRefresh)
- apiv1.Use(middleware.Jwt())
- user := apiv1.Group("/user")
- {
- user.PUT("/change_passwd", c.ChangePasswd)
- user.GET("/permission", c.UserPermission)
- user.PUT("/verify_mail", c.MailPrepare)
- user.PUT("/phone", c.PhoneUpdate)
- user.GET("/info", c.UserInfo)
- }
- project := apiv1.Group("/project")
- {
- project.GET("/fields", c.ProjectInfoForChange)
- project.PUT("", c.ProjectChange)
- project.PUT("/device_approve", c.DeviceApprove)
- project.GET("/change_job_list", c.ProjectChangeInfoList)
- project.DELETE("/progress/:id", c.ProjectProgressDel)
- project.GET("/progress_list", c.ProjectProgress)
- project.GET("/info", c.ProjectInfo)
- project.GET("/device_statistics", c.ProjectDeviceStatistics)
- project.POST("/progress", c.ProjectProgressAdd)
- project.PUT("/progress", c.ProjectProgressSet)
- project.PUT("/pic", c.ProjectSetPic)
- project.PUT("/name_location", c.ProjectUpdate)
- }
- device := apiv1.Group("/device")
- {
- device.GET("/list", c.DeviceList)
- //device.GET("/camera", c.DeviceCamera)
- device.GET("/apply_list", c.DeviceApplyList)
- device.GET("/vedio_list", c.DeviceVedioList)
- device.GET("/vedio_channel_list", c.DeviceVedioChannelList)
- device.GET("/vedio_channel_unbind", c.DeviceVedioChannelUnbindList)
- device.GET("/vedio_channel", c.DeviceVideoChannel)
- device.PUT("/vedio_channel", c.ChannelUpdate)
- }
- vehicle := apiv1.Group("/vehicle")
- {
- vehicle.GET("/list", c.VehicleList)
- }
- staff := apiv1.Group("/staff")
- {
- staff.GET("/last", c.LatestStaffData)
- staff.GET("/type_statistics", c.StaffTypeStatistics)
- staff.GET("/work_type_statistics", c.StaffWorkTypeStatistics)
- staff.GET("/company_statistics", c.LaborCompanyStatistics)
- staff.GET("/list", c.StaffList)
- staff.GET("/attendance", c.StaffAttendance)
- }
- dust := apiv1.Group("/dust")
- {
- dust.GET("/last", c.LatestDustMonitorData)
- dust.GET("/history", c.DustMonitorHistory)
- dust.GET("/list", c.DustList)
- dust.GET("/aqi", c.DustAqi)
- }
- tower := apiv1.Group("/iot")
- {
- tower.GET("/tower_last", c.LatestTowerMonitorData)
- tower.GET("/tower_history", c.TowerMonitorHistory)
- tower.GET("/list", c.IotList)
- tower.GET("/type_list", c.IotTypeList)
- tower.GET("/last", c.IotLast)
- }
- alarm := apiv1.Group("/alarm")
- {
- alarm.GET("/list", c.AlarmList)
- alarm.POST("/rule", c.AlarmRuleAdd)
- alarm.GET("/rule_list", c.AlarmRuleList)
- alarm.DELETE("/rule_delete/:id", c.AlarmRuleDelete)
- alarm.PUT("/rule_on_off", c.AlarmRuleOnOff)
- alarm.PUT("/rule", c.AlarmRuleUpdate)
- alarm.POST("/contact", c.AlarmContactAdd)
- alarm.PUT("/contact", c.AlarmContactUpdate)
- alarm.GET("/contact_list", c.AlarmContactList)
- alarm.DELETE("/contact_delete/:id", c.AlarmContactDelete)
- }
- camera := apiv1.Group("/camera")
- {
- camera.PUT("/bind_device", c.DeviceBindCamera)
- camera.PUT("/unbind_device", c.DeviceUnbindCamera)
- camera.GET("/real_play", c.RealPlay)
- camera.GET("/ptz", c.Ptz)
- }
- oplog := apiv1.Group("log")
- {
- oplog.GET("/list", c.LogList)
- }
- }
- }
|