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

203 wiersze
8.2 KiB

  1. package router
  2. import (
  3. "applet/app/cfg"
  4. "applet/app/hdl"
  5. "applet/app/hdl/comm"
  6. "applet/app/hdl/financial_center"
  7. "applet/app/hdl/institutional_management/egg_energy"
  8. "applet/app/hdl/institutional_management/public_platoon"
  9. "applet/app/hdl/marketing_applications/new_user_red_package"
  10. "applet/app/hdl/member_center"
  11. "applet/app/hdl/setCenter/oss/aliyun"
  12. "applet/app/mw"
  13. _ "applet/docs"
  14. "github.com/gin-gonic/gin"
  15. swaggerFiles "github.com/swaggo/files"
  16. ginSwagger "github.com/swaggo/gin-swagger"
  17. )
  18. // 初始化路由
  19. func Init() *gin.Engine {
  20. // debug, release, test 项目阶段
  21. mode := "release"
  22. if cfg.Debug {
  23. mode = "debug"
  24. }
  25. gin.SetMode(mode)
  26. //创建一个新的启动器
  27. r := gin.New()
  28. r.GET("/api/swagger/*any", func(c *gin.Context) {
  29. // r.Use(mw.SwagAuth())
  30. ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, "SWAGGER")(c)
  31. })
  32. // 是否打印访问日志, 在非正式环境都打印
  33. if mode != "release" {
  34. r.Use(gin.Logger())
  35. }
  36. r.Use(gin.Recovery())
  37. r.GET("/favicon.ico", func(c *gin.Context) {
  38. c.Status(204)
  39. })
  40. r.NoRoute(func(c *gin.Context) {
  41. c.JSON(404, gin.H{"code": 404, "msg": "page not found", "data": []struct{}{}})
  42. })
  43. r.NoMethod(func(c *gin.Context) {
  44. c.JSON(405, gin.H{"code": 405, "msg": "method not allowed", "data": []struct{}{}})
  45. })
  46. r.Use(mw.Cors)
  47. route(r.Group("/api"))
  48. return r
  49. }
  50. func route(r *gin.RouterGroup) {
  51. r.GET("/test", hdl.Demo)
  52. r.POST("/login", hdl.Login)
  53. r.Use(mw.Auth) // 以下接口需要JWT验证
  54. rComm(r.Group("/comm"))
  55. r.Use(mw.CheckPermission) // 检测权限
  56. rInstitutionalManagement(r.Group("/institutionalManagement"))
  57. rMarketingApplications(r.Group("/marketingApplications"))
  58. rMemberCenter(r.Group("/memberCenter"))
  59. rSettCenter(r.Group("/settCenter"))
  60. rFinancialCenter(r.Group("/financialCenter"))
  61. }
  62. func rSettCenter(r *gin.RouterGroup) { //设置中心
  63. rOss := r.Group("/oss") //oss设置
  64. {
  65. rOssAliYun := rOss.Group("/aliYun") //阿里云
  66. {
  67. rOssAliYun.GET("/getBasic", aliyun.GetBasic)
  68. rOssAliYun.POST("/setBasic", aliyun.SetBasic)
  69. }
  70. }
  71. }
  72. func rInstitutionalManagement(r *gin.RouterGroup) { //制度管理
  73. rPublicPlatoon := r.Group("/publicPlatoon") //公排设置
  74. {
  75. rPublicPlatoon.GET("/getBasic", public_platoon.GetPublicPlatoonBasic)
  76. rPublicPlatoon.PUT("/updateBasic", public_platoon.UpdatePublicPlatoonBasic)
  77. rPublicPlatoon.GET("/relationshipMap", public_platoon.GetRelationshipMap)
  78. rPublicPlatoon.GET("/findUserRelationshipMap", public_platoon.FindUserRelationshipMap)
  79. rPublicPlatoon.GET("/findSubUserRelationshipMap", public_platoon.FindSubUserRelationshipMap)
  80. rPublicPlatoon.POST("/exchangeUserPosition", public_platoon.ExchangeUserPosition)
  81. rPublicPlatoon.POST("/selectMember", public_platoon.SelectMember)
  82. rPublicPlatoonUserFreePunish := rPublicPlatoon.Group("/publicPlatoonUserFreePunish")
  83. {
  84. rPublicPlatoonUserFreePunish.POST("/index", public_platoon.GetFreePublishUser)
  85. rPublicPlatoonUserFreePunish.POST("/save", public_platoon.AddFreePublishUser)
  86. rPublicPlatoonUserFreePunish.DELETE("/delete", public_platoon.DeleteFreePublishUser)
  87. }
  88. rCommunityDividends := rPublicPlatoon.Group("/communityDividends")
  89. {
  90. rCommunityDividends.POST("/communityDividendsList", public_platoon.ListCommunityDividends)
  91. rCommunityDividends.POST("/communityDividendsAdd", public_platoon.AddCommunityDividends)
  92. rCommunityDividends.POST("/communityDividendsWithUserList", public_platoon.ListCommunityDividendsWithUser)
  93. rCommunityDividends.POST("/communityDividendsWithUserAdd", public_platoon.AddCommunityDividendsWithUser)
  94. }
  95. rUserDailyActivityAnalysis := rPublicPlatoon.Group("/userDailyActivityAnalysis")
  96. {
  97. rUserDailyActivityAnalysis.POST("/index", public_platoon.UserDailyActivityAnalysis)
  98. }
  99. }
  100. rEggEnergy := r.Group("/eggEnergy") //蛋蛋能量
  101. {
  102. rEggEnergy.GET("/getVirtualCoinList", egg_energy.GetVirtualCoinList)
  103. rEggEnergy.GET("/getBasic", egg_energy.GetEggEnergyBasic)
  104. rEggEnergy.POST("/updateBasic", egg_energy.UpdateEggEnergyBasic)
  105. rEggEnergy.GET("/getVipSetting", egg_energy.GetEggEnergyVipSetting)
  106. rEggEnergy.POST("/addVipSetting", egg_energy.AddEggEnergyVipSetting)
  107. rEggEnergy.POST("/updateVipSetting", egg_energy.UpdateEggEnergyVipSetting)
  108. rEggEnergyUserCoin := rEggEnergy.Group("/userCoin")
  109. {
  110. rEggEnergyUserCoin.POST("/eggEnergyUserCoinList", egg_energy.GetEggEnergyUserCoinList)
  111. rEggEnergyUserCoin.POST("/eggEnergyUserCoinFlowList", egg_energy.GetEggEnergyUserCoinFlowList)
  112. rEggEnergyUserCoin.POST("/eggPointsUserCoinList", egg_energy.GetEggPointsUserCoinList)
  113. rEggEnergyUserCoin.POST("/getEggPointsUserCoinFlowList", egg_energy.GetEggPointsUserCoinFlowList)
  114. }
  115. rEggEnergyAvailableEnergy := rEggEnergy.Group("/availableEnergy")
  116. {
  117. rEggEnergyAvailableEnergy.POST("/list", egg_energy.DynamicDataFlowList)
  118. }
  119. rEggGlobalData := rEggEnergy.Group("/globalData")
  120. {
  121. rEggGlobalData.GET("/coreDataList", egg_energy.GetEggCoreDataList)
  122. rEggGlobalData.GET("/pointsCenterPriceCurve", egg_energy.GetPriceCurve)
  123. rEggGlobalData.POST("/fundDataList", egg_energy.GetFundDataList)
  124. rEggGlobalData.POST("/fundDataRecordList", egg_energy.GetFundDataRecordList)
  125. rEggGlobalData.POST("/fundDataAdd", egg_energy.AddFundData)
  126. }
  127. rPlatformRevenue := rEggEnergy.Group("/platformRevenue")
  128. {
  129. rPlatformRevenue.POST("/getVideoReward", egg_energy.GetVideoReward)
  130. rPlatformRevenue.POST("/setVideoReward", egg_energy.SetVideoReward)
  131. rPlatformRevenue.POST("/platformRevenueList", egg_energy.ListPlatformRevenue)
  132. rPlatformRevenue.POST("/platformRevenueAdd", egg_energy.AddPlatformRevenue)
  133. }
  134. rEggPoint := rEggEnergy.Group("/eggPoint")
  135. {
  136. rEggPoint.POST("/userEggIndex", egg_energy.UserEggIndex)
  137. rEggPoint.POST("/statisticsUserEggIndex", egg_energy.StatisticsUserEggIndex)
  138. rEggPoint.POST("/userEggFlow", egg_energy.UserEggFlow)
  139. rEggPoint.POST("/manualScore", egg_energy.ManualScore)
  140. }
  141. }
  142. }
  143. func rMarketingApplications(r *gin.RouterGroup) { //营销应用
  144. rNewUserRedPackage := r.Group("/newUserRedPackage") //新人红包
  145. {
  146. rNewUserRedPackage.GET("/getBasic", new_user_red_package.NewUserRedPackageGetBasic)
  147. rNewUserRedPackage.PUT("/updateBasic", new_user_red_package.NewUserRedPackageUpdateBasic)
  148. rNewUserRedPackage.POST("/recordList", new_user_red_package.NewUserRedPackageRecordList)
  149. rNewUserRedPackage.POST("/recordFlowList", new_user_red_package.NewUserRedPackageRecordFlowList)
  150. }
  151. }
  152. func rMemberCenter(r *gin.RouterGroup) { // 会员中心
  153. rUserManagement := r.Group("/userManagement")
  154. {
  155. rUserManagement.POST("/getUserList", member_center.UserManagementGetUserList)
  156. rUserManagement.GET("/userData", member_center.UserManagementGetOneBasic)
  157. rUserManagement.POST("/updateUserInfo", member_center.UserManagementUpdateUserInfo)
  158. rUserManagement.GET("/getFans", member_center.UserManagementGetFans)
  159. rUserManagement.GET("/balanceDetail", member_center.UserManagementGetBalanceDetail)
  160. rUserManagement.GET("/getVirtualCoinDetail", member_center.UserManagementGetVirtualCoinDetail)
  161. }
  162. rTagManagement := r.Group("/tagManagement")
  163. {
  164. rTagManagement.GET("/getTagList", member_center.GetTagList)
  165. rTagManagement.POST("/addTag", member_center.AddTag)
  166. rTagManagement.POST("/updateTag", member_center.UpdateTag)
  167. rTagManagement.DELETE("/deleteTag", member_center.DeleteTag)
  168. }
  169. rLevelManagement := r.Group("/levelManagement")
  170. {
  171. rLevelManagement.GET("/getLevelList", member_center.GetLevelList)
  172. rLevelManagement.GET("/getOneLevel", member_center.GetOneLevel)
  173. rLevelManagement.POST("/updateLevel", member_center.UpdateLevel)
  174. rLevelManagement.POST("/addLevel", member_center.AddLevel)
  175. rLevelManagement.DELETE("/deleteLevel", member_center.DeleteLevel)
  176. rLevelManagement.POST("/addLevelTask", member_center.AddLevelTask)
  177. rLevelManagement.POST("/updateLevelTask", member_center.UpdateLevelTask)
  178. rLevelManagement.DELETE("/deleteLevelTask", member_center.DeleteLevelTask)
  179. }
  180. }
  181. func rFinancialCenter(r *gin.RouterGroup) {
  182. rWithdraw := r.Group("/withdraw")
  183. {
  184. rWithdraw.GET("/setting", financial_center.GetWithdrawSetting)
  185. rWithdraw.POST("/updateWithdrawSetting", financial_center.UpdateWithdrawSetting)
  186. }
  187. }
  188. func rComm(r *gin.RouterGroup) {
  189. r.POST("/getMenuList", comm.MenuList) // 获取菜单栏列表
  190. r.GET("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL
  191. }