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

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