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

240 lines
11 KiB

  1. package router
  2. import (
  3. "applet/app/cfg"
  4. "applet/app/hdl"
  5. "applet/app/hdl/comm"
  6. "applet/app/hdl/friend_circle"
  7. "applet/app/mw"
  8. _ "applet/docs"
  9. "github.com/gin-contrib/pprof"
  10. "github.com/gin-gonic/gin"
  11. swaggerFiles "github.com/swaggo/files"
  12. ginSwagger "github.com/swaggo/gin-swagger"
  13. "net/http"
  14. )
  15. // 初始化路由
  16. func Init() *gin.Engine {
  17. // debug, release, test 项目阶段
  18. mode := "release"
  19. if cfg.Debug {
  20. mode = "debug"
  21. }
  22. gin.SetMode(mode)
  23. //创建一个新的启动器
  24. r := gin.New()
  25. r.GET("/api/swagger/*any", func(c *gin.Context) {
  26. // r.Use(mw.SwagAuth())
  27. ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, "SWAGGER")(c)
  28. })
  29. // 是否打印访问日志, 在非正式环境都打印
  30. if mode != "release" {
  31. r.Use(gin.Logger())
  32. }
  33. r.Use(gin.Recovery())
  34. r.Delims("<<<", ">>>").LoadHTMLGlob("static/html/*")
  35. r.GET("/favicon.ico", func(c *gin.Context) {
  36. c.Status(204)
  37. })
  38. r.NoRoute(func(c *gin.Context) {
  39. c.JSON(404, gin.H{"code": 404, "msg": "page not found", "data": []struct{}{}})
  40. })
  41. r.NoMethod(func(c *gin.Context) {
  42. c.JSON(405, gin.H{"code": 405, "msg": "method not allowed", "data": []struct{}{}})
  43. })
  44. r.Use(mw.Cors)
  45. route(r.Group("/api/v1"))
  46. pprof.Register(r, "/api/v1/comm/debug/pprof")
  47. return r
  48. }
  49. func route(r *gin.RouterGroup) {
  50. r.StaticFS("/static", http.Dir("./static"))
  51. r.GET("/test", hdl.Demo)
  52. r.GET("/test1", hdl.Demo1)
  53. r.Any("/createSign", hdl.CreateSign)
  54. r.Any("/aesDecryptByECB", hdl.AesDecryptByECB)
  55. r.GET("/article/html", hdl.ArticleHtml) //H5渲染的文章
  56. rCallback := r.Group("/callback")
  57. {
  58. rCallback.Any("/alipay/face", hdl.CallbackAlipayFace) //支付宝实名回调
  59. }
  60. r.Use(mw.CheckSign)
  61. r.Use(mw.Limiter) //进行限流
  62. r.Any("/testCreateSign", hdl.TestCreateSign)
  63. r.GET("/openApp/start", hdl.Start) //打开app调用
  64. r.GET("/config", hdl.Config) //基本配置
  65. r.GET("/version", hdl.Version) //版本数据
  66. r.GET("/downloadList", hdl.DownloadList) //版本数据
  67. {
  68. r.GET("/advertising", hdl.Advertising) //广告位
  69. r.POST("/advertising/detail", hdl.AdvertisingDetail) //广告位
  70. }
  71. {
  72. r.POST("/smsSend", hdl.SmsSend) //发送短信
  73. r.POST("/fastLogin", hdl.FastLogin) //一键登录
  74. r.POST("/wechatLogin", hdl.WechatLogin) //微信登录
  75. r.POST("/wechatRegister", hdl.WechatRegister) //注册
  76. r.POST("/register", hdl.Register) //注册
  77. r.POST("/login", hdl.Login) //登录
  78. r.POST("/findPassword", hdl.FindPassword) //找回密码
  79. r.POST("/inviteCode/userInfo", hdl.InviteCodeUserInfo) //邀请码查用户
  80. }
  81. r.POST("/college/detail", hdl.CollegeDetail) // 文章详情
  82. rGuidePage := r.Group("/guidePage")
  83. {
  84. rGuidePage.GET("/runningTime", hdl.GetRunningTime)
  85. }
  86. r.GET("/getModuleSetting", hdl.GetModuleSetting) // 获取页面样式
  87. r.Use(mw.Auth) // 以下接口需要JWT验证
  88. rCircleFriends(r.Group("/circleFriends"))
  89. rComm(r.Group("/comm"))
  90. rAdvertising := r.Group("/advertising") //广告
  91. {
  92. rAdvertising.POST("/check", hdl.AdvertisingCheck) //广告位判断能不能看
  93. rAdvertising.POST("/state", hdl.AdvertisingState) //广告位状态
  94. }
  95. rHomePage := r.Group("/homePage")
  96. {
  97. rHomePage.GET("/index", hdl.HomePage) // 主页
  98. rHomePage.GET("/adRule", hdl.HomePageWatchAdRule) // 主页-可以观看广告规则
  99. rHomePage.GET("/realTimePrice", hdl.RealTimePrice) // 主页-实时数据
  100. rHomePage.GET("/isCanSignIn", hdl.IsCanSignIn) // 主页-是否可以签到
  101. rHomePage.GET("/isCanGetRedPackage", hdl.IsCanGetRedPackage) // 主页-是否可以获得红包
  102. rHomePage.GET("/heroList", hdl.HeroList) // 主页-英雄榜
  103. }
  104. rAddFriend := r.Group("/addFriend")
  105. {
  106. rAddFriend.POST("/eggEnergyDetails", hdl.EggEnergyDetails) // 添加好友-蛋蛋能量明细
  107. rAddFriend.POST("/eggPointDetails", hdl.EggPointDetails) // 添加好友-蛋蛋积分明细
  108. rAddFriend.GET("/basalRate", hdl.BasalRate) // 添加好友-基础速率
  109. rAddFriend.GET("/totalRate", hdl.TotalRate) // 添加好友-总速率
  110. rAddFriend.GET("/myFans", hdl.MyFans) // 添加好友-我的粉丝-团队速率
  111. rAddFriend.GET("/myFansUserList", hdl.MyFansUserList) // 添加好友-我的粉丝-好友列表
  112. rAddFriend.GET("/nineDimensionalSpace", hdl.NineDimensionalSpace) // 添加好友-我的粉丝-九维空间
  113. }
  114. rMemberCenter := r.Group("/memberCenter")
  115. {
  116. rMemberCenter.GET("/getBasic", hdl.MemberCenterGetBasic) // 会员中心-基础数据
  117. rMemberCenter.POST("/bindParent", hdl.UserBindParent) //绑定上级
  118. rMemberCenter.POST("/bindUserInfo", hdl.BindUserInfo) //绑定用户信息
  119. rMemberCenter.GET("/parentInfo", hdl.ParentInfo) //上级信息
  120. rMemberCenter.POST("/updatePassword", hdl.UpdatePassword) //修改密码
  121. rMemberCenter.POST("/updatePasscode", hdl.UpdatePasscode) //修改支付密码
  122. rMemberCenter.GET("/inviteUrl", hdl.InviteUrl) //邀请链接
  123. rMemberCenter.POST("/delete", hdl.Delete) //注销账号
  124. rMemberCenter.GET("/delete/info", hdl.DeleteInfo) //注销账号相关信息
  125. }
  126. rPointsCenter := r.Group("/pointsCenter") // 积分中心
  127. {
  128. rPointsCenter.GET("/basic", hdl.PointsCenterGetBasic) // 积分中心-基础信息
  129. rPointsCenter.GET("/initialData", hdl.InitialData) // 积分中心-初始数据
  130. rPointsCenter.GET("/dynamicData", hdl.DynamicData) // 积分中心-动态数据
  131. rPointsCenter.GET("/pointsExchangeBasic", hdl.PointsExchangeGetBasic) // 积分中心-能量兑换基础数据
  132. rPointsCenter.GET("/priceCurve", hdl.GetPriceCurve) // 积分中心-获取价格曲线
  133. rPointsCenter.POST("/exchangeEnergy", hdl.ExchangeEnergy) // 积分中心-能量兑换
  134. rPointsCenter.GET("/contributionValue", hdl.GetContributionValue) // 积分中心-贡献值
  135. rPointsCenter.GET("/contributionValueFlow", hdl.GetContributionValueFlow) // 积分中心-贡献值明细
  136. rPointsCenter.GET("/record", hdl.GetEggPointRecord) // 积分中心-蛋蛋分历史记录
  137. rPointsCenter.GET("/energyFlow", hdl.GetEggEnergyFlow) // 积分中心-积分收支明细
  138. rPointsCenter.GET("/calcExchange", hdl.PointsCenterCalcExchange) // 积分中心-计算兑换
  139. }
  140. rWallet := r.Group("/wallet") // 钱包
  141. {
  142. rWallet.GET("/amountFlow", hdl.GetAmountFlow) // 余额流水
  143. rWithdraw := rWallet.Group("/withdraw")
  144. {
  145. rWithdraw.GET("/index", hdl.WithdrawGetAmount) // 查询余额
  146. rWithdraw.POST("/apply", hdl.WithdrawApply) // 发起提现申请
  147. rWithdraw.GET("/condition", hdl.GetWithdrawCondition) // 获取提现条件
  148. rWithdraw.GET("/launchBindAlipay", hdl.LaunchBindAlipayAccount) // 支付宝发起绑定请求获得 url
  149. rWithdraw.POST("/bindAlipay", hdl.BindAlipayAccount) // 绑定支付宝
  150. rWithdraw.POST("/bindWxPay", hdl.BindWxPayAccount)
  151. }
  152. }
  153. rCollege := r.Group("/college") //学院
  154. {
  155. rCollege.GET("/cate", hdl.CollegeCate) // 分类
  156. rCollege.POST("/list", hdl.CollegeList) // 文章
  157. rCollege.POST("/like/add", hdl.CollegeLikeAdd) // 文章点赞
  158. rCollege.POST("/like/cancel", hdl.CollegeLikeCancel) // 文章取消点赞
  159. rCollege.POST("/share/add", hdl.CollegeShareAdd) // 文章分享记录数量
  160. }
  161. rUserFeedback := r.Group("/userFeedback") //用户反馈
  162. {
  163. rUserFeedback.GET("/cate", hdl.UserFeedbackCate) // 分类
  164. rUserFeedback.POST("/list", hdl.UserFeedbackList) // 反馈记录
  165. rUserFeedback.POST("/record", hdl.UserFeedbackRecord) // 反馈记录-回复
  166. rUserFeedback.POST("/save", hdl.UserFeedbackSave) // 提交
  167. rUserFeedback.POST("/say", hdl.UserFeedbackSay) // 沟通
  168. }
  169. rNewUserRedPacket := r.Group("/newUserRedPacket") // 新人红包
  170. {
  171. rNewUserRedPacket.GET("/index", hdl.NewUserRedPacketInfo)
  172. }
  173. rIm := r.Group("/im")
  174. {
  175. rIm.POST("/user/sendRedPackage", hdl.SendRedPackage) // IM-发送红包
  176. rIm.POST("/user/sendRedPackageDetail", hdl.SendRedPackageDetail) // IM-发送红包详情
  177. rIm.POST("/user/grabRedPackage", hdl.GrabRedPackage) // IM-领取红包
  178. rIm.GET("/redPackageDetail", hdl.RedPackageDetail) // IM-红包详情
  179. }
  180. rFaceRealName := r.Group("/faceRealName") // 实名认证
  181. {
  182. rFaceRealName.GET("/base", hdl.GetRealNameAuthBase) //实名认证基础
  183. rFaceRealName.GET("/state", hdl.GetRealNameAuthState) //实名认证基础
  184. rFaceRealName.POST("/save", hdl.RealNameSave)
  185. }
  186. rVideo := r.Group("/video") //短视频
  187. {
  188. rVideo.GET("/base", hdl.VideoBase) //基础数据
  189. rVideo.POST("/reward", hdl.VideoReward) //奖励
  190. }
  191. rPlaylet := r.Group("/playlet") //短剧
  192. {
  193. rPlaylet.GET("/base", hdl.PlayletBase) //基础数据
  194. rPlaylet.POST("/unlockNum", hdl.PlayletUnlockNum) //基础数据
  195. rPlaylet.POST("/reward", hdl.PlayletReward) //奖励
  196. }
  197. }
  198. func rCircleFriends(r *gin.RouterGroup) {
  199. r.POST("/personalSending", friend_circle.PersonalSendingList) // 个人发送的朋友圈列表
  200. r.POST("/mySelfList", friend_circle.MySelfList) // 我的朋友圈列表
  201. r.POST("/recommendList", friend_circle.RecommendList) // 推荐列表
  202. r.POST("/commentList", friend_circle.CommentList) // 评论列表
  203. r.POST("/commentDetail", friend_circle.CommentDetail) // 评论详情
  204. r.POST("/publish", friend_circle.Publish) // 发送朋友圈
  205. r.GET("/isCanPublish", friend_circle.IsCanPublish) // 是否可以发朋友圈
  206. r.POST("/likeList", friend_circle.FriendCircleLikeList) // 点赞列表
  207. r.DELETE("/delete", friend_circle.Delete) // 删除朋友圈
  208. r.POST("/like", friend_circle.Like) // 点赞
  209. r.POST("/cancelLike", friend_circle.CancelLike) // 取消点赞
  210. r.POST("/share", friend_circle.Share) // 分享
  211. r.POST("/comment", friend_circle.Comment) // 评论
  212. r.GET("/isCanComment", friend_circle.IsCanComment) // 是否可以评论
  213. r.DELETE("/commentDelete/:comment_index_id", friend_circle.CommentDelete) // 删除评论
  214. r.GET("/commentLike", friend_circle.CommentLike) // 点赞评论
  215. r.GET("/commentCancelLike", friend_circle.CommentCancelLike) // 取消点赞评论
  216. }
  217. func rComm(r *gin.RouterGroup) {
  218. r.POST("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL
  219. r.POST("/accessRecords", comm.AccessRecords) // 访问记录
  220. }