|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- package router
-
- import (
- "applet/app/cfg"
- "applet/app/hdl"
- "applet/app/hdl/comm"
- "applet/app/hdl/friend_circle"
- "applet/app/mw"
- _ "applet/docs"
- "github.com/gin-contrib/pprof"
- "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"))
- pprof.Register(r, "/api/v1/comm/debug/pprof")
- return r
- }
-
- func route(r *gin.RouterGroup) {
- r.StaticFS("/static", http.Dir("./static"))
- r.GET("/test", hdl.Demo)
- r.GET("/test1", hdl.Demo1)
- r.Any("/createSign", hdl.CreateSign)
- r.Any("/aesDecryptByECB", hdl.AesDecryptByECB)
- r.GET("/article/html", hdl.ArticleHtml) //H5渲染的文章
- rCallback := r.Group("/callback")
- {
- rCallback.Any("/alipay/face", hdl.CallbackAlipayFace) //支付宝实名回调
- }
-
- r.Use(mw.CheckSign)
- r.Use(mw.Limiter) //进行限流
- r.Any("/testCreateSign", hdl.TestCreateSign)
- r.GET("/openApp/start", hdl.Start) //打开app调用
- r.GET("/config", hdl.Config) //基本配置
- r.GET("/version", hdl.Version) //版本数据
- r.GET("/downloadList", hdl.DownloadList) //版本数据
-
- {
- 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("/wechatRegister", hdl.WechatRegister) //注册
- r.POST("/register", hdl.Register) //注册
- r.POST("/login", hdl.Login) //登录
- r.POST("/findPassword", hdl.FindPassword) //找回密码
- r.POST("/inviteCode/userInfo", hdl.InviteCodeUserInfo) //邀请码查用户
- }
- r.POST("/college/detail", hdl.CollegeDetail) // 文章详情
- rGuidePage := r.Group("/guidePage")
- {
- rGuidePage.GET("/runningTime", hdl.GetRunningTime)
- }
-
- r.GET("/getModuleSetting", hdl.GetModuleSetting) // 获取页面样式
- r.Use(mw.Auth) // 以下接口需要JWT验证
- rCircleFriends(r.Group("/circleFriends"))
- rComm(r.Group("/comm"))
-
- rAdvertising := r.Group("/advertising") //广告
- {
- rAdvertising.POST("/check", hdl.AdvertisingCheck) //广告位判断能不能看
- rAdvertising.POST("/state", hdl.AdvertisingState) //广告位状态
- }
- 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) // 会员中心-基础数据
- rMemberCenter.POST("/bindParent", hdl.UserBindParent) //绑定上级
- rMemberCenter.POST("/bindUserInfo", hdl.BindUserInfo) //绑定用户信息
- rMemberCenter.GET("/parentInfo", hdl.ParentInfo) //上级信息
- rMemberCenter.POST("/updatePassword", hdl.UpdatePassword) //修改密码
- rMemberCenter.POST("/updatePasscode", hdl.UpdatePasscode) //修改支付密码
- rMemberCenter.GET("/inviteUrl", hdl.InviteUrl) //邀请链接
- rMemberCenter.POST("/delete", hdl.Delete) //注销账号
- rMemberCenter.GET("/delete/info", hdl.DeleteInfo) //注销账号相关信息
- }
- 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) // 积分中心-积分收支明细
- rPointsCenter.GET("/calcExchange", hdl.PointsCenterCalcExchange) // 积分中心-计算兑换
- }
- rWallet := r.Group("/wallet") // 钱包
- {
- rWallet.GET("/amountFlow", hdl.GetAmountFlow) // 余额流水
- rWithdraw := rWallet.Group("/withdraw")
- {
- rWithdraw.GET("/index", hdl.WithdrawGetAmount) // 查询余额
- rWithdraw.POST("/apply", hdl.WithdrawApply) // 发起提现申请
- rWithdraw.GET("/condition", hdl.GetWithdrawCondition) // 获取提现条件
- rWithdraw.GET("/launchBindAlipay", hdl.LaunchBindAlipayAccount) // 支付宝发起绑定请求获得 url
- rWithdraw.POST("/bindAlipay", hdl.BindAlipayAccount) // 绑定支付宝
- rWithdraw.POST("/bindWxPay", hdl.BindWxPayAccount)
- }
- }
-
- rCollege := r.Group("/college") //学院
- {
- rCollege.GET("/cate", hdl.CollegeCate) // 分类
- rCollege.POST("/list", hdl.CollegeList) // 文章
- rCollege.POST("/like/add", hdl.CollegeLikeAdd) // 文章点赞
- rCollege.POST("/like/cancel", hdl.CollegeLikeCancel) // 文章取消点赞
- rCollege.POST("/share/add", hdl.CollegeShareAdd) // 文章分享记录数量
- }
- rUserFeedback := r.Group("/userFeedback") //用户反馈
- {
- rUserFeedback.GET("/cate", hdl.UserFeedbackCate) // 分类
- rUserFeedback.POST("/list", hdl.UserFeedbackList) // 反馈记录
- rUserFeedback.POST("/record", hdl.UserFeedbackRecord) // 反馈记录-回复
- rUserFeedback.POST("/save", hdl.UserFeedbackSave) // 提交
- rUserFeedback.POST("/say", hdl.UserFeedbackSay) // 沟通
- }
-
- rNewUserRedPacket := r.Group("/newUserRedPacket") // 新人红包
- {
- rNewUserRedPacket.GET("/index", hdl.NewUserRedPacketInfo)
- }
-
- rIm := r.Group("/im")
- {
- rIm.POST("/user/sendRedPackage", hdl.SendRedPackage) // IM-发送红包
- rIm.POST("/user/sendRedPackageDetail", hdl.SendRedPackageDetail) // IM-发送红包详情
- rIm.POST("/user/grabRedPackage", hdl.GrabRedPackage) // IM-领取红包
- rIm.GET("/redPackageDetail", hdl.RedPackageDetail) // IM-红包详情
- }
-
- rFaceRealName := r.Group("/faceRealName") // 实名认证
- {
- rFaceRealName.GET("/base", hdl.GetRealNameAuthBase) //实名认证基础
- rFaceRealName.GET("/state", hdl.GetRealNameAuthState) //实名认证基础
- rFaceRealName.POST("/save", hdl.RealNameSave)
- }
- rVideo := r.Group("/video") //短视频
- {
- rVideo.GET("/base", hdl.VideoBase) //基础数据
- rVideo.POST("/reward", hdl.VideoReward) //奖励
- }
- rPlaylet := r.Group("/playlet") //短剧
- {
- rPlaylet.GET("/base", hdl.PlayletBase) //基础数据
- rPlaylet.POST("/unlockNum", hdl.PlayletUnlockNum) //基础数据
- rPlaylet.POST("/reward", hdl.PlayletReward) //奖励
- }
- }
-
- func rCircleFriends(r *gin.RouterGroup) {
- r.POST("/mySelfList", friend_circle.MySelfList) // 我的朋友圈列表
- r.POST("/recommendList", friend_circle.RecommendList) // 推荐列表
- r.POST("/commentList", friend_circle.CommentList) // 评论列表
- r.POST("/commentDetail", friend_circle.CommentDetail) // 评论详情
- r.POST("/publish", friend_circle.Publish) // 发送朋友圈
- r.GET("/isCanPublish", friend_circle.IsCanPublish) // 是否可以发朋友圈
-
- r.DELETE("/delete", friend_circle.Delete) // 删除朋友圈
- r.POST("/like", friend_circle.Like) // 点赞
- r.POST("/cancelLike", friend_circle.CancelLike) // 取消点赞
- r.POST("/share", friend_circle.Share) // 分享
-
- r.POST("/comment", friend_circle.Comment) // 评论
- r.GET("/isCanComment", friend_circle.IsCanComment) // 是否可以评论
-
- r.DELETE("/commentDelete/:comment_index_id", friend_circle.CommentDelete) // 删除评论
- r.GET("/commentLike", friend_circle.CommentLike) // 点赞评论
- r.GET("/commentCancelLike", friend_circle.CommentCancelLike) // 取消点赞评论
- }
-
- func rComm(r *gin.RouterGroup) {
- r.POST("/getOssUrl", comm.GetOssUrl) // 获取阿里云上传PutObject所需的签名URL
- r.POST("/accessRecords", comm.AccessRecords) // 访问记录
- }
|