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

267 rivejä
10 KiB

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