// 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-supplier-management-gateway/controller/v1" _ "smart-supplier-management-gateway/docs" "smart-supplier-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-supplier")) // version 1 apiv1 := engine.Group("/api/v1") { c := v1.NewController() apiv1.POST("/upload", c.Upload) apiv1.GET("/publicity", c.Publicity) apiv1.GET("/device_type_all", c.DeviceTypeAll) apiv1.GET("/vcode", c.Vcode) 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.ProviderApproveStatus) 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.PUT("/verify_mail", c.MailPrepare) user.PUT("/phone", c.PhoneUpdate) user.GET("/info", c.UserInfo) } device := apiv1.Group("/device") { device.POST("/docking", c.DeviceDocking) device.POST("", c.DeviceAdd) device.DELETE("", c.DeviceDel) device.GET("/type_list", c.DeviceTypeList) device.GET("/default_type_list", c.DeviceDefaultTypeList) device.GET("/list", c.DeviceList) device.GET("/can_del_list", c.DeviceCanDelList) device.GET("/vedio_list", c.DeviceVedioList) device.GET("/vedio_channel_list", c.DeviceVedioChannelList) device.POST("/vedio", c.VedioAdd) device.POST("/vedio_channel", c.ChannelAdd) device.PUT("/vedio_channel", c.ChannelUpdate) device.GET("/del_job_list", c.DeviceDelJobList) } project := apiv1.Group("project") { project.GET("/list", c.ProjectList) } oplog := apiv1.Group("log") { oplog.GET("/list", c.LogList) } } }