蛋蛋星球 后台端
 
 
 
 

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