蛋蛋星球 后台端
 
 
 
 

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