12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- package router
- import (
- "github.com/gin-gonic/gin"
- file "iot_manager_service/app/file/controller"
- "iot_manager_service/app/middleware"
- user "iot_manager_service/app/user/controller"
- "iot_manager_service/config"
- "iot_manager_service/util/logger"
- )
- func InitRouter(engine *gin.Engine) {
- // 跨域处理
- engine.Use(middleware.Cors())
- // 校验token令牌
- engine.Use(middleware.AuthMiddleware())
- engine.Use(gin.Recovery())
- if config.Instance().Logger.Switch == 1 {
- engine.Use(logger.LogToFile())
- }
- engine.Use(logger.Recover)
- //用户
- sys := engine.Group("/user")
- {
- sys.GET("/getpublickey", user.UserController.GetPublicKey)
- sys.POST("/login", user.UserController.Login)
- sys.POST("/logout", user.UserController.Logout)
- sys.GET("/getdeptusers", user.UserController.GetDeptUsers)
- }
- //文件
- files := engine.Group("/file")
- {
- files.POST("/distribute", file.FileController.Distribute)
- files.GET("/getuserfiles", file.FileController.GetUserFiles)
- }
- //通知
- notice := engine.Group("/notice")
- {
- notice.GET("/demo", user.UserController.GetUser)
- }
- }
|