蛋蛋星球 后台端
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

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