蛋蛋星球-客户端
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 
 
 
 

90 satır
3.1 KiB

  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. )
  12. // 初始化路由
  13. func Init() *gin.Engine {
  14. // debug, release, test 项目阶段
  15. mode := "release"
  16. if cfg.Debug {
  17. mode = "debug"
  18. }
  19. gin.SetMode(mode)
  20. //创建一个新的启动器
  21. r := gin.New()
  22. r.GET("/api/swagger/*any", func(c *gin.Context) {
  23. // r.Use(mw.SwagAuth())
  24. ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, "SWAGGER")(c)
  25. })
  26. // 是否打印访问日志, 在非正式环境都打印
  27. if mode != "release" {
  28. r.Use(gin.Logger())
  29. }
  30. r.Use(gin.Recovery())
  31. r.GET("/favicon.ico", func(c *gin.Context) {
  32. c.Status(204)
  33. })
  34. r.NoRoute(func(c *gin.Context) {
  35. c.JSON(404, gin.H{"code": 404, "msg": "page not found", "data": []struct{}{}})
  36. })
  37. r.NoMethod(func(c *gin.Context) {
  38. c.JSON(405, gin.H{"code": 405, "msg": "method not allowed", "data": []struct{}{}})
  39. })
  40. r.Use(mw.Cors)
  41. route(r.Group("/api/v1"))
  42. return r
  43. }
  44. func route(r *gin.RouterGroup) {
  45. r.GET("/test", hdl.Demo)
  46. r.Any("/createSign", hdl.CreateSign)
  47. r.Any("/aesDecryptByECB", hdl.AesDecryptByECB)
  48. r.Use(mw.CheckSign)
  49. r.Any("/testCreateSign", hdl.TestCreateSign)
  50. r.POST("/smsSend", hdl.SmsSend) //发送短信
  51. r.POST("/fastLogin", hdl.FastLogin) //一键登录
  52. r.POST("/register", hdl.Register) //注册
  53. r.POST("/login", hdl.Login) //登录
  54. r.Use(mw.Auth) // 以下接口需要JWT验证
  55. rComm(r.Group("/comm"))
  56. r.GET("/userInfo", hdl.UserInfo) //用户基础信息
  57. rHomePage := r.Group("/homePage")
  58. {
  59. rHomePage.GET("/index", hdl.HomePage) // 主页
  60. rHomePage.GET("/adRule", hdl.HomePageWatchAdRule) // 主页-可以观看广告列表
  61. rHomePage.GET("/realTimePrice", hdl.RealTimePrice) // 主页-实时数据
  62. rHomePage.GET("/isCanSignIn", hdl.IsCanSignIn) // 主页-是否可以观看广告
  63. rHomePage.GET("/isCanGetRedPackage", hdl.IsCanGetRedPackage) // 主页-是否可以获得红包
  64. }
  65. rAddFriend := r.Group("/addFriend")
  66. {
  67. rAddFriend.POST("/eggEnergyDetails", hdl.EggEnergyDetails) // 添加好友-蛋蛋能量明细
  68. rAddFriend.POST("/eggPointDetails", hdl.EggPointDetails) // 添加好友-蛋蛋积分明细
  69. rAddFriend.GET("/basalRate", hdl.BasalRate) // 添加好友-基础速率
  70. rAddFriend.GET("/totalRate", hdl.TotalRate) // 添加好友-总速率
  71. rAddFriend.GET("/myFans", hdl.MyFans) // 添加好友-我的粉丝-团队速率
  72. rAddFriend.GET("/myFansUserList", hdl.MyFansUserList) // 添加好友-我的粉丝-好友列表
  73. rAddFriend.GET("/nineDimensionalSpace", hdl.NineDimensionalSpace) // 添加好友-我的粉丝-九维空间
  74. }
  75. rMemberCenter := r.Group("/memberCenter")
  76. {
  77. rMemberCenter.GET("/getBasic", hdl.MemberCenterGetBasic) // 会员中心-基础数据
  78. }
  79. }
  80. func rComm(r *gin.RouterGroup) {
  81. r.GET("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL
  82. }