广告平台(站长使用)
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.
 
 
 
 
 

138 satır
5.7 KiB

  1. package router
  2. import (
  3. "applet/app/cfg"
  4. "applet/app/hdl"
  5. "applet/app/mw"
  6. _ "applet/docs"
  7. "github.com/gin-gonic/gin"
  8. swaggerFiles "github.com/swaggo/files"
  9. ginSwagger "github.com/swaggo/gin-swagger"
  10. )
  11. // 初始化路由
  12. func Init() *gin.Engine {
  13. // debug, release, test 项目阶段
  14. mode := "release"
  15. if cfg.Debug {
  16. mode = "debug"
  17. }
  18. gin.SetMode(mode)
  19. //创建一个新的启动器
  20. r := gin.New()
  21. r.GET("/api/swagger/*any", func(c *gin.Context) {
  22. //r.Use(mw.SwagAuth())
  23. ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, "SWAGGER")(c)
  24. })
  25. r.Use(mw.ChangeHeader)
  26. // 是否打印访问日志, 在非正式环境都打印
  27. if mode != "release" {
  28. r.Use(gin.Logger())
  29. }
  30. r.Use(gin.Recovery())
  31. // r.Use(mw.Limiter)
  32. //r.LoadHTMLGlob("static/html/*")
  33. r.GET("/favicon.ico", func(c *gin.Context) {
  34. c.Status(204)
  35. })
  36. r.NoRoute(func(c *gin.Context) {
  37. c.JSON(404, gin.H{"code": 404, "msg": "page not found", "data": []struct{}{}})
  38. })
  39. r.NoMethod(func(c *gin.Context) {
  40. c.JSON(405, gin.H{"code": 405, "msg": "method not allowed", "data": []struct{}{}})
  41. })
  42. r.Use(mw.Cors)
  43. route(r.Group("/api"))
  44. return r
  45. }
  46. func route(r *gin.RouterGroup) {
  47. r.GET("/test", hdl.Demo)
  48. r.Use(mw.DB) // 以下接口需要用到数据库
  49. {
  50. r.POST("/login", hdl.Login)
  51. }
  52. r.Use(mw.CheckBody) //body参数转换
  53. r.Use(mw.CheckSign) //签名校验
  54. r.POST("/registerForMedium", hdl.RegisterForMedium)
  55. r.POST("/registerForAgent", hdl.RegisterForAgent)
  56. r.Use(mw.Auth) // 以下接口需要JWT验证
  57. rRole(r.Group("/role")) //权限管理
  58. rAgentQualification(r.Group("/agentQualification")) //渠道-资质
  59. rMediumQualification(r.Group("/mediumQualification")) //媒体-资质
  60. rSetCenter(r.Group("/setCenter")) //设置中心
  61. rMedium(r.Group("/medium")) //媒体中心
  62. }
  63. func rRole(r *gin.RouterGroup) {
  64. r.GET("/roleList", hdl.RoleList) //角色列表
  65. r.POST("/addRole", hdl.AddRole) //角色添加
  66. r.POST("/roleBindPermissionGroup", hdl.RoleBindPermissionGroup) //角色绑定权限组
  67. r.POST("/updateRoleState", hdl.UpdateRoleState) //修改角色状态
  68. r.POST("/updateRole", hdl.UpdateRole) //修改角色状态
  69. r.DELETE("/deleteRole/:id", hdl.DeleteRole) //删除角色
  70. r.GET("/permissionGroupList", hdl.PermissionGroupList) //权限组列表
  71. r.POST("/adminList", hdl.AdminList) //管理员列表
  72. r.POST("/updateAdminState", hdl.UpdateAdminState) //修改管理员状态
  73. r.POST("/updateAdmin", hdl.UpdateAdmin) //修改管理员信息
  74. r.POST("/addAdmin", hdl.AddAdmin) //新增管理员
  75. r.DELETE("/deleteAdmin/:adm_id", hdl.DeleteAdmin) //删除管理员
  76. r.GET("/adminInfo", hdl.AdminInfo) //获取管理员信息
  77. r.POST("/bindAdminRole", hdl.BindAdminRole) //绑定角色
  78. }
  79. func rAgentQualification(r *gin.RouterGroup) {
  80. r.POST("/enterprise", hdl.AgentQualificationEnterprise) //企业主体资质
  81. r.POST("/enterprise/audit", hdl.AgentQualificationEnterpriseAudit) //企业主体资质审核
  82. r.POST("/bank", hdl.AgentQualificationBank) //银行资质
  83. r.POST("/bank/audit", hdl.AgentQualificationBankAudit) //银行审核
  84. r.POST("/contact", hdl.AgentQualificationContactInfo) //联系方式
  85. r.POST("/contact/audit", hdl.AgentQualificationContactInfoAudit) //联系方式
  86. }
  87. func rMediumQualification(r *gin.RouterGroup) {
  88. r.POST("/enterprise", hdl.MediumQualificationEnterprise) //企业主体资质
  89. r.POST("/enterprise/audit", hdl.MediumQualificationEnterpriseAudit) //企业主体资质审核
  90. r.POST("/bank", hdl.MediumQualificationBank) //银行资质
  91. r.POST("/bank/audit", hdl.MediumQualificationBankAudit) //银行审核
  92. r.POST("/contact", hdl.MediumQualificationContactInfo) //联系方式
  93. r.POST("/contact/audit", hdl.MediumQualificationContactInfoAudit) //联系方式
  94. }
  95. func rSetCenter(r *gin.RouterGroup) {
  96. rBasicSetCenter := r.Group("/basic")
  97. {
  98. rBasicSetCenter.POST("/setOss", hdl.SetOss)
  99. rBasicSetCenter.GET("/getOss", hdl.GetOss)
  100. rBasicSetCenter.POST("/wxOpenSet", hdl.WxOpenSet)
  101. rBasicSetCenter.GET("/wxOpenGet", hdl.WxOpenGet)
  102. rBasicSetCenter.POST("/setMob", hdl.SetMob)
  103. rBasicSetCenter.GET("/getMob", hdl.GetMob)
  104. }
  105. rAppletSetCenter := r.Group("/applet")
  106. {
  107. rAppletSetCenter.GET("/list", hdl.AppletList)
  108. rAppletSetCenter.POST("/add", hdl.AppletAdd)
  109. rAppletSetCenter.POST("/update", hdl.AppletUpdate)
  110. rAppletSetCenter.DELETE("/delete/:id", hdl.AppletDelete)
  111. rAppletSetCenter.GET("/authorize", hdl.AppletAuthorize)
  112. rAppletSetCenter.GET("/unauthorized", hdl.AppletUnauthorized)
  113. }
  114. rShareSetCenter := r.Group("/share")
  115. {
  116. rShareSetCenter.GET("/index", hdl.ShareIndex)
  117. }
  118. }
  119. func rMedium(r *gin.RouterGroup) {
  120. r.POST("/applet/application/medium/list", hdl.AppletApplicationMediumList) //应用管理-媒体列表
  121. r.POST("/applet/application/list", hdl.AppletApplicationList) //小程序应用-列表数据
  122. r.POST("/applet/application/audit", hdl.AppletApplicationAudit) //小程序应用-审核
  123. r.POST("/applet/application/ad/space/medium/list", hdl.AppletApplicationAdSpaceMediumList) //广告管理-媒体列表
  124. r.POST("/applet/application/ad/space/list", hdl.AppletApplicationAdSpaceList) //小程序应用-广告位列表数据
  125. r.POST("/applet/application/ad/space/audit", hdl.AppletApplicationAdSpaceAudit) //小程序应用-广告位审核
  126. }