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

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