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

137 lines
5.0 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/hdl/setCenter/oss/aliyun"
  9. "applet/app/mw"
  10. _ "applet/docs"
  11. "github.com/gin-gonic/gin"
  12. swaggerFiles "github.com/swaggo/files"
  13. ginSwagger "github.com/swaggo/gin-swagger"
  14. )
  15. // 初始化路由
  16. func Init() *gin.Engine {
  17. // debug, release, test 项目阶段
  18. mode := "release"
  19. if cfg.Debug {
  20. mode = "debug"
  21. }
  22. gin.SetMode(mode)
  23. //创建一个新的启动器
  24. r := gin.New()
  25. r.GET("/api/swagger/*any", func(c *gin.Context) {
  26. // r.Use(mw.SwagAuth())
  27. ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, "SWAGGER")(c)
  28. })
  29. // 是否打印访问日志, 在非正式环境都打印
  30. if mode != "release" {
  31. r.Use(gin.Logger())
  32. }
  33. r.Use(gin.Recovery())
  34. r.GET("/favicon.ico", func(c *gin.Context) {
  35. c.Status(204)
  36. })
  37. r.NoRoute(func(c *gin.Context) {
  38. c.JSON(404, gin.H{"code": 404, "msg": "page not found", "data": []struct{}{}})
  39. })
  40. r.NoMethod(func(c *gin.Context) {
  41. c.JSON(405, gin.H{"code": 405, "msg": "method not allowed", "data": []struct{}{}})
  42. })
  43. r.Use(mw.Cors)
  44. route(r.Group("/api"))
  45. return r
  46. }
  47. func route(r *gin.RouterGroup) {
  48. r.GET("/test", hdl.Demo)
  49. r.POST("/login", hdl.Login)
  50. r.Use(mw.Auth) // 以下接口需要JWT验证
  51. rComm(r.Group("/comm"))
  52. r.Use(mw.CheckPermission) // 检测权限
  53. rInstitutionalManagement(r.Group("/institutionalManagement"))
  54. rSettCenter(r.Group("/settCenter"))
  55. }
  56. func rSettCenter(r *gin.RouterGroup) { //设置中心
  57. rOss := r.Group("/oss") //oss设置
  58. {
  59. rOssAliYun := rOss.Group("/aliYun") //阿里云
  60. {
  61. rOssAliYun.GET("/getBasic", aliyun.GetBasic)
  62. rOssAliYun.POST("/setBasic", aliyun.SetBasic)
  63. }
  64. }
  65. }
  66. func rInstitutionalManagement(r *gin.RouterGroup) { //制度管理
  67. rPublicPlatoon := r.Group("/publicPlatoon") //公排设置
  68. {
  69. rPublicPlatoon.GET("/getBasic", public_platoon.GetPublicPlatoonBasic)
  70. rPublicPlatoon.PUT("/updateBasic", public_platoon.UpdatePublicPlatoonBasic)
  71. rPublicPlatoon.GET("/relationshipMap", public_platoon.GetRelationshipMap)
  72. rPublicPlatoon.GET("/findUserRelationshipMap", public_platoon.FindUserRelationshipMap)
  73. rPublicPlatoon.GET("/findSubUserRelationshipMap", public_platoon.FindSubUserRelationshipMap)
  74. rPublicPlatoon.POST("/exchangeUserPosition", public_platoon.ExchangeUserPosition)
  75. rPublicPlatoonUserFreePunish := rPublicPlatoon.Group("/publicPlatoonUserFreePunish")
  76. {
  77. rPublicPlatoonUserFreePunish.POST("/index", public_platoon.GetFreePublishUser)
  78. rPublicPlatoonUserFreePunish.POST("/save", public_platoon.AddFreePublishUser)
  79. }
  80. rCommunityDividends := rPublicPlatoon.Group("/communityDividends")
  81. {
  82. rCommunityDividends.POST("/communityDividendsList", public_platoon.ListCommunityDividends)
  83. rCommunityDividends.POST("/communityDividendsAdd", public_platoon.AddCommunityDividends)
  84. rCommunityDividends.POST("/communityDividendsWithUserList", public_platoon.ListCommunityDividendsWithUser)
  85. rCommunityDividends.POST("/communityDividendsWithUserAdd", public_platoon.AddCommunityDividendsWithUser)
  86. }
  87. rUserDailyActivityAnalysis := rPublicPlatoon.Group("/userDailyActivityAnalysis")
  88. {
  89. rUserDailyActivityAnalysis.POST("/index", public_platoon.UserDailyActivityAnalysis)
  90. }
  91. }
  92. rEggEnergy := r.Group("/eggEnergy") //蛋蛋能量
  93. {
  94. rEggEnergy.GET("/getVirtualCoinList", egg_energy.GetVirtualCoinList)
  95. rEggEnergy.GET("/getBasic", egg_energy.GetEggEnergyBasic)
  96. rEggEnergy.POST("/updateBasic", egg_energy.UpdateEggEnergyBasic)
  97. rEggEnergyUserCoin := rEggEnergy.Group("/userCoin")
  98. {
  99. rEggEnergyUserCoin.POST("/activePointsUserCoinList", egg_energy.GetActivePointsUserCoinList)
  100. rEggEnergyUserCoin.POST("/activePointsUserCoinFlowList", egg_energy.GetActivePointsUserCoinFlowList)
  101. rEggEnergyUserCoin.POST("/greenEnergyUserCoinList", egg_energy.GetGreenEnergyUserCoinList)
  102. rEggEnergyUserCoin.POST("/greenEnergyUserCoinFlowList", egg_energy.GetGreenEnergyUserCoinFlowList)
  103. }
  104. rEggEnergyAvailableEnergy := rEggEnergy.Group("/availableEnergy")
  105. {
  106. rEggEnergyAvailableEnergy.POST("/list", egg_energy.DynamicDataFlowList)
  107. }
  108. rEggGlobalData := rEggEnergy.Group("/globalData")
  109. {
  110. rEggGlobalData.GET("/coreDataList", egg_energy.GetEggCoreDataList)
  111. rEggGlobalData.GET("/pointsCenterPriceCurve", egg_energy.GetPriceCurve)
  112. rEggGlobalData.POST("/fundDataList", egg_energy.GetFundDataList)
  113. rEggGlobalData.POST("/fundDataRecordList", egg_energy.GetFundDataRecordList)
  114. rEggGlobalData.POST("/fundDataAdd", egg_energy.AddFundData)
  115. }
  116. rPlatformRevenue := rEggEnergy.Group("/platformRevenue")
  117. {
  118. rPlatformRevenue.POST("/setVideoReward", egg_energy.SetVideoReward)
  119. rPlatformRevenue.POST("/platformRevenueList", egg_energy.ListPlatformRevenue)
  120. rPlatformRevenue.POST("/platformRevenueAdd", egg_energy.AddPlatformRevenue)
  121. }
  122. }
  123. }
  124. func rComm(r *gin.RouterGroup) {
  125. r.POST("/getMenuList", comm.MenuList) // 获取菜单栏列表
  126. r.GET("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL
  127. }