智盟项目
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.

110 lines
3.2 KiB

  1. package router
  2. import (
  3. "applet/app/cfg"
  4. "applet/app/hdl"
  5. internalHdl "applet/app/hdl/zhimeng_internal"
  6. platformHdl "applet/app/hdl/zhimeng_platform"
  7. "applet/app/mw"
  8. "github.com/gin-gonic/gin"
  9. )
  10. // 初始化路由
  11. func Init() *gin.Engine {
  12. // debug, release, test 项目阶段
  13. mode := "release"
  14. if cfg.Debug {
  15. mode = "debug"
  16. }
  17. gin.SetMode(mode)
  18. //创建一个新的启动器
  19. r := gin.New()
  20. r.Use(mw.ChangeHeader)
  21. // 是否打印访问日志, 在非正式环境都打印
  22. if mode != "release" {
  23. r.Use(gin.Logger())
  24. }
  25. r.Use(gin.Recovery())
  26. // r.Use(mw.Limiter)
  27. //r.LoadHTMLGlob("static/html/*")
  28. r.GET("/favicon.ico", func(c *gin.Context) {
  29. c.Status(204)
  30. })
  31. r.NoRoute(func(c *gin.Context) {
  32. c.JSON(404, gin.H{"code": 404, "msg": "page not found", "data": []struct{}{}})
  33. })
  34. r.NoMethod(func(c *gin.Context) {
  35. c.JSON(405, gin.H{"code": 405, "msg": "method not allowed", "data": []struct{}{}})
  36. })
  37. r.Use(mw.Cors)
  38. routeInternal(r.Group("/api/internal"))
  39. routeZhimeng(r.Group("/api/admin"))
  40. return r
  41. }
  42. func routeInternal(r *gin.RouterGroup) {
  43. r.Use(mw.DB) // 以下接口需要用到数据库
  44. {
  45. r.POST("/playlet_order", internalHdl.GetPlayletOrder)
  46. r.POST("/hw_order", internalHdl.GetHwOrder)
  47. r.POST("/playlet_short_link", internalHdl.GetShortLink)
  48. }
  49. r.Use(mw.Checker) // 以下接口需要检查Header: platform
  50. {
  51. }
  52. r.Use(mw.Auth) // 以下接口需要JWT验证
  53. {
  54. }
  55. }
  56. func routeZhimeng(r *gin.RouterGroup) {
  57. r.POST("kuaishou/auth", hdl.KuaishouAuth)
  58. r.GET("/test", hdl.Order)
  59. r.GET("/cinema", hdl.Cinema)
  60. r.GET("/task", hdl.TikTokTask)
  61. r.POST("/bihai_file_new", hdl.BihaiFile)
  62. r.GET("/bihai_add", hdl.BihaiAdds)
  63. r.GET("/bihai_story_add", hdl.BihaiStoryAdd)
  64. r.GET("/beiwo_story_add", hdl.BeiwoStoryAdd)
  65. r.GET("/kujiang_add", hdl.KujiangAdd)
  66. r.POST("/file_new", hdl.File)
  67. r.POST("/file_new1", hdl.FileNew)
  68. r.POST("/file_old", hdl.FileTwo)
  69. r.POST("/file_old1", hdl.FileTwoNew)
  70. r.POST("/file_second", hdl.FileSecond)
  71. r.POST("/file_down", hdl.FileDown)
  72. r.POST("/file_down1", hdl.FileDownNew)
  73. r.GET("/authorizationCode", hdl.GetAuthorizationCode)
  74. r.GET("/token", hdl.GetToken)
  75. r.POST("/rToken", hdl.RefreshToken)
  76. r.POST("/file/upload/token", mw.InitReqValidator, hdl.ImgReqUpload) // 文件上传获取七牛云上传token
  77. r.POST("/file/upload/callback", hdl.FileImgCallback) // 文件上传回调
  78. r.Use(mw.AuthJWT, mw.RequestCache) // 以下接口需要JWT验证
  79. {
  80. r.POST("/order_list", platformHdl.OrderList)
  81. r.POST("/order_output", platformHdl.OrderOutput)
  82. r.POST("/:pvd/order_list", platformHdl.NewOrderList)
  83. r.POST("/:pvd/order_output", platformHdl.NewOrderOutput)
  84. //r.POST("/hw_order_list", platformHdl.HwOrderList)
  85. //r.POST("/hw_order_output", platformHdl.HwOrderOutput)
  86. //r.POST("/guide_order_list", platformHdl.GuideOrderList)
  87. //r.POST("/guide_order_output", platformHdl.GuideOrderOutput)
  88. r.POST("/withdrawal_income", platformHdl.WithdrawalIncome)
  89. r.POST("/withdrawal_bind_alipay", platformHdl.WithdrawalBindAlipay)
  90. r.GET("/sms", platformHdl.Sms)
  91. r.POST("/withdrawal_list", platformHdl.WithdrawalList)
  92. r.POST("/withdrawal_doing", platformHdl.WithdrawalDoing)
  93. r.POST("/withdrawal_output", platformHdl.WithdrawalOutput)
  94. r.POST("/withdrawal_invoice_img", platformHdl.WithdrawalInvoiceImg)
  95. }
  96. }