蛋蛋星球 后台端
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.
 
 
 
 

115 line
4.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("/communityDividendsList", public_platoon.ListCommunityDividends)
  71. rCommunityDividends.POST("/communityDividendsAdd", public_platoon.AddCommunityDividends)
  72. rCommunityDividends.POST("/communityDividendsWithUserList", public_platoon.ListCommunityDividendsWithUser)
  73. rCommunityDividends.POST("/communityDividendsWithUserAdd", public_platoon.AddCommunityDividendsWithUser)
  74. }
  75. rUserDailyActivityAnalysis := rPublicPlatoon.Group("/userDailyActivityAnalysis")
  76. {
  77. rUserDailyActivityAnalysis.POST("/index", public_platoon.UserDailyActivityAnalysis)
  78. }
  79. }
  80. rEggEnergy := r.Group("/eggEnergy") //蛋蛋能量
  81. {
  82. rEggEnergy.GET("/getVirtualCoinList", egg_energy.GetVirtualCoinList)
  83. rEggEnergy.GET("/getBasic", egg_energy.GetEggEnergyBasic)
  84. rEggEnergy.POST("/updateBasic", egg_energy.UpdateEggEnergyBasic)
  85. rEggEnergyUserCoin := rEggEnergy.Group("/userCoin")
  86. {
  87. rEggEnergyUserCoin.POST("/activePointsUserCoinList", egg_energy.GetActivePointsUserCoinList)
  88. rEggEnergyUserCoin.POST("/activePointsUserCoinFlowList", egg_energy.GetActivePointsUserCoinFlowList)
  89. rEggEnergyUserCoin.POST("/greenEnergyUserCoinList", egg_energy.GetGreenEnergyUserCoinList)
  90. rEggEnergyUserCoin.POST("/greenEnergyUserCoinFlowList", egg_energy.GetGreenEnergyUserCoinFlowList)
  91. }
  92. rEggEnergyAvailableEnergy := rEggEnergy.Group("/availableEnergy")
  93. {
  94. rEggEnergyAvailableEnergy.POST("/list", egg_energy.DynamicDataFlowList)
  95. }
  96. rEggGlobalData := rEggEnergy.Group("/globalData")
  97. {
  98. rEggGlobalData.POST("/coreDataList", egg_energy.GetEggCoreDataList)
  99. rEggGlobalData.POST("/fundDataList", egg_energy.GetFundDataList)
  100. rEggGlobalData.POST("/fundDataListRecord", egg_energy.GetFundDataRecordList)
  101. }
  102. }
  103. }
  104. func rComm(r *gin.RouterGroup) {
  105. r.POST("/getMenuList", comm.MenuList) // 获取菜单栏列表
  106. }