123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- // 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-enterprise-management-gateway/controller/v1"
- _ "smart-enterprise-management-gateway/docs"
- "smart-enterprise-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("/map", c.Map)
- apiv1.GET("/publicity", c.Publicity)
- apiv1.GET("/device_type_all", c.DeviceTypeAll)
- apiv1.GET("/user/mail", c.MailUpdate)
- engine.POST("/api/v1/user/register", c.Register)
- engine.POST("/api/v1/user/login", c.Login)
- engine.PUT("/api/v1/user/set_passwd", c.SetPasswd)
- engine.GET("/api/v1/user/status", c.CompanyApproveStatus)
- engine.GET("/api/v1/user/captcha_id", c.CaptchaId)
- engine.GET("/api/v1/project/district", c.ProjectDistrict)
- 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.PUT("/verify_mail", c.MailPrepare)
- user.PUT("/phone", c.PhoneUpdate)
- user.GET("/info", c.UserInfo)
- user.GET("/tmp_token", c.TmpToken)
- }
- project := apiv1.Group("/project")
- {
- project.PUT("/user", c.EnableProjectUser)
- project.POST("", c.ProjectAdd)
- project.PUT("", c.ProjectUpdate)
- project.GET("/user_list", c.ProjectUserList)
- project.GET("/list", c.ProjectList)
- project.PUT("/password", c.ProjectUserPasswordReset)
- project.GET("/info/:id", c.ProjectInfo)
- project.DELETE("/:id", c.ProjectDel)
- project.PUT("/finish/:id", c.ProjectFinish)
- }
- device := apiv1.Group("/device")
- {
- device.GET("/type_list", c.DeviceTypeList)
- device.GET("/list", c.DeviceList)
- device.GET("/vedio_list", c.DeviceVedioList)
- device.GET("/vedio_channel_list", c.DeviceVedioChannelList)
- }
- oplog := apiv1.Group("log")
- {
- oplog.GET("/list", c.LogList)
- }
- }
- }
|