route.go 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // Copyright 2019 github.com. All rights reserved.
  2. // Use of this source code is governed by github.com.
  3. package route
  4. import (
  5. "net/http"
  6. "github.com/gin-gonic/gin"
  7. "xingjia-management-gateway/controller/v1"
  8. "xingjia-management-gateway/route/middleware"
  9. _ "xingjia-management-gateway/docs"
  10. )
  11. func SetupRoute(engine *gin.Engine) {
  12. // 404页面
  13. engine.NoRoute(func(c *gin.Context) {
  14. c.String(http.StatusNotFound, "Not Found")
  15. })
  16. // 服务健康检查
  17. engine.GET("/ping", func(c *gin.Context) {
  18. // TODO 心跳检查
  19. c.String(http.StatusOK, "pong")
  20. })
  21. //engine.Use(middleware.Session("smart-site-supplier"))
  22. // version 1
  23. apiv1 := engine.Group("/api/v1")
  24. {
  25. c := v1.NewController()
  26. engine.POST("/api/v1/user/login", c.Login)
  27. engine.GET("/api/v1/file", c.DownLoad)
  28. engine.PUT("/api/v1/token_refresh", c.TokenRefresh)
  29. apiv1.Use(middleware.Jwt())
  30. apiv1.POST("/file", c.Upload)
  31. //apiv1.GET("/file", c.DownLoad)
  32. //apiv1.PUT("/token_refresh", c.TokenRefresh)
  33. muser := apiv1.Group("/management_user")
  34. {
  35. muser.POST("", c.ManagementUserAdd)
  36. muser.PUT("/password", c.ManagementUserResetPassword)
  37. muser.GET("", c.ManagementUserList)
  38. muser.PUT("", c.ManagementUserUpdate)
  39. muser.DELETE("", c.ManagementUserDel)
  40. }
  41. olog := apiv1.Group("/operation_log")
  42. {
  43. olog.GET("", c.OperationLogList)
  44. olog.DELETE("", c.OperationLogDel)
  45. }
  46. jt := apiv1.Group("/jt")
  47. {
  48. jt.POST("/desc", c.JtDescAdd)
  49. jt.GET("/desc", c.JtDescInfo)
  50. jt.PUT("/desc", c.JtDescUpdate)
  51. jt.DELETE("/desc", c.JtDescDel)
  52. jt.PUT("/desc/publish", c.JtDescPublish)
  53. jt.POST("/vision", c.JtVisionAdd)
  54. jt.GET("/vision", c.JtVisionInfo)
  55. jt.PUT("/vision", c.JtVisionUpdate)
  56. jt.DELETE("/vision", c.JtVisionDel)
  57. jt.PUT("/vision/publish", c.JtVisionPublish)
  58. jt.POST("/news", c.JtNewsAdd)
  59. jt.GET("/news", c.JtNewsList)
  60. jt.PUT("/news", c.JtNewsUpdate)
  61. jt.DELETE("/news", c.JtNewsDel)
  62. jt.PUT("/news/publish", c.JtNewsPublish)
  63. jt.POST("/announcement", c.JtAnnouncementAdd)
  64. jt.GET("/announcement", c.JtAnnouncementList)
  65. jt.PUT("/announcement", c.JtAnnouncementUpdate)
  66. jt.DELETE("/announcement", c.JtAnnouncementDel)
  67. jt.PUT("/announcement/publish", c.JtAnnouncementPublish)
  68. jt.POST("/program", c.JtProgramAdd)
  69. jt.GET("/program", c.JtProgramList)
  70. jt.PUT("/program", c.JtProgramUpdate)
  71. jt.DELETE("/program", c.JtProgramDel)
  72. jt.PUT("/program/publish", c.JtProgramPublish)
  73. jt.POST("/lx", c.JtLxAdd)
  74. jt.GET("/lx", c.JtLxList)
  75. jt.PUT("/lx", c.JtLxUpdate)
  76. jt.DELETE("/lx", c.JtLxDel)
  77. jt.PUT("/lx/publish", c.JtLxPublish)
  78. jt.POST("/hw", c.JtHwAdd)
  79. jt.GET("/hw", c.JtHwList)
  80. jt.PUT("/hw", c.JtHwUpdate)
  81. jt.DELETE("/hw", c.JtHwDel)
  82. jt.PUT("/hw/publish", c.JtHwPublish)
  83. jt.POST("/df", c.JtDfAdd)
  84. jt.GET("/df", c.JtDfList)
  85. jt.PUT("/df", c.JtDfUpdate)
  86. jt.DELETE("/df", c.JtDfDel)
  87. jt.PUT("/df/publish", c.JtDfPublish)
  88. jt.POST("/contact", c.JtContactAdd)
  89. jt.GET("/contact", c.JtContactInfo)
  90. jt.PUT("/contact", c.JtContactUpdate)
  91. jt.DELETE("/contact", c.JtContactDel)
  92. jt.POST("/page_pic", c.PagePicAdd)
  93. jt.GET("/page_pic", c.PagePicList)
  94. jt.PUT("/page_pic", c.PagePicUpdate)
  95. jt.DELETE("/page_pic", c.PagePicDel)
  96. }
  97. }
  98. }