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

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