蛋蛋星球 后台端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

97 rivejä
3.2 KiB

  1. package router
  2. import (
  3. "applet/app/cfg"
  4. "applet/app/hdl"
  5. "applet/app/hdl/comm"
  6. "applet/app/hdl/institutional_management/egg_Energy"
  7. "applet/app/hdl/institutional_management/public_platoon"
  8. "applet/app/mw"
  9. _ "applet/docs"
  10. "github.com/gin-gonic/gin"
  11. swaggerFiles "github.com/swaggo/files"
  12. ginSwagger "github.com/swaggo/gin-swagger"
  13. )
  14. // 初始化路由
  15. func Init() *gin.Engine {
  16. // debug, release, test 项目阶段
  17. mode := "release"
  18. if cfg.Debug {
  19. mode = "debug"
  20. }
  21. gin.SetMode(mode)
  22. //创建一个新的启动器
  23. r := gin.New()
  24. r.GET("/api/swagger/*any", func(c *gin.Context) {
  25. // r.Use(mw.SwagAuth())
  26. ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, "SWAGGER")(c)
  27. })
  28. // 是否打印访问日志, 在非正式环境都打印
  29. if mode != "release" {
  30. r.Use(gin.Logger())
  31. }
  32. r.Use(gin.Recovery())
  33. r.GET("/favicon.ico", func(c *gin.Context) {
  34. c.Status(204)
  35. })
  36. r.NoRoute(func(c *gin.Context) {
  37. c.JSON(404, gin.H{"code": 404, "msg": "page not found", "data": []struct{}{}})
  38. })
  39. r.NoMethod(func(c *gin.Context) {
  40. c.JSON(405, gin.H{"code": 405, "msg": "method not allowed", "data": []struct{}{}})
  41. })
  42. r.Use(mw.Cors)
  43. route(r.Group("/api"))
  44. return r
  45. }
  46. func route(r *gin.RouterGroup) {
  47. r.GET("/test", hdl.Demo)
  48. r.POST("/login", hdl.Login)
  49. //r.Use(mw.Auth) // 以下接口需要JWT验证
  50. rComm(r.Group("/comm"))
  51. //r.Use(mw.CheckPermission) // 检测权限
  52. rInstitutionalManagement(r.Group("/institutionalManagement"))
  53. }
  54. func rInstitutionalManagement(r *gin.RouterGroup) { //制度管理
  55. rPublicPlatoon := r.Group("/publicPlatoon") //公排设置
  56. {
  57. rPublicPlatoon.GET("/getBasic", public_platoon.GetPublicPlatoonBasic)
  58. rPublicPlatoon.PUT("/updateBasic", public_platoon.UpdatePublicPlatoonBasic)
  59. rPublicPlatoon.GET("/relationshipMap", public_platoon.GetRelationshipMap)
  60. rPublicPlatoon.GET("/findUserRelationshipMap", public_platoon.FindUserRelationshipMap)
  61. rPublicPlatoon.GET("/findSubUserRelationshipMap", public_platoon.FindSubUserRelationshipMap)
  62. rPublicPlatoon.POST("/exchangeUserPosition", public_platoon.ExchangeUserPosition)
  63. rPublicPlatoonUserFreePunish := rPublicPlatoon.Group("/publicPlatoonUserFreePunish")
  64. {
  65. rPublicPlatoonUserFreePunish.POST("/index", public_platoon.GetFreePublishUser)
  66. rPublicPlatoonUserFreePunish.POST("/save", public_platoon.AddFreePublishUser)
  67. }
  68. rCommunityDividends := rPublicPlatoon.Group("/communityDividends")
  69. {
  70. rCommunityDividends.POST("/communityDividendsAdd", public_platoon.AddCommunityDividends)
  71. rCommunityDividends.POST("/communityDividendsWithUserAdd", public_platoon.AddCommunityDividendsWithUser)
  72. }
  73. rUserDailyActivityAnalysis := rPublicPlatoon.Group("/userDailyActivityAnalysis")
  74. {
  75. rUserDailyActivityAnalysis.POST("/index", public_platoon.UserDailyActivityAnalysis)
  76. }
  77. }
  78. rEggEnergy := r.Group("/eggEnergy")
  79. {
  80. rEggEnergy.POST("/activePointsUserCoinList", egg_Energy.GetActivePointsUserCoinList)
  81. rEggEnergy.POST("/activePointsUserCoinFlowList", egg_Energy.GetActivePointsUserCoinFlowList)
  82. rEggEnergy.POST("/greenEnergyUserCoinList", egg_Energy.GetGreenEnergyUserCoinList)
  83. rEggEnergy.POST("/greenEnergyUserCoinFlowList", egg_Energy.GetGreenEnergyUserCoinFlowList)
  84. }
  85. }
  86. func rComm(r *gin.RouterGroup) {
  87. r.POST("/getMenuList", comm.MenuList) // 获取菜单栏列表
  88. }