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

100 lines
3.8 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("/wechatLogin", hdl.WechatLogin) //微信登录
  53. r.POST("/register", hdl.Register) //注册
  54. r.POST("/login", hdl.Login) //登录
  55. r.POST("/findPassword", hdl.FindPassword) //找回密码
  56. r.Use(mw.Auth) // 以下接口需要JWT验证
  57. rComm(r.Group("/comm"))
  58. r.GET("/userInfo", hdl.UserInfo) //用户基础信息
  59. rHomePage := r.Group("/homePage")
  60. {
  61. rHomePage.GET("/index", hdl.HomePage) // 主页
  62. rHomePage.GET("/adRule", hdl.HomePageWatchAdRule) // 主页-可以观看广告规则
  63. rHomePage.GET("/realTimePrice", hdl.RealTimePrice) // 主页-实时数据
  64. rHomePage.GET("/isCanSignIn", hdl.IsCanSignIn) // 主页-是否可以观看广告
  65. rHomePage.GET("/isCanGetRedPackage", hdl.IsCanGetRedPackage) // 主页-是否可以获得红包
  66. }
  67. rAddFriend := r.Group("/addFriend")
  68. {
  69. rAddFriend.POST("/eggEnergyDetails", hdl.EggEnergyDetails) // 添加好友-蛋蛋能量明细
  70. rAddFriend.POST("/eggPointDetails", hdl.EggPointDetails) // 添加好友-蛋蛋积分明细
  71. rAddFriend.GET("/basalRate", hdl.BasalRate) // 添加好友-基础速率
  72. rAddFriend.GET("/totalRate", hdl.TotalRate) // 添加好友-总速率
  73. rAddFriend.GET("/myFans", hdl.MyFans) // 添加好友-我的粉丝-团队速率
  74. rAddFriend.GET("/myFansUserList", hdl.MyFansUserList) // 添加好友-我的粉丝-好友列表
  75. rAddFriend.GET("/nineDimensionalSpace", hdl.NineDimensionalSpace) // 添加好友-我的粉丝-九维空间
  76. }
  77. rMemberCenter := r.Group("/memberCenter")
  78. {
  79. rMemberCenter.GET("/getBasic", hdl.MemberCenterGetBasic) // 会员中心-基础数据
  80. }
  81. rPointsCenter := r.Group("/pointsCenter") // 积分中心
  82. {
  83. rPointsCenter.GET("/getBasic", hdl.PointsCenterGetBasic) // 积分中-基础数据
  84. rPointsCenter.GET("/priceCurve", hdl.GetPriceCurve) // 积分中心-获取价格曲线
  85. rPointsCenter.POST("/exchangeEnergy", hdl.ExchangeEnergy) // 积分中心-能量兑换
  86. rPointsCenter.GET("/contributionValue", hdl.GetContributionValue) // 积分中心-贡献值
  87. rPointsCenter.GET("/contributionValueFlow", hdl.GetContributionValueFlow) // 积分中心-贡献值明细
  88. }
  89. }
  90. func rComm(r *gin.RouterGroup) {
  91. r.GET("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL
  92. }