蛋蛋星球 后台端
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 
 

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