蛋蛋星球 后台端
 
 
 
 

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