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

router.go 6.4 KiB

4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
4 months ago
4 months ago
4 months ago
4 months ago
3 months ago
3 months ago
4 months ago
4 months ago
4 months ago
3 months ago
3 months ago
3 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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.POST("/qiniuyun/callback", hdl.FileImgCallback) //七牛云回调
  49. r.Use(mw.DB) // 以下接口需要用到数据库
  50. {
  51. r.GET("/base", hdl.LoginBase)
  52. r.POST("/login", hdl.Login)
  53. r.POST("/login/phone", hdl.LoginPhone)
  54. r.POST("/register", hdl.Register)
  55. }
  56. r.Use(mw.CheckBody) //body参数转换
  57. r.Use(mw.CheckSign) //签名校验
  58. {
  59. r.POST("/qiniuyun/upload", hdl.ImgReqUpload) //七牛云上传
  60. r.POST("/sms", hdl.Sms) //短信发送
  61. }
  62. r.Use(mw.Auth) // 以下接口需要JWT验证
  63. rRole(r.Group("/role")) //权限管理
  64. rMedium(r.Group("/medium")) //媒体中心
  65. rAccount(r.Group("/account")) //账号中心
  66. rIndex(r.Group("/index")) //首页
  67. rDataCenter(r.Group("/dataCenter")) //数据中心
  68. rSettleCenter(r.Group("/settleCenter")) //结算中心
  69. rFinancialDynamics(r.Group("/financialDynamics")) //资产动态
  70. rSetCenter(r.Group("/setCenter")) //基本配置
  71. }
  72. func rRole(r *gin.RouterGroup) {
  73. r.GET("/roleList", hdl.RoleList) //角色列表
  74. r.POST("/addRole", hdl.AddRole) //角色添加
  75. r.POST("/roleBindPermissionGroup", hdl.RoleBindPermissionGroup) //角色绑定权限组
  76. r.POST("/updateRoleState", hdl.UpdateRoleState) //修改角色状态
  77. r.POST("/updateRole", hdl.UpdateRole) //修改角色状态
  78. r.DELETE("/deleteRole/:id", hdl.DeleteRole) //删除角色
  79. r.GET("/permissionGroupList", hdl.PermissionGroupList) //权限组列表
  80. r.POST("/adminList", hdl.AdminList) //管理员列表
  81. r.POST("/updateAdminState", hdl.UpdateAdminState) //修改管理员状态
  82. r.POST("/updateAdmin", hdl.UpdateAdmin) //修改管理员信息
  83. r.POST("/addAdmin", hdl.AddAdmin) //新增管理员
  84. r.DELETE("/deleteAdmin/:adm_id", hdl.DeleteAdmin) //删除管理员
  85. r.GET("/adminInfo", hdl.AdminInfo) //获取管理员信息
  86. r.POST("/bindAdminRole", hdl.BindAdminRole) //绑定角色
  87. }
  88. func rMedium(r *gin.RouterGroup) {
  89. r.POST("/list", hdl.MediumList) //媒体列表
  90. }
  91. func rAccount(r *gin.RouterGroup) {
  92. r.GET("/base", hdl.AccountBase) //账号信息
  93. r.POST("/update/password", hdl.AccountUpdatePassword) //账号信息-修改密码
  94. r.GET("/qualification/info", hdl.QualificationInfo) //资质认证-基本信息
  95. r.GET("/qualification/select/base", hdl.QualificationSelectBase) //资质认证-认证选择内容
  96. r.POST("/qualification/enterprise/save", hdl.QualificationEnterpriseSave) //资质认证-企业认证保存
  97. r.POST("/qualification/bank/save", hdl.QualificationBankSave) //资质认证-银行资质保存
  98. r.POST("/qualification/contact/save", hdl.QualificationContactSave) //资质认证-联系方式保存
  99. }
  100. func rSetCenter(r *gin.RouterGroup) {
  101. rShareSetCenter := r.Group("/share")
  102. {
  103. rShareSetCenter.GET("/index", hdl.ShareIndex)
  104. }
  105. }
  106. func rIndex(r *gin.RouterGroup) {
  107. r.GET("/base", hdl.Base) //首页-基本信息
  108. r.GET("/total", hdl.IndexTotal) //首页-统计数据
  109. r.POST("/app/list", hdl.IndexAppList) //首页-应用数据
  110. }
  111. func rDataCenter(r *gin.RouterGroup) {
  112. r.GET("/select/data", hdl.DataCenterSelectData) //数据中心-筛选条件
  113. r.POST("/record/total", hdl.DataCenterRecordTotal) //数据中心-数据明细合计
  114. r.POST("/record/list", hdl.DataCenterRecordList) //数据中心-数据明细
  115. r.POST("/record/output", hdl.DataCenterRecordOutPut) //数据中心-数据明细-导出
  116. r.POST("/commission/record/total", hdl.DataCenterCommissionRecordTotal) //数据中心-佣金收益明细合计
  117. r.POST("/commission/record/list", hdl.DataCenterCommissionRecordList) //数据中心-佣金收益明细
  118. r.POST("/commission/record/output", hdl.DataCenterCommissionRecordOutPut) //数据中心-佣金收益明细-导出
  119. r.POST("/profit/record/list", hdl.DataCenterProfitRecordList) //数据中心-分润收益明细
  120. r.POST("/profit/record/output", hdl.DataCenterProfitRecordOutPut) //数据中心-分润收益明细-导出
  121. }
  122. func rSettleCenter(r *gin.RouterGroup) {
  123. r.POST("/medium/list", hdl.SettleCenterMediumList) //结算中心-媒体结算报表
  124. r.POST("/agent/list", hdl.SettleCenterList) //结算中心-渠道个人结算报表
  125. r.POST("/agent/detail", hdl.SettleCenterDetail) //结算中心-渠道个人结算报表-详情
  126. r.POST("/agent/settle/file/save", hdl.SettleCenterSettleFileSave) //结算中心-渠道个人结算报表-结算单上传
  127. r.POST("/agent/invoice/save", hdl.SettleCenterInvoiceSave) //结算中心-渠道个人结算报表-发票上传
  128. }
  129. func rFinancialDynamics(r *gin.RouterGroup) {
  130. r.POST("/agent/total", hdl.FinancialDynamicsAgentTotal) //资产动态-代理预付统计
  131. r.POST("/agent/list", hdl.FinancialDynamicsAgentList) //资产动态-代理预付
  132. }