123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126 |
- // 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-government-management-gateway/controller/v1"
- _ "smart-government-management-gateway/docs"
- "smart-government-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("/map", c.Map)
- apiv1.GET("/publicity", c.Publicity)
- apiv1.GET("/device_type_all", c.DeviceTypeAll)
- apiv1.GET("/user/mail", c.MailUpdate)
- apiv1.GET("/area_code_limit", c.AreaCodeLimit)
- engine.POST("/api/v1/user/login", c.Login)
- apiv1.GET("/vcode", c.GetVcode)
- engine.PUT("/api/v1/user/set_passwd", c.SetPasswd)
- engine.GET("/api/v1/user/captcha_id", c.CaptchaId)
- engine.GET("/api/v1/user/captcha_png/:captcha_id", c.CaptchaPng)
- apiv1.PUT("/token_refresh", c.TokenRefresh)
- apiv1.Use(middleware.Jwt())
- user := apiv1.Group("/user")
- {
- user.PUT("/change_passwd", c.ChangePasswd)
- user.GET("/tmp_token", c.TmpToken)
- user.PUT("/verify_mail", c.MailPrepare)
- user.PUT("/phone", c.PhoneUpdate)
- user.GET("/info", c.UserInfo)
- }
- task := apiv1.Group("/task")
- {
- task.GET("/list", c.TaskList)
- task.POST("", c.TaskAdd)
- task.PUT("", c.TaskApprove)
- task.GET("/info/:id", c.TaskInfo)
- }
- device := apiv1.Group("/device")
- {
- device.GET("/type_list", c.DeviceTypeList)
- device.GET("/dust_list", c.DeviceDustList)
- device.GET("/attendance_list", c.DeviceAttendanceList)
- device.PUT("/type_approve", c.DeviceTypeApprove)
- device.PUT("/del_approve", c.DeviceDelApprove)
- device.GET("/del_job_list", c.DeviceDelJobList)
- device.GET("/vedio_list", c.DeviceVedioList)
- device.GET("/vedio_channel_list", c.DeviceVedioChannelList)
- device.GET("/statistic", c.DeviceStatistic)
- device.GET("/type_statistic", c.DeviceTypeStatistic)
- device.GET("/tested_type_info/:id", c.DeviceTestedTypeInfo)
- }
- provider := apiv1.Group("/provider")
- {
- provider.GET("/list", c.ProviderList)
- provider.GET("/apply_list", c.ProviderApplyList)
- provider.PUT("/approve", c.ProviderApprove)
- }
- company := apiv1.Group("/company")
- {
- company.GET("/list", c.CompanyList)
- company.PUT("/approve", c.CompanyApprove)
- company.GET("/apply_list", c.CompanyApplyList)
- company.GET("/statistic", c.CompanyStatistic)
- }
- project := apiv1.Group("/project")
- {
- project.GET("/list", c.ProjectList)
- project.GET("/info/:id", c.ProjectInfo)
- project.GET("/change_job_list", c.ProjectChangeInfoList)
- //project.PUT("/approve", c.ProjectAddApprove)
- project.PUT("/change_approve", c.ProjectChangeApprove)
- project.GET("/statistic", c.ProjectStatistic)
- project.GET("/type_statistic", c.ProjectTypeStatistic)
- }
- staff := apiv1.Group("/staff")
- {
- staff.GET("/statistic", c.StaffStatistic)
- staff.GET("/type_statistic", c.StaffStatisticNew)
- }
- oplog := apiv1.Group("log")
- {
- oplog.GET("/list", c.LogList)
- }
- alarm := apiv1.Group("/alarm")
- {
- alarm.GET("/list", c.AlarmList)
- alarm.PUT("", c.AlarmHandle)
- alarm.GET("/statistic", c.AlarmStatistic)
- }
- dust := apiv1.Group("/dust")
- {
- dust.GET("/last", c.LatestDustMonitorData)
- dust.GET("/aqi", c.DustAqi)
- }
- }
- }
|