蛋蛋星球 后台端
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 
 

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