蛋蛋星球-客户端
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.

router.go 6.8 KiB

2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
2 weeks ago
1 week ago
2 weeks ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
2 weeks ago
1 week ago
1 week ago
1 week ago
1 week ago
2 weeks ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
1 week ago
2 weeks ago
1 week ago
1 week ago
2 weeks ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. package router
  2. import (
  3. "applet/app/cfg"
  4. "applet/app/hdl"
  5. "applet/app/hdl/comm"
  6. "applet/app/mw"
  7. _ "applet/docs"
  8. "github.com/gin-gonic/gin"
  9. swaggerFiles "github.com/swaggo/files"
  10. ginSwagger "github.com/swaggo/gin-swagger"
  11. "net/http"
  12. )
  13. // 初始化路由
  14. func Init() *gin.Engine {
  15. // debug, release, test 项目阶段
  16. mode := "release"
  17. if cfg.Debug {
  18. mode = "debug"
  19. }
  20. gin.SetMode(mode)
  21. //创建一个新的启动器
  22. r := gin.New()
  23. r.GET("/api/swagger/*any", func(c *gin.Context) {
  24. // r.Use(mw.SwagAuth())
  25. ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, "SWAGGER")(c)
  26. })
  27. // 是否打印访问日志, 在非正式环境都打印
  28. if mode != "release" {
  29. r.Use(gin.Logger())
  30. }
  31. r.Use(gin.Recovery())
  32. r.Delims("<<<", ">>>").LoadHTMLGlob("static/html/*")
  33. r.GET("/favicon.ico", func(c *gin.Context) {
  34. c.Status(204)
  35. })
  36. r.NoRoute(func(c *gin.Context) {
  37. c.JSON(404, gin.H{"code": 404, "msg": "page not found", "data": []struct{}{}})
  38. })
  39. r.NoMethod(func(c *gin.Context) {
  40. c.JSON(405, gin.H{"code": 405, "msg": "method not allowed", "data": []struct{}{}})
  41. })
  42. r.Use(mw.Cors)
  43. route(r.Group("/api/v1"))
  44. return r
  45. }
  46. func route(r *gin.RouterGroup) {
  47. r.StaticFS("/static", http.Dir("./static"))
  48. r.GET("/test", hdl.Demo)
  49. r.Any("/createSign", hdl.CreateSign)
  50. r.Any("/aesDecryptByECB", hdl.AesDecryptByECB)
  51. r.GET("/article/html", hdl.ArticleHtml) //H5渲染的文章
  52. r.Use(mw.CheckSign)
  53. r.Any("/testCreateSign", hdl.TestCreateSign)
  54. r.GET("/openApp/start", hdl.Start) //打开app调用
  55. r.GET("/config", hdl.Config) //基本配置
  56. r.GET("/version", hdl.Version) //版本数据
  57. {
  58. r.GET("/advertising", hdl.Advertising) //广告位
  59. r.POST("/advertising/detail", hdl.AdvertisingDetail) //广告位
  60. }
  61. {
  62. r.POST("/smsSend", hdl.SmsSend) //发送短信
  63. r.POST("/fastLogin", hdl.FastLogin) //一键登录
  64. r.POST("/wechatLogin", hdl.WechatLogin) //微信登录
  65. r.POST("/register", hdl.Register) //注册
  66. r.POST("/login", hdl.Login) //登录
  67. r.POST("/findPassword", hdl.FindPassword) //找回密码
  68. r.POST("/inviteCode/userInfo", hdl.InviteCodeUserInfo) //邀请码查用户
  69. }
  70. r.GET("/getModuleSetting", hdl.GetModuleSetting) // 获取页面样式
  71. r.Use(mw.Auth) // 以下接口需要JWT验证
  72. rComm(r.Group("/comm"))
  73. r.POST("/advertising/check", hdl.AdvertisingCheck) //广告位判断能不能看
  74. rHomePage := r.Group("/homePage")
  75. {
  76. rHomePage.GET("/index", hdl.HomePage) // 主页
  77. rHomePage.GET("/adRule", hdl.HomePageWatchAdRule) // 主页-可以观看广告规则
  78. rHomePage.GET("/realTimePrice", hdl.RealTimePrice) // 主页-实时数据
  79. rHomePage.GET("/isCanSignIn", hdl.IsCanSignIn) // 主页-是否可以观看广告
  80. rHomePage.GET("/isCanGetRedPackage", hdl.IsCanGetRedPackage) // 主页-是否可以获得红包
  81. }
  82. rAddFriend := r.Group("/addFriend")
  83. {
  84. rAddFriend.POST("/eggEnergyDetails", hdl.EggEnergyDetails) // 添加好友-蛋蛋能量明细
  85. rAddFriend.POST("/eggPointDetails", hdl.EggPointDetails) // 添加好友-蛋蛋积分明细
  86. rAddFriend.GET("/basalRate", hdl.BasalRate) // 添加好友-基础速率
  87. rAddFriend.GET("/totalRate", hdl.TotalRate) // 添加好友-总速率
  88. rAddFriend.GET("/myFans", hdl.MyFans) // 添加好友-我的粉丝-团队速率
  89. rAddFriend.GET("/myFansUserList", hdl.MyFansUserList) // 添加好友-我的粉丝-好友列表
  90. rAddFriend.GET("/nineDimensionalSpace", hdl.NineDimensionalSpace) // 添加好友-我的粉丝-九维空间
  91. }
  92. rMemberCenter := r.Group("/memberCenter")
  93. {
  94. rMemberCenter.GET("/getBasic", hdl.MemberCenterGetBasic) // 会员中心-基础数据
  95. rMemberCenter.POST("/bindParent", hdl.UserBindParent) //绑定上级
  96. }
  97. rPointsCenter := r.Group("/pointsCenter") // 积分中心
  98. {
  99. rPointsCenter.GET("/basic", hdl.PointsCenterGetBasic) // 积分中心-基础信息
  100. rPointsCenter.GET("/initialData", hdl.InitialData) // 积分中心-初始数据
  101. rPointsCenter.GET("/dynamicData", hdl.DynamicData) // 积分中心-动态数据
  102. rPointsCenter.GET("/pointsExchangeBasic", hdl.PointsExchangeGetBasic) // 积分中心-能量兑换基础数据
  103. rPointsCenter.GET("/priceCurve", hdl.GetPriceCurve) // 积分中心-获取价格曲线
  104. rPointsCenter.POST("/exchangeEnergy", hdl.ExchangeEnergy) // 积分中心-能量兑换
  105. rPointsCenter.GET("/contributionValue", hdl.GetContributionValue) // 积分中心-贡献值
  106. rPointsCenter.GET("/contributionValueFlow", hdl.GetContributionValueFlow) // 积分中心-贡献值明细
  107. rPointsCenter.GET("/record", hdl.GetEggPointRecord) // 积分中心-蛋蛋分历史记录
  108. rPointsCenter.GET("/energyFlow", hdl.GetEggEnergyFlow) // 积分中心-积分收支明细
  109. }
  110. rWallet := r.Group("/wallet") // 钱包
  111. {
  112. rWallet.GET("/amountFlow", hdl.GetAmountFlow) // 余额流水
  113. rWithdraw := r.Group("/withdraw")
  114. {
  115. rWithdraw.GET("/index", hdl.WithdrawGetAmount)
  116. }
  117. }
  118. rCollege := r.Group("/college") //学院
  119. {
  120. rCollege.GET("/cate", hdl.CollegeCate) // 分类
  121. rCollege.POST("/list", hdl.CollegeList) // 文章
  122. rCollege.POST("/detail", hdl.CollegeDetail) // 文章详情
  123. rCollege.POST("/like/add", hdl.CollegeLikeAdd) // 文章点赞
  124. rCollege.POST("/like/cancel", hdl.CollegeLikeCancel) // 文章取消点赞
  125. rCollege.POST("/share/add", hdl.CollegeShareAdd) // 文章分享记录数量
  126. }
  127. rUserFeedback := r.Group("/userFeedback") //用户反馈
  128. {
  129. rUserFeedback.GET("/cate", hdl.UserFeedbackCate) // 分类
  130. rUserFeedback.POST("/list", hdl.UserFeedbackList) // 反馈记录
  131. rUserFeedback.POST("/record", hdl.UserFeedbackRecord) // 反馈记录-回复
  132. rUserFeedback.POST("/save", hdl.UserFeedbackSave) // 提交
  133. rUserFeedback.POST("/say", hdl.UserFeedbackSay) // 沟通
  134. }
  135. rNewUserRedPacket := r.Group("/newUserRedPacket") // 新人红包
  136. {
  137. rNewUserRedPacket.GET("/index", hdl.NewUserRedPacketInfo)
  138. }
  139. rIm := r.Group("/im")
  140. {
  141. rIm.POST("/user/sendRedPackage", hdl.SendRedPackage) // IM-发送红包
  142. rIm.POST("/user/sendRedPackageDetail", hdl.SendRedPackageDetail) // IM-发送红包详情
  143. rIm.POST("/user/grabRedPackage", hdl.GrabRedPackage) // IM-领取红包
  144. rIm.GET("/redPackageDetail", hdl.RedPackageDetail) // IM-红包详情
  145. }
  146. }
  147. func rComm(r *gin.RouterGroup) {
  148. r.POST("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL
  149. r.GET("/accessRecords", comm.AccessRecords) // 访问记录
  150. }