面包店
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.
 
 
 
 
 

194 satır
6.9 KiB

  1. package router
  2. import (
  3. "applet/app/admin/hdl"
  4. categoryHdl "applet/app/admin/hdl/category"
  5. goodsHdl "applet/app/admin/hdl/goods"
  6. orderHdl "applet/app/admin/hdl/order"
  7. "applet/app/admin/mw"
  8. "applet/app/cfg"
  9. "github.com/gin-gonic/gin"
  10. )
  11. // Init 初始化路由
  12. func Init() *gin.Engine {
  13. mode := "release"
  14. if cfg.Debug {
  15. mode = "debug"
  16. }
  17. gin.SetMode(mode)
  18. //创建一个新的启动器
  19. r := gin.New()
  20. // 是否打印访问日志, 在非正式环境都打印
  21. if mode != "release" {
  22. r.Use(gin.Logger())
  23. }
  24. r.Use(gin.Recovery())
  25. r.GET("/favicon.ico", func(c *gin.Context) {
  26. c.Status(204)
  27. })
  28. r.NoRoute(func(c *gin.Context) {
  29. c.JSON(404, gin.H{"code": 404, "msg": "page not found", "data": []struct{}{}})
  30. })
  31. r.NoMethod(func(c *gin.Context) {
  32. c.JSON(405, gin.H{"code": 405, "msg": "method not allowed", "data": []struct{}{}})
  33. })
  34. r.Use(mw.Cors)
  35. AdminRoute(r.Group("/api/admin"))
  36. IpadInit(r.Group("/api/ipad"))
  37. BigDataInit(r.Group("/api/bigData"))
  38. return r
  39. }
  40. func rCompany(r *gin.RouterGroup) {
  41. r.GET("/list", hdl.CompanyList)
  42. r.POST("/add", hdl.CompanyAdd)
  43. r.POST("/update", hdl.CompanyUpdate)
  44. r.DELETE("/delete/:id", hdl.CompanyDelete)
  45. }
  46. func rHomePage(r *gin.RouterGroup) {
  47. r.GET("/index", hdl.HomeIndex)
  48. r.GET("/operationalDataStatistics", hdl.OperationalDataStatistics)
  49. r.GET("/repayBehaviorAnalysis", hdl.RepayBehaviorAnalysis)
  50. }
  51. func rScheme(r *gin.RouterGroup) {
  52. r.GET("/list", hdl.SchemeList)
  53. r.POST("/add", hdl.AddScheme)
  54. r.POST("/update", hdl.UpdateScheme)
  55. r.POST("/bindEnterprise", hdl.SchemeBindEnterprise)
  56. r.POST("/updateSchemeState", hdl.UpdateSchemeState)
  57. r.DELETE("/delete/:id", hdl.DeleteScheme)
  58. r.GET("/goodsList", goodsHdl.GetMallGoodsList)
  59. r.GET("/goodsDetail", hdl.SchemeGoodsDetail)
  60. r.POST("/saveSchemeGoods", hdl.SaveSchemeGoods)
  61. }
  62. func rComm(r *gin.RouterGroup) {
  63. r.POST("/getMenuList", hdl.MenuList) // 获取菜单栏列表
  64. }
  65. func rOss(r *gin.RouterGroup) {
  66. r.POST("/upload/token", hdl.ImgReqUpload) // 文件上传获取七牛云上传token
  67. }
  68. func rSetCenter(r *gin.RouterGroup) {
  69. r.GET("/get", hdl.GetCenter) // 设置中心-获取
  70. r.POST("/set", hdl.SetCenter) // 设置中心-设置
  71. }
  72. func rStaff(r *gin.RouterGroup) {
  73. r.POST("/list", hdl.StaffList)
  74. r.POST("/delete", hdl.StaffDelete)
  75. r.POST("/add", hdl.StaffAdd)
  76. r.POST("/update", hdl.StaffUpdate)
  77. }
  78. func rEnterprise(r *gin.RouterGroup) {
  79. r.POST("/list", hdl.EnterpriseList)
  80. r.POST("/add", hdl.EnterpriseAdd)
  81. r.POST("/update", hdl.EnterpriseUpdate)
  82. r.POST("/updateState", hdl.EnterpriseUpdateState)
  83. r.POST("/delete", hdl.EnterpriseDelete)
  84. }
  85. func rCategory(r *gin.RouterGroup) {
  86. r.GET("/list", categoryHdl.List)
  87. r.GET("/add", categoryHdl.Add)
  88. r.GET("/del", categoryHdl.Del)
  89. r.POST("/sort", categoryHdl.Sort)
  90. r.POST("/save", categoryHdl.Save)
  91. }
  92. func rGoods(r *gin.RouterGroup) {
  93. r.POST("/del", goodsHdl.DelMallGoods)
  94. r.POST("/add", goodsHdl.AddMallGoods)
  95. r.GET("/detail", goodsHdl.GetGoodsDetail)
  96. r.GET("/list", goodsHdl.GetMallGoodsList)
  97. r.GET("/checkSkuCode", goodsHdl.CheckSkuCode)
  98. r.POST("/change-sale-state", goodsHdl.ChangeSaleState)
  99. }
  100. func rRole(r *gin.RouterGroup) {
  101. r.GET("/roleList", hdl.RoleList) //角色列表
  102. r.POST("/addRole", hdl.AddRole) //角色添加
  103. r.POST("/roleBindPermissionGroup", hdl.RoleBindPermissionGroup) //角色绑定权限组
  104. r.POST("/updateRoleState", hdl.UpdateRoleState) //修改角色状态
  105. r.POST("/updateRole", hdl.UpdateRole) //修改角色
  106. r.DELETE("/deleteRole/:id", hdl.DeleteRole) //删除角色
  107. r.GET("/permissionGroupList", hdl.PermissionGroupList) //权限组列表
  108. r.POST("/adminList", hdl.AdminList) //管理员列表
  109. r.POST("/updateAdminState", hdl.UpdateAdminState) //修改管理员状态
  110. r.POST("/updateAdmin", hdl.UpdateAdmin) //修改管理员信息
  111. r.POST("/addAdmin", hdl.AddAdmin) //新增管理员
  112. r.DELETE("/deleteAdmin/:adm_id", hdl.DeleteAdmin) //删除管理员
  113. r.GET("/adminInfo", hdl.AdminInfo) //获取管理员信息
  114. r.POST("/bindAdminRole", hdl.BindAdminRole) //绑定角色
  115. }
  116. func rGoodsPay(r *gin.RouterGroup) {
  117. r.POST("/enterpriseList", hdl.EnterpriseList) //校企列表
  118. r.GET("/goodsList", goodsHdl.GetMallGoodsListByPay) //商品列表
  119. r.POST("/calcAmount", orderHdl.GoodsPayCalcAmount) //商品下单计算价格
  120. r.POST("/create", orderHdl.GoodsPayCreate) //商品下单
  121. }
  122. func rOrder(r *gin.RouterGroup) {
  123. r.POST("/list", orderHdl.OrderList) //用户订单
  124. r.POST("/total", orderHdl.OrderTotal) //用户订单统计
  125. r.POST("/cancel", orderHdl.OrderCancel) //用户订单取消
  126. r.POST("/detail", orderHdl.OrderDetail) //用户订单详情
  127. r.POST("/output", orderHdl.OrderOutput) //用户订单导出
  128. r.POST("/del", orderHdl.OrderDel) //用户订单商品删除
  129. r.POST("/edit", orderHdl.OrderEdit) //用户订单修改购买人信息
  130. r.POST("/editNum", orderHdl.OrderEditNum) //用户订单修改订单数
  131. r.POST("/addSku", orderHdl.OrderAddSku) //用户订单修改订单数
  132. r.POST("/addNum", orderHdl.OrderAddNum) //用户订单增加数量
  133. r.POST("/deductNum", orderHdl.OrderDeductNum) //用户订单减少数量
  134. r.POST("/makeRecord", orderHdl.MarkRecord) //制作记录
  135. }
  136. func rDataStatistics(r *gin.RouterGroup) {
  137. r.POST("/list", hdl.DataStatisticsList) //列表
  138. r.POST("/export", hdl.DataStatisticsExport) //导出
  139. r.POST("/delete", hdl.DataStatisticsDelete) //删除
  140. }
  141. func rFinanceManage(r *gin.RouterGroup) {
  142. r.POST("/list", orderHdl.OrderList) //用户订单
  143. r.POST("/export", orderHdl.OrderExport) //用户订单导出
  144. r.POST("/total", orderHdl.OrderTotal) //用户订单统计
  145. }
  146. func AdminRoute(r *gin.RouterGroup) {
  147. r.GET("/demo", hdl.Demo)
  148. r.POST("/login", hdl.Login)
  149. r.Use(mw.Auth) //检测登录状态
  150. r.GET("/userInfo", hdl.UserInfo) //用户信息
  151. r.GET("/sysCfg", hdl.GetSysCfg) //基础配置-获取
  152. rOss(r.Group("/oss"))
  153. rComm(r.Group("/comm"))
  154. r.Use(mw.CheckPermission) //检测权限
  155. rHomePage(r.Group("/homePage")) //首页
  156. rCompany(r.Group("/company")) //公司管理
  157. rScheme(r.Group("/scheme")) //方案管理
  158. rEnterprise(r.Group("/enterprise")) //校企
  159. rCategory(r.Group("/category")) //商品类目
  160. rGoods(r.Group("/goods")) //商品
  161. rRole(r.Group("/role")) //权限管理
  162. rSetCenter(r.Group("/setCenter")) //设置中心
  163. rStaff(r.Group("/staff")) //员工管理
  164. rGoodsPay(r.Group("/goodsPay")) //商品下单
  165. rOrder(r.Group("/order")) //用户订单
  166. rFinanceManage(r.Group("/financeManage")) //财务管理
  167. rDataStatistics(r.Group("/dataStatistics")) //数据统计
  168. }