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

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