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

199 lines
10 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.GET("/authorize", hdl.AppletAuthorize)
  49. r.Use(mw.DB) // 以下接口需要用到数据库
  50. {
  51. r.POST("/login", hdl.Login)
  52. }
  53. r.Use(mw.CheckBody) //body参数转换
  54. r.Use(mw.CheckSign) //签名校验
  55. r.POST("/registerForMedium", hdl.RegisterForMedium)
  56. r.POST("/registerForAgent", hdl.RegisterForAgent)
  57. r.Use(mw.Auth) // 以下接口需要JWT验证
  58. rRole(r.Group("/role")) //权限管理
  59. rQualification(r.Group("/qualification")) //资质认证公共数据
  60. rAgentQualification(r.Group("/agentQualification")) //渠道-资质
  61. rMediumQualification(r.Group("/mediumQualification")) //媒体-资质
  62. rSetCenter(r.Group("/setCenter")) //设置中心
  63. rMedium(r.Group("/mediumCenter")) //媒体中心
  64. rDivisionStrategy(r.Group("/divisionStrategy")) //分成策略
  65. rDataCenter(r.Group("/dataCenter")) //数据中心
  66. rSettleCenter(r.Group("/settleCenter")) //结算中心
  67. rFinanceCenter(r.Group("/financeCenter")) //财务中心
  68. }
  69. func rRole(r *gin.RouterGroup) {
  70. r.GET("/roleList", hdl.RoleList) //角色列表
  71. r.POST("/addRole", hdl.AddRole) //角色添加
  72. r.POST("/roleBindPermissionGroup", hdl.RoleBindPermissionGroup) //角色绑定权限组
  73. r.POST("/updateRoleState", hdl.UpdateRoleState) //修改角色状态
  74. r.POST("/updateRole", hdl.UpdateRole) //修改角色状态
  75. r.DELETE("/deleteRole/:id", hdl.DeleteRole) //删除角色
  76. r.GET("/permissionGroupList", hdl.PermissionGroupList) //权限组列表
  77. r.POST("/adminList", hdl.AdminList) //管理员列表
  78. r.POST("/updateAdminState", hdl.UpdateAdminState) //修改管理员状态
  79. r.POST("/updateAdmin", hdl.UpdateAdmin) //修改管理员信息
  80. r.POST("/addAdmin", hdl.AddAdmin) //新增管理员
  81. r.DELETE("/deleteAdmin/:adm_id", hdl.DeleteAdmin) //删除管理员
  82. r.GET("/adminInfo", hdl.AdminInfo) //获取管理员信息
  83. r.POST("/bindAdminRole", hdl.BindAdminRole) //绑定角色
  84. }
  85. func rQualification(r *gin.RouterGroup) {
  86. r.GET("/select/base", hdl.QualificationSelectBase) //资质认证-认证选择内容
  87. }
  88. func rAgentQualification(r *gin.RouterGroup) {
  89. r.POST("/enterprise", hdl.AgentQualificationEnterprise) //企业主体资质
  90. r.POST("/enterprise/audit", hdl.AgentQualificationEnterpriseAudit) //企业主体资质审核
  91. r.POST("/bank", hdl.AgentQualificationBank) //银行资质
  92. r.POST("/bank/audit", hdl.AgentQualificationBankAudit) //银行审核
  93. r.POST("/contact", hdl.AgentQualificationContactInfo) //联系方式
  94. r.POST("/contact/audit", hdl.AgentQualificationContactInfoAudit) //联系方式
  95. }
  96. func rMediumQualification(r *gin.RouterGroup) {
  97. r.POST("/enterprise", hdl.MediumQualificationEnterprise) //企业主体资质
  98. r.POST("/enterprise/audit", hdl.MediumQualificationEnterpriseAudit) //企业主体资质审核
  99. r.POST("/bank", hdl.MediumQualificationBank) //银行资质
  100. r.POST("/bank/audit", hdl.MediumQualificationBankAudit) //银行审核
  101. r.POST("/contact", hdl.MediumQualificationContactInfo) //联系方式
  102. r.POST("/contact/audit", hdl.MediumQualificationContactInfoAudit) //联系方式
  103. }
  104. func rSetCenter(r *gin.RouterGroup) {
  105. rBasicSetCenter := r.Group("/basic")
  106. {
  107. rBasicSetCenter.POST("/setOss", hdl.SetOss)
  108. rBasicSetCenter.GET("/getOss", hdl.GetOss)
  109. rBasicSetCenter.POST("/wxOpenSet", hdl.WxOpenSet)
  110. rBasicSetCenter.GET("/wxOpenGet", hdl.WxOpenGet)
  111. rBasicSetCenter.POST("/setMob", hdl.SetMob)
  112. rBasicSetCenter.GET("/getMob", hdl.GetMob)
  113. }
  114. rAppletSetCenter := r.Group("/applet")
  115. {
  116. rAppletSetCenter.GET("/list", hdl.AppletList)
  117. rAppletSetCenter.POST("/add", hdl.AppletAdd)
  118. rAppletSetCenter.POST("/update", hdl.AppletUpdate)
  119. rAppletSetCenter.DELETE("/delete/:id", hdl.AppletDelete)
  120. rAppletSetCenter.GET("/authorize", hdl.AppletAuthorize)
  121. rAppletSetCenter.GET("/unauthorized", hdl.AppletUnauthorized)
  122. }
  123. rShareSetCenter := r.Group("/share")
  124. {
  125. rShareSetCenter.GET("/index", hdl.ShareIndex)
  126. }
  127. }
  128. func rMedium(r *gin.RouterGroup) {
  129. r.POST("/applet/application/medium/list", hdl.AppletApplicationMediumList) //应用管理-媒体列表
  130. r.POST("/applet/application/list", hdl.AppletApplicationList) //小程序应用-列表数据
  131. r.POST("/applet/application/audit", hdl.AppletApplicationAudit) //小程序应用-审核
  132. r.POST("/applet/application/ad/space/medium/list", hdl.AppletApplicationAdSpaceMediumList) //广告管理-媒体列表
  133. r.POST("/applet/application/ad/space/list", hdl.AppletApplicationAdSpaceList) //小程序应用-广告位列表数据
  134. r.POST("/applet/application/ad/space/audit", hdl.AppletApplicationAdSpaceAudit) //小程序应用-广告位审核
  135. r.POST("/medium/list", hdl.MediumList) //媒体列表
  136. r.POST("/medium/bind/agent/list", hdl.MediumBindAgentList) //媒体绑定代理列表
  137. r.POST("/medium/bind/agent/save", hdl.MediumBindAgentSave) //媒体绑定代理操作
  138. r.POST("/medium/bind/agent/del", hdl.MediumBindAgentDel) //媒体绑定代理删除
  139. r.POST("/agent/list", hdl.AgentList) //代理列表
  140. r.POST("/agent/bind/medium/list", hdl.AgentBindMediumList) //代理绑定媒体列表
  141. }
  142. func rDivisionStrategy(r *gin.RouterGroup) {
  143. r.POST("/list", hdl.DivisionStrategyList) //分成策略-列表
  144. r.POST("/detail", hdl.DivisionStrategyDetail) //分成策略-详情
  145. r.POST("/save", hdl.DivisionStrategySave) //分成策略-保存
  146. }
  147. func rDataCenter(r *gin.RouterGroup) {
  148. r.POST("/original/data/list", hdl.OriginalDataList) //数据中心-原始数据
  149. r.POST("/original/data/del", hdl.OriginalDataDel) //数据中心-原始数据-删除
  150. r.POST("/original/data/total", hdl.OriginalDataTotal) //数据中心-原始数据-记录应用时统计
  151. r.POST("/original/data/doing", hdl.OriginalDataDoing) //数据中心-原始数据-记录应用时操作
  152. r.POST("/original/data/more/application", hdl.OriginalDataMoreApplication) //数据中心-原始数据-一键导入应用列表
  153. r.POST("/original/data/more/application/doing", hdl.OriginalDataMoreApplicationDoing) //数据中心-原始数据-一键导入操作
  154. r.POST("/original/data/more/application/state", hdl.OriginalDataMoreApplicationState) //数据中心-原始数据-一键导入操作后的完成状态
  155. r.GET("/original/data/one/application", hdl.OriginalDataOneApplication) //数据中心-原始数据-单个导入应用列表
  156. r.POST("/original/data/one/application/ad/list", hdl.OriginalDataOneApplicationAdList) //数据中心-原始数据-单个导入应用-广告位列表
  157. r.POST("/original/data/one/application/total", hdl.OriginalDataOneApplicationTotal) //数据中心-原始数据-单个应用数据统计
  158. r.POST("/original/data/one/application/doing", hdl.OriginalDataOneApplicationDoing) //数据中心-原始数据-单个应用数据操作
  159. r.POST("/generate/data/list", hdl.GenerateDataList) //数据中心-分成数据
  160. r.POST("/generate/data/del", hdl.GenerateDataDel) //数据中心-分成数据-删除
  161. r.POST("/generate/data/detail", hdl.GenerateDataDetail) //数据中心-分成数据-详情
  162. r.POST("/generate/data/doing", hdl.GenerateDataDoing) //数据中心-分成数据-报表生成操作
  163. r.POST("/income/data/list", hdl.IncomeDataList) //数据中心-收益报表
  164. r.POST("/income/data/detail", hdl.IncomeDataDetail) //数据中心-收益报表-详情
  165. }
  166. func rSettleCenter(r *gin.RouterGroup) {
  167. r.POST("/medium/list", hdl.SettleCenterMediumList) //结算中心-媒体列表
  168. r.POST("/medium/save", hdl.SettleCenterMediumSave) //结算中心-媒体修复结算方式
  169. r.POST("/medium/detail", hdl.SettleCenterMediumDetail) //结算中心-媒体结算详情
  170. r.POST("/agent/list", hdl.SettleCenterAgentList) //结算中心-代理列表
  171. r.POST("/agent/save", hdl.SettleCenterAgentSave) //结算中心-代理修复结算方式
  172. r.POST("/agent/detail", hdl.SettleCenterAgentDetail) //结算中心-代理结算详情
  173. }
  174. func rFinanceCenter(r *gin.RouterGroup) {
  175. r.POST("/medium/list", hdl.FinanceCenterMediumList) //财务中心-媒体列表
  176. r.POST("/medium/detail", hdl.FinanceCenterMediumDetail) //财务中心-媒体详情
  177. r.POST("/medium/settle/file/save", hdl.FinanceCenterMediumSettleFileSave) //财务中心-媒体详情-结算单上传
  178. r.POST("/medium/invoice/save", hdl.FinanceCenterMediumInvoiceSave) //财务中心-媒体详情-发票审核
  179. r.POST("/medium/other/income/save", hdl.FinanceCenterMediumOtherIncomeSave) //财务中心-媒体详情-其他收益调整
  180. r.POST("/medium/pay/save", hdl.FinanceCenterMediumPaySave) //财务中心-媒体详情-确认支付
  181. }