广告平台(站长使用)
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

router.go 17 KiB

há 4 meses
há 1 mês
há 1 mês
há 4 meses
há 4 meses
há 4 meses
há 2 meses
há 4 meses
há 4 meses
há 2 meses
há 4 meses
há 1 mês
há 1 mês
há 1 mês
há 1 mês
há 1 mês
há 1 mês
há 1 mês
há 1 mês
há 1 mês
há 1 mês
há 4 meses
há 2 meses
há 4 meses
há 4 meses
há 4 meses
há 1 mês
há 2 meses
há 3 meses
há 1 mês
há 4 meses
há 4 meses
há 2 meses
há 4 meses
há 2 meses
há 3 meses
há 4 meses
há 4 meses
há 2 meses
há 2 meses
há 2 meses
há 2 meses
há 2 meses
há 2 meses
há 4 meses
há 2 meses
há 2 meses
há 2 meses
há 3 meses
há 2 meses
há 3 meses
há 2 meses
há 4 meses
há 2 meses
há 1 mês
há 1 mês
há 4 meses
há 2 meses
há 4 meses
há 2 meses
há 2 meses
há 4 meses
há 2 meses
há 4 meses
há 2 meses
há 2 meses
há 4 meses
há 2 meses
há 4 meses
há 3 meses
há 2 meses
há 4 meses
há 2 meses
há 2 meses
há 4 meses
há 2 meses
há 2 meses
há 2 meses
há 2 meses
há 2 meses
há 2 meses
há 4 meses
há 2 meses
há 2 meses
há 3 meses
há 2 meses
há 3 meses
há 2 meses
há 3 meses
há 2 meses
há 1 mês
há 1 mês
há 3 meses
há 2 meses
há 3 meses
há 2 meses
há 3 meses
há 2 meses
há 3 meses
há 2 meses
há 3 meses
há 2 meses
há 3 meses
há 3 meses
há 2 meses
há 3 meses
há 2 meses
há 3 meses
há 2 meses
há 3 meses
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. package router
  2. import (
  3. "applet/app/cfg"
  4. "applet/app/hdl"
  5. "applet/app/mw"
  6. _ "applet/docs"
  7. "fmt"
  8. "github.com/gin-contrib/cors"
  9. "github.com/gin-gonic/gin"
  10. swaggerFiles "github.com/swaggo/files"
  11. ginSwagger "github.com/swaggo/gin-swagger"
  12. )
  13. // 初始化路由
  14. func Init() *gin.Engine {
  15. // debug, release, test 项目阶段
  16. mode := "release"
  17. if cfg.Debug {
  18. mode = "debug"
  19. }
  20. gin.SetMode(mode)
  21. // 创建一个新的启动器
  22. r := gin.New()
  23. r.GET("/api/swagger/*any", func(c *gin.Context) {
  24. // r.Use(mw.SwagAuth())
  25. ginSwagger.DisablingWrapHandler(swaggerFiles.Handler, "SWAGGER")(c)
  26. })
  27. // TODO::指定open的文档的位置
  28. // 设置静态文件服务,提供 group2.json 文件
  29. r.Static("/api/api-docs", "./docs")
  30. r.GET("/api/open/swagger/*any", gin.BasicAuth(gin.Accounts{
  31. "jihuoniao": "123123",
  32. }), func(c *gin.Context) {
  33. requestTls := "http://"
  34. if c.Request.TLS != nil {
  35. requestTls = "https://"
  36. }
  37. r.Use(mw.SwagAuth())
  38. r.Use(cors.Default())
  39. fmt.Println(requestTls + c.GetHeader("Real-Host") + "/api/api-docs/open.json")
  40. if c.GetHeader("Real-Host") != "" {
  41. ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.URL(requestTls+c.GetHeader("Real-Host")+"/api/api-docs/open.json"))(c)
  42. } else {
  43. ginSwagger.WrapHandler(swaggerFiles.Handler, ginSwagger.URL(requestTls+c.Request.Host+"/api/api-docs/open.json"))(c)
  44. }
  45. })
  46. r.Use(mw.ChangeHeader)
  47. // 是否打印访问日志, 在非正式环境都打印
  48. if mode != "release" {
  49. r.Use(gin.Logger())
  50. }
  51. r.Use(gin.Recovery())
  52. // r.Use(mw.Limiter)
  53. // r.LoadHTMLGlob("static/html/*")
  54. r.GET("/favicon.ico", func(c *gin.Context) {
  55. c.Status(204)
  56. })
  57. r.NoRoute(func(c *gin.Context) {
  58. c.JSON(404, gin.H{"code": 404, "msg": "page not found", "data": []struct{}{}})
  59. })
  60. r.NoMethod(func(c *gin.Context) {
  61. c.JSON(405, gin.H{"code": 405, "msg": "method not allowed", "data": []struct{}{}})
  62. })
  63. r.Use(mw.Cors)
  64. route(r.Group("/api"))
  65. return r
  66. }
  67. func route(r *gin.RouterGroup) {
  68. r.GET("/test", hdl.Demo)
  69. r.GET("/test1", hdl.Demo1)
  70. r.GET("/getAuthToken", hdl.GetAuthToken)
  71. r.GET("/authorize", hdl.AppletAuthorize)
  72. r.POST("/qiniuyun/callback", hdl.FileImgCallback) // 七牛云回调
  73. r.GET("/medium/settle/file/down", hdl.SettleCenterSettleFileDown) //结算中心-结算报表-结算单下载
  74. r.GET("/agent/settle/file/down", hdl.AgentSettleCenterSettleFileDown) //结算中心-结算报表-结算单下载
  75. r.Use(mw.DB) // 以下接口需要用到数据库
  76. {
  77. r.POST("/login", hdl.Login)
  78. r.GET("/base", hdl.LoginBase)
  79. }
  80. r.Use(mw.CheckBody) // body参数转换
  81. r.Use(mw.CheckSign) // 签名校验
  82. r.POST("/qiniuyun/upload", hdl.ImgReqUpload) // 七牛云上传
  83. r.POST("/registerForMedium", hdl.RegisterForMedium)
  84. r.POST("/registerForAgent", hdl.RegisterForAgent)
  85. r.Use(mw.Auth) // 以下接口需要JWT验证
  86. rComm(r.Group("/comm"))
  87. r.Use(mw.CheckPermission) // 检测权限
  88. rRole(r.Group("/role")) // 权限管理
  89. rAgentQualification(r.Group("/agentQualification")) // 渠道-资质
  90. rMediumQualification(r.Group("/mediumQualification")) // 媒体-资质
  91. rSetCenter(r.Group("/setCenter")) // 设置中心
  92. rMedium(r.Group("/mediumCenter")) // 媒体中心
  93. rAssociationCenter(r.Group("/associationCenter")) // 关联中心
  94. rDivisionStrategy(r.Group("/divisionStrategy")) // 分成策略
  95. rDataCenter(r.Group("/dataCenter")) // 数据中心
  96. rSettleCenter(r.Group("/settleCenter")) // 结算中心
  97. rFinanceCenter(r.Group("/financeCenter")) // 财务中心
  98. rIndex(r.Group("/index")) // 默认首页 超管看
  99. rOperatorIndex(r.Group("/operatorIndex")) // 运营首页
  100. rFinanceIndex(r.Group("/financeIndex")) // 财务首页
  101. rFinancialDynamics(r.Group("/financialDynamics")) // 资产动态
  102. }
  103. func rComm(r *gin.RouterGroup) {
  104. r.POST("/getMenuList", hdl.MenuList) // 获取菜单栏列表
  105. r.GET("/base", hdl.Base) // 基本信息
  106. }
  107. func rIndex(r *gin.RouterGroup) {
  108. r.GET("/total", hdl.IndexTotal) // 首页-统计数据
  109. r.POST("/app/list", hdl.IndexAppList) // 首页-应用数据
  110. r.POST("/app/list/table", hdl.IndexAppListTable) // 首页-应用数据-每个应用的折线图
  111. }
  112. func rOperatorIndex(r *gin.RouterGroup) {
  113. r.GET("/total", hdl.OperatorIndexTotal) // 首页-统计数据
  114. r.POST("/app/list", hdl.OperatorIndexAppList) // 首页-应用数据
  115. r.POST("/app/list/table", hdl.OperatorIndexAppListTable) // 首页-应用数据-每个应用的折线图
  116. }
  117. func rFinanceIndex(r *gin.RouterGroup) {
  118. r.GET("/total", hdl.FinanceIndexTotal) // 首页-统计数据
  119. r.POST("/app/list", hdl.FinanceIndexAppList) // 首页-应用数据
  120. r.POST("/app/list/table", hdl.FinanceIndexAppListTable) // 首页-应用数据-每个应用的折线图
  121. }
  122. func rRole(r *gin.RouterGroup) {
  123. r.GET("/roleList", hdl.RoleList) // 角色列表
  124. r.POST("/addRole", hdl.AddRole) // 角色添加
  125. r.POST("/roleBindPermissionGroup", hdl.RoleBindPermissionGroup) // 角色绑定权限组
  126. r.POST("/updateRoleState", hdl.UpdateRoleState) // 修改角色状态
  127. r.POST("/updateRole", hdl.UpdateRole) // 修改角色状态
  128. r.DELETE("/deleteRole/:id", hdl.DeleteRole) // 删除角色
  129. r.GET("/permissionGroupList", hdl.PermissionGroupList) // 权限组列表
  130. r.POST("/adminList", hdl.AdminList) // 管理员列表
  131. r.POST("/updateAdminState", hdl.UpdateAdminState) // 修改管理员状态
  132. r.POST("/updateAdmin", hdl.UpdateAdmin) // 修改管理员信息
  133. r.POST("/addAdmin", hdl.AddAdmin) // 新增管理员
  134. r.DELETE("/deleteAdmin/:adm_id", hdl.DeleteAdmin) // 删除管理员
  135. r.GET("/adminInfo", hdl.AdminInfo) // 获取管理员信息
  136. r.POST("/bindAdminRole", hdl.BindAdminRole) // 绑定角色
  137. r.POST("/mediumList", hdl.RoleMediumList) // 管理员列表-媒体列表
  138. r.POST("/bindMedium", hdl.RoleBindMedium) // 管理员列表-关联媒体
  139. r.POST("/mediumDel", hdl.RoleDelMedium) // 管理员列表-删除关联媒体
  140. r.POST("/bindAgent", hdl.RoleBindAgent) // 管理员列表-关联代理
  141. r.POST("/agentList", hdl.RoleAgentList) // 管理员列表-媒体列表
  142. r.POST("/agentDel", hdl.RoleDelAgent) // 管理员列表-删除代理媒体
  143. }
  144. func rAgentQualification(r *gin.RouterGroup) {
  145. r.GET("/enterprise/select/base", hdl.QualificationSelectBase) // 资质认证-认证选择内容
  146. r.GET("/bank/select/base", hdl.QualificationSelectBase) // 资质认证-认证选择内容
  147. r.POST("/enterprise", hdl.AgentQualificationEnterprise) // 企业主体资质
  148. r.POST("/enterprise/audit", hdl.AgentQualificationEnterpriseAudit) // 企业主体资质审核
  149. r.POST("/bank", hdl.AgentQualificationBank) // 银行资质
  150. r.POST("/bank/audit", hdl.AgentQualificationBankAudit) // 银行审核
  151. r.POST("/contact", hdl.AgentQualificationContactInfo) // 联系方式
  152. r.POST("/contact/audit", hdl.AgentQualificationContactInfoAudit) // 联系方式
  153. }
  154. func rMediumQualification(r *gin.RouterGroup) {
  155. r.GET("/enterprise/select/base", hdl.QualificationSelectBase) // 资质认证-认证选择内容
  156. r.GET("/bank/select/base", hdl.QualificationSelectBase) // 资质认证-认证选择内容
  157. r.POST("/enterprise", hdl.MediumQualificationEnterprise) // 企业主体资质
  158. r.POST("/enterprise/audit", hdl.MediumQualificationEnterpriseAudit) // 企业主体资质审核
  159. r.POST("/bank", hdl.MediumQualificationBank) // 银行资质
  160. r.POST("/bank/audit", hdl.MediumQualificationBankAudit) // 银行审核
  161. r.POST("/contact", hdl.MediumQualificationContactInfo) // 联系方式
  162. r.POST("/contact/audit", hdl.MediumQualificationContactInfoAudit) // 联系方式
  163. }
  164. func rSetCenter(r *gin.RouterGroup) {
  165. rBasicSetCenter := r.Group("/basic")
  166. {
  167. rBasicSetCenter.POST("/setOss", hdl.SetOss)
  168. rBasicSetCenter.GET("/getOss", hdl.GetOss)
  169. rBasicSetCenter.POST("/wxOpenSet", hdl.WxOpenSet)
  170. rBasicSetCenter.GET("/wxOpenGet", hdl.WxOpenGet)
  171. rBasicSetCenter.POST("/setMob", hdl.SetMob)
  172. rBasicSetCenter.GET("/getMob", hdl.GetMob)
  173. rBasicSetCenter.POST("/setLogo", hdl.SetLogo)
  174. rBasicSetCenter.GET("/getLogo", hdl.GetLogo)
  175. rBasicSetCenter.POST("/setSeo", hdl.SetSeo)
  176. rBasicSetCenter.GET("/getSeo", hdl.GetSeo)
  177. }
  178. rAppletSetCenter := r.Group("/applet")
  179. {
  180. rAppletSetCenter.GET("/list", hdl.AppletList)
  181. rAppletSetCenter.POST("/add", hdl.AppletAdd)
  182. rAppletSetCenter.POST("/update", hdl.AppletUpdate)
  183. rAppletSetCenter.DELETE("/delete/:id", hdl.AppletDelete)
  184. rAppletSetCenter.GET("/authorize", hdl.AppletAuthorize)
  185. rAppletSetCenter.GET("/unauthorized", hdl.AppletUnauthorized)
  186. rAppletShieldRules := rAppletSetCenter.Group("/shieldRules")
  187. {
  188. rAppletShieldRules.POST("/getBlackList", hdl.AppletGetBlackList)
  189. rAppletShieldRules.POST("/addBlackList", hdl.AppletAddBlackList)
  190. rAppletShieldRules.POST("/delBlackList", hdl.AppletDelBlackList)
  191. rAppletShieldRules.POST("/getAmsCategoryBlackList", hdl.AppletGetAmsCategoryBlackList)
  192. rAppletShieldRules.POST("/setAmsCategoryBlackList", hdl.AppletSetAmsCategoryBlackList)
  193. }
  194. }
  195. rShareSetCenter := r.Group("/share")
  196. {
  197. rShareSetCenter.GET("/index", hdl.ShareIndex)
  198. }
  199. }
  200. func rMedium(r *gin.RouterGroup) {
  201. r.POST("/applet/application/medium/list", hdl.AppletApplicationMediumList) // 应用管理-媒体列表
  202. r.POST("/applet/application/list", hdl.AppletApplicationList) // 小程序应用-列表数据
  203. r.POST("/applet/application/audit", hdl.AppletApplicationAudit) // 小程序应用-审核
  204. r.POST("/applet/application/ad/space/medium/list", hdl.AppletApplicationAdSpaceMediumList) // 广告管理-媒体列表
  205. r.POST("/applet/application/ad/space/list", hdl.AppletApplicationAdSpaceList) // 小程序应用-广告位列表数据
  206. r.POST("/applet/application/ad/space/audit", hdl.AppletApplicationAdSpaceAudit) // 小程序应用-广告位审核
  207. }
  208. func rAssociationCenter(r *gin.RouterGroup) {
  209. r.POST("/medium/list", hdl.MediumList) // 媒体列表
  210. r.POST("/medium/bind/agent/list", hdl.MediumBindAgentList) // 媒体绑定代理列表
  211. r.POST("/medium/bind/agent/save", hdl.MediumBindAgentSave) // 媒体绑定代理操作
  212. r.POST("/medium/bind/agent/del", hdl.MediumBindAgentDel) // 媒体绑定代理删除
  213. r.POST("/medium/bind/agent/select/list", hdl.AgentList) // 媒体绑定代理-选择内容
  214. r.POST("/agent/list", hdl.AgentList) // 代理列表
  215. r.POST("/agent/bind/medium/list", hdl.AgentBindMediumList) // 代理绑定媒体列表
  216. }
  217. func rDivisionStrategy(r *gin.RouterGroup) {
  218. r.POST("/list", hdl.DivisionStrategyList) // 分成策略-列表
  219. r.POST("/detail", hdl.DivisionStrategyDetail) // 分成策略-详情
  220. r.POST("/save", hdl.DivisionStrategySave) // 分成策略-保存
  221. }
  222. func rDataCenter(r *gin.RouterGroup) {
  223. r.POST("/original/data/list", hdl.OriginalDataList) // 数据中心-原始数据
  224. r.POST("/original/data/del", hdl.OriginalDataDel) // 数据中心-原始数据-删除
  225. r.POST("/original/data/total", hdl.OriginalDataTotal) // 数据中心-原始数据-记录应用时统计
  226. r.POST("/original/data/doing", hdl.OriginalDataDoing) // 数据中心-原始数据-记录应用时操作
  227. r.POST("/original/data/more/application", hdl.OriginalDataMoreApplication) // 数据中心-原始数据-一键导入应用列表
  228. r.POST("/original/data/more/application/doing", hdl.OriginalDataMoreApplicationDoing) // 数据中心-原始数据-一键导入操作
  229. r.GET("/original/data/more/application/state", hdl.OriginalDataMoreApplicationState) // 数据中心-原始数据-一键导入操作后的完成状态
  230. r.GET("/original/data/one/application", hdl.OriginalDataOneApplication) // 数据中心-原始数据-单个导入应用列表
  231. r.POST("/original/data/one/application/ad/list", hdl.OriginalDataOneApplicationAdList) // 数据中心-原始数据-单个导入应用-广告位列表
  232. r.POST("/original/data/one/application/total", hdl.OriginalDataOneApplicationTotal) // 数据中心-原始数据-单个应用数据统计
  233. r.POST("/original/data/one/application/doing", hdl.OriginalDataOneApplicationDoing) // 数据中心-原始数据-单个应用数据操作
  234. r.GET("/original/data/one/application/state", hdl.OriginalDataOneApplicationState) // 数据中心-原始数据-单个应用数据操作后的完成状态
  235. r.POST("/generate/data/list", hdl.GenerateDataList) // 数据中心-分成数据
  236. r.POST("/generate/data/del", hdl.GenerateDataDel) // 数据中心-分成数据-删除
  237. r.POST("/generate/data/detail", hdl.GenerateDataDetail) // 数据中心-分成数据-详情
  238. r.POST("/generate/data/doing", hdl.GenerateDataDoing) // 数据中心-分成数据-报表生成操作
  239. r.POST("/income/data/list", hdl.IncomeDataList) // 数据中心-收益报表
  240. r.POST("/income/data/listForOpen", hdl.IncomeDataListForOpen) // 数据中心-收益报表(开放使用)
  241. r.POST("/income/data/list/output", hdl.IncomeDataListOutPut) // 数据中心-收益报表
  242. r.POST("/income/data/detail", hdl.IncomeDataDetail) // 数据中心-收益报表-详情
  243. r.GET("/income/data/select/data", hdl.DataCenterSelectData) //数据中心-收益报表-筛选条件
  244. r.POST("/income/data/table", hdl.DataCenterTable) //数据中心-收益报表-数据图表
  245. }
  246. func rSettleCenter(r *gin.RouterGroup) {
  247. r.POST("/medium/list", hdl.SettleCenterMediumList) // 结算中心-媒体列表
  248. r.POST("/medium/save", hdl.SettleCenterMediumSave) // 结算中心-媒体修复结算方式
  249. r.POST("/medium/detail", hdl.SettleCenterMediumDetail) // 结算中心-媒体结算详情
  250. r.POST("/agent/list", hdl.SettleCenterAgentList) // 结算中心-代理列表
  251. r.POST("/agent/save", hdl.SettleCenterAgentSave) // 结算中心-代理修复结算方式
  252. r.POST("/agent/detail", hdl.SettleCenterAgentDetail) // 结算中心-代理结算详情
  253. }
  254. func rFinanceCenter(r *gin.RouterGroup) {
  255. r.POST("/medium/list", hdl.FinanceCenterMediumList) // 财务中心-媒体列表
  256. r.POST("/medium/detail", hdl.FinanceCenterMediumDetail) // 财务中心-媒体详情
  257. r.POST("/medium/settle/file/save", hdl.FinanceCenterMediumSettleFileSave) // 财务中心-媒体详情-结算单上传
  258. r.POST("/medium/invoice/save", hdl.FinanceCenterMediumInvoiceSave) // 财务中心-媒体详情-发票审核
  259. r.POST("/medium/other/income/save", hdl.FinanceCenterMediumOtherIncomeSave) // 财务中心-媒体详情-其他收益调整
  260. r.POST("/medium/pay/save", hdl.FinanceCenterMediumPaySave) // 财务中心-媒体详情-确认支付
  261. r.POST("/platform/list", hdl.FinanceCenterPlatformList) // 财务中心-平台报表
  262. r.POST("/agent/list", hdl.FinanceCenterAgentList) // 财务中心-代理列表
  263. r.POST("/agent/detail", hdl.FinanceCenterAgentDetail) // 财务中心-代理详情
  264. r.POST("/agent/settle/file/save", hdl.FinanceCenterAgentSettleFileSave) // 财务中心-代理详情-结算单上传
  265. r.POST("/agent/invoice/save", hdl.FinanceCenterAgentInvoiceSave) // 财务中心-代理详情-发票审核
  266. r.POST("/agent/other/income/save", hdl.FinanceCenterAgentOtherIncomeSave) // 财务中心-代理详情-其他收益调整
  267. r.POST("/agent/pay/save", hdl.FinanceCenterAgentPaySave) // 财务中心-代理详情-确认支付
  268. }
  269. func rFinancialDynamics(r *gin.RouterGroup) {
  270. r.POST("/medium/total", hdl.FinancialDynamicsMediumTotal) // 预付中心-媒体预付统计
  271. r.POST("/medium/list", hdl.FinancialDynamicsMediumList) // 预付中心-媒体预付
  272. r.POST("/medium/save", hdl.FinancialDynamicsMediumSave) // 预付中心-媒体预付创建
  273. r.POST("/agent/total", hdl.FinancialDynamicsAgentTotal) // 预付中心-代理预付统计
  274. r.POST("/agent/list", hdl.FinancialDynamicsAgentList) // 预付中心-代理预付
  275. r.POST("/agent/save", hdl.FinancialDynamicsAgentSave) // 预付中心-代理预付创建
  276. }