|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- package router
-
- import (
- "applet/app/cfg"
- "applet/app/hdl"
- "applet/app/hdl/comm"
- "applet/app/mw"
- _ "applet/docs"
- "github.com/gin-gonic/gin"
- swaggerFiles "github.com/swaggo/files"
- ginSwagger "github.com/swaggo/gin-swagger"
- "net/http"
- )
-
- // 初始化路由
- func Init() *gin.Engine {
- // debug, release, test 项目阶段
- mode := "release"
- if cfg.Debug {
- mode = "debug"
- }
- gin.SetMode(mode)
- //创建一个新的启动器
- r := gin.New()
- r.GET("/api/swagger/*any", func(c *gin.Context) {
- // r.Use(mw.SwagAuth())
- ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, "SWAGGER")(c)
- })
-
- // 是否打印访问日志, 在非正式环境都打印
- if mode != "release" {
- r.Use(gin.Logger())
- }
- r.Use(gin.Recovery())
- r.Delims("<<<", ">>>").LoadHTMLGlob("static/html/*")
-
- r.GET("/favicon.ico", func(c *gin.Context) {
- c.Status(204)
- })
- r.NoRoute(func(c *gin.Context) {
- c.JSON(404, gin.H{"code": 404, "msg": "page not found", "data": []struct{}{}})
- })
- r.NoMethod(func(c *gin.Context) {
- c.JSON(405, gin.H{"code": 405, "msg": "method not allowed", "data": []struct{}{}})
- })
- r.Use(mw.Cors)
- route(r.Group("/api/v1"))
- return r
- }
-
- func route(r *gin.RouterGroup) {
- r.StaticFS("/static", http.Dir("./static"))
- r.GET("/test", hdl.Demo)
- r.Any("/createSign", hdl.CreateSign)
- r.Any("/aesDecryptByECB", hdl.AesDecryptByECB)
- r.GET("/article/html", hdl.ArticleHtml) //H5渲染的文章
- r.Use(mw.CheckSign)
- r.Any("/testCreateSign", hdl.TestCreateSign)
- r.GET("/config", hdl.Config) //基本配置
- r.GET("/advertising", hdl.Advertising) //广告位
- r.POST("/advertising/detail", hdl.AdvertisingDetail) //广告位
- r.POST("/smsSend", hdl.SmsSend) //发送短信
- r.POST("/fastLogin", hdl.FastLogin) //一键登录
- r.POST("/wechatLogin", hdl.WechatLogin) //微信登录
- r.POST("/register", hdl.Register) //注册
- r.POST("/login", hdl.Login) //登录
- r.POST("/findPassword", hdl.FindPassword) //找回密码
- r.Use(mw.Auth) // 以下接口需要JWT验证
- rComm(r.Group("/comm"))
- r.GET("/userInfo", hdl.UserInfo) //用户基础信息
- rHomePage := r.Group("/homePage")
- {
- rHomePage.GET("/index", hdl.HomePage) // 主页
- rHomePage.GET("/adRule", hdl.HomePageWatchAdRule) // 主页-可以观看广告规则
- rHomePage.GET("/realTimePrice", hdl.RealTimePrice) // 主页-实时数据
- rHomePage.GET("/isCanSignIn", hdl.IsCanSignIn) // 主页-是否可以观看广告
- rHomePage.GET("/isCanGetRedPackage", hdl.IsCanGetRedPackage) // 主页-是否可以获得红包
- }
- rAddFriend := r.Group("/addFriend")
- {
- rAddFriend.POST("/eggEnergyDetails", hdl.EggEnergyDetails) // 添加好友-蛋蛋能量明细
- rAddFriend.POST("/eggPointDetails", hdl.EggPointDetails) // 添加好友-蛋蛋积分明细
- rAddFriend.GET("/basalRate", hdl.BasalRate) // 添加好友-基础速率
- rAddFriend.GET("/totalRate", hdl.TotalRate) // 添加好友-总速率
- rAddFriend.GET("/myFans", hdl.MyFans) // 添加好友-我的粉丝-团队速率
- rAddFriend.GET("/myFansUserList", hdl.MyFansUserList) // 添加好友-我的粉丝-好友列表
- rAddFriend.GET("/nineDimensionalSpace", hdl.NineDimensionalSpace) // 添加好友-我的粉丝-九维空间
- }
- rMemberCenter := r.Group("/memberCenter")
- {
- rMemberCenter.GET("/getBasic", hdl.MemberCenterGetBasic) // 会员中心-基础数据
- }
- rPointsCenter := r.Group("/pointsCenter") // 积分中心
- {
- rPointsCenter.GET("/basic", hdl.PointsCenterGetBasic) // 积分中心-基础信息
- rPointsCenter.GET("/initialData", hdl.InitialData) // 积分中心-初始数据
- rPointsCenter.GET("/dynamicData", hdl.DynamicData) // 积分中心-动态数据
- rPointsCenter.GET("/pointsExchangeBasic", hdl.PointsExchangeGetBasic) // 积分中心-能量兑换基础数据
- rPointsCenter.GET("/priceCurve", hdl.GetPriceCurve) // 积分中心-获取价格曲线
- rPointsCenter.POST("/exchangeEnergy", hdl.ExchangeEnergy) // 积分中心-能量兑换
- rPointsCenter.GET("/contributionValue", hdl.GetContributionValue) // 积分中心-贡献值
- rPointsCenter.GET("/contributionValueFlow", hdl.GetContributionValueFlow) // 积分中心-贡献值明细
- rPointsCenter.GET("/record", hdl.GetEggPointRecord) // 积分中心-蛋蛋分历史记录
- rPointsCenter.GET("/energyFlow", hdl.GetEggEnergyFlow) // 积分中心-积分收支明细
- }
- rWallet := r.Group("/wallet") // 钱包
- {
- rWallet.GET("/amountFlow", hdl.GetAmountFlow) // 余额流水
- }
-
- }
-
- func rComm(r *gin.RouterGroup) {
- r.GET("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL
- }
|