蛋蛋星球 后台端
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

209 rader
8.5 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. rContributionValue := rEggEnergy.Group("/contributionValue")
  142. {
  143. rContributionValue.GET("/basic", egg_energy.GetContributionValueBasicSetting)
  144. rContributionValue.POST("/updateBasic", egg_energy.UpdateContributionValueBasicSetting)
  145. }
  146. }
  147. }
  148. func rMarketingApplications(r *gin.RouterGroup) { //营销应用
  149. rNewUserRedPackage := r.Group("/newUserRedPackage") //新人红包
  150. {
  151. rNewUserRedPackage.GET("/getBasic", new_user_red_package.NewUserRedPackageGetBasic)
  152. rNewUserRedPackage.PUT("/updateBasic", new_user_red_package.NewUserRedPackageUpdateBasic)
  153. rNewUserRedPackage.POST("/recordList", new_user_red_package.NewUserRedPackageRecordList)
  154. rNewUserRedPackage.POST("/recordFlowList", new_user_red_package.NewUserRedPackageRecordFlowList)
  155. }
  156. }
  157. func rMemberCenter(r *gin.RouterGroup) { // 会员中心
  158. rUserManagement := r.Group("/userManagement")
  159. {
  160. rUserManagement.POST("/getUserList", member_center.UserManagementGetUserList)
  161. rUserManagement.GET("/userData", member_center.UserManagementGetOneBasic)
  162. rUserManagement.POST("/updateUserInfo", member_center.UserManagementUpdateUserInfo)
  163. rUserManagement.GET("/getFans", member_center.UserManagementGetFans)
  164. rUserManagement.GET("/balanceDetail", member_center.UserManagementGetBalanceDetail)
  165. rUserManagement.GET("/getVirtualCoinDetail", member_center.UserManagementGetVirtualCoinDetail)
  166. }
  167. rTagManagement := r.Group("/tagManagement")
  168. {
  169. rTagManagement.GET("/getTagList", member_center.GetTagList)
  170. rTagManagement.POST("/addTag", member_center.AddTag)
  171. rTagManagement.POST("/updateTag", member_center.UpdateTag)
  172. rTagManagement.DELETE("/deleteTag", member_center.DeleteTag)
  173. }
  174. rLevelManagement := r.Group("/levelManagement")
  175. {
  176. rLevelManagement.GET("/getLevelList", member_center.GetLevelList)
  177. rLevelManagement.GET("/getOneLevel", member_center.GetOneLevel)
  178. rLevelManagement.POST("/updateLevel", member_center.UpdateLevel)
  179. rLevelManagement.POST("/addLevel", member_center.AddLevel)
  180. rLevelManagement.DELETE("/deleteLevel", member_center.DeleteLevel)
  181. rLevelManagement.POST("/addLevelTask", member_center.AddLevelTask)
  182. rLevelManagement.POST("/updateLevelTask", member_center.UpdateLevelTask)
  183. rLevelManagement.DELETE("/deleteLevelTask", member_center.DeleteLevelTask)
  184. }
  185. }
  186. func rFinancialCenter(r *gin.RouterGroup) {
  187. rWithdraw := r.Group("/withdraw")
  188. {
  189. rWithdraw.GET("/setting", financial_center.GetWithdrawSetting)
  190. rWithdraw.POST("/updateWithdrawSetting", financial_center.UpdateWithdrawSetting)
  191. rWithdraw.GET("/applyList", financial_center.GetWithdrawApplyList)
  192. }
  193. }
  194. func rComm(r *gin.RouterGroup) {
  195. r.POST("/getMenuList", comm.MenuList) // 获取菜单栏列表
  196. r.GET("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL
  197. }