面包店
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 
 

170 rader
5.7 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. }
  48. func rScheme(r *gin.RouterGroup) {
  49. r.GET("/list", hdl.SchemeList)
  50. r.POST("/add", hdl.AddScheme)
  51. r.POST("/update", hdl.UpdateScheme)
  52. r.POST("/bindEnterprise", hdl.SchemeBindEnterprise)
  53. r.POST("/updateSchemeState", hdl.UpdateSchemeState)
  54. r.DELETE("/delete/:id", hdl.DeleteScheme)
  55. r.GET("/goodsList", goodsHdl.GetMallGoodsList)
  56. r.GET("/goodsDetail", hdl.SchemeGoodsDetail)
  57. r.POST("/saveSchemeGoods", hdl.SaveSchemeGoods)
  58. }
  59. func rComm(r *gin.RouterGroup) {
  60. r.POST("/getMenuList", hdl.MenuList) // 获取菜单栏列表
  61. }
  62. func rOss(r *gin.RouterGroup) {
  63. r.POST("/upload/token", hdl.ImgReqUpload) // 文件上传获取七牛云上传token
  64. }
  65. func rSetCenter(r *gin.RouterGroup) {
  66. r.GET("/get", hdl.GetCenter) // 设置中心-获取
  67. r.POST("/set", hdl.SetCenter) // 设置中心-设置
  68. }
  69. func rUser(r *gin.RouterGroup) {
  70. }
  71. func rEnterprise(r *gin.RouterGroup) {
  72. r.POST("/list", hdl.EnterpriseList)
  73. r.POST("/add", hdl.EnterpriseAdd)
  74. r.POST("/update", hdl.EnterpriseUpdate)
  75. r.POST("/updateState", hdl.EnterpriseUpdateState)
  76. r.POST("/delete", hdl.EnterpriseDelete)
  77. }
  78. func rCategory(r *gin.RouterGroup) {
  79. r.GET("/list", categoryHdl.List)
  80. r.GET("/add", categoryHdl.Add)
  81. r.GET("/del", categoryHdl.Del)
  82. r.POST("/sort", categoryHdl.Sort)
  83. r.POST("/save", categoryHdl.Save)
  84. }
  85. func rGoods(r *gin.RouterGroup) {
  86. r.POST("/del", goodsHdl.DelMallGoods)
  87. r.POST("/add", goodsHdl.AddMallGoods)
  88. r.GET("/detail", goodsHdl.GetGoodsDetail)
  89. r.GET("/list", goodsHdl.GetMallGoodsList)
  90. r.GET("/checkSkuCode", goodsHdl.CheckSkuCode)
  91. r.POST("/change-sale-state", goodsHdl.ChangeSaleState)
  92. }
  93. func rRole(r *gin.RouterGroup) {
  94. r.GET("/roleList", hdl.RoleList) //角色列表
  95. r.POST("/addRole", hdl.AddRole) //角色添加
  96. r.POST("/roleBindPermissionGroup", hdl.RoleBindPermissionGroup) //角色绑定权限组
  97. r.POST("/updateRoleState", hdl.UpdateRoleState) //修改角色状态
  98. r.POST("/updateRole", hdl.UpdateRole) //修改角色
  99. r.DELETE("/deleteRole/:id", hdl.DeleteRole) //删除角色
  100. r.GET("/permissionGroupList", hdl.PermissionGroupList) //权限组列表
  101. r.POST("/adminList", hdl.AdminList) //管理员列表
  102. r.POST("/updateAdminState", hdl.UpdateAdminState) //修改管理员状态
  103. r.POST("/updateAdmin", hdl.UpdateAdmin) //修改管理员信息
  104. r.POST("/addAdmin", hdl.AddAdmin) //新增管理员
  105. r.DELETE("/deleteAdmin/:adm_id", hdl.DeleteAdmin) //删除管理员
  106. r.GET("/adminInfo", hdl.AdminInfo) //获取管理员信息
  107. r.POST("/bindAdminRole", hdl.BindAdminRole) //绑定角色
  108. }
  109. func rGoodsPay(r *gin.RouterGroup) {
  110. r.GET("/enterpriseList", hdl.EnterpriseList) //校企列表
  111. r.GET("/goodsList", goodsHdl.GetMallGoodsList) //商品列表
  112. r.POST("/calcAmount", orderHdl.GoodsPayCalcAmount) //商品下单计算价格
  113. r.POST("/create", orderHdl.GoodsPayCreate) //商品下单
  114. }
  115. func rOrder(r *gin.RouterGroup) {
  116. r.POST("/list", orderHdl.OrderList) //用户订单
  117. r.POST("/total", orderHdl.OrderTotal) //用户订单统计
  118. r.POST("/cancel", orderHdl.OrderCancel) //用户订单取消
  119. r.POST("/detail", orderHdl.OrderDetail) //用户订单详情
  120. r.POST("/output", orderHdl.OrderOutput) //用户订单导出
  121. r.POST("/del", orderHdl.OrderDel) //用户订单商品删除
  122. r.POST("/edit", orderHdl.OrderEdit) //用户订单修改购买人信息
  123. r.POST("/editNum", orderHdl.OrderEditNum) //用户订单修改订单数
  124. r.POST("/makeRecord", orderHdl.MarkRecord) //制作记录
  125. }
  126. func AdminRoute(r *gin.RouterGroup) {
  127. r.GET("/demo", hdl.Demo)
  128. r.POST("/login", hdl.Login)
  129. r.Use(mw.Auth) //检测登录状态
  130. r.GET("/userInfo", hdl.UserInfo) //用户信息
  131. r.GET("/sysCfg", hdl.GetSysCfg) //基础配置-获取
  132. rOss(r.Group("/oss"))
  133. rComm(r.Group("/comm"))
  134. r.Use(mw.CheckPermission) //检测权限
  135. rHomePage(r.Group("/homePage")) //首页
  136. rCompany(r.Group("/company")) //公司管理
  137. rScheme(r.Group("/scheme")) //方案管理
  138. rEnterprise(r.Group("/enterprise")) //校企
  139. rCategory(r.Group("/category")) //商品类目
  140. rGoods(r.Group("/goods")) //商品
  141. rRole(r.Group("/role")) //权限管理
  142. rSetCenter(r.Group("/setCenter")) //设置中心
  143. rUser(r.Group("/user")) //用户管理
  144. rGoodsPay(r.Group("/goodsPay")) //商品下单
  145. rOrder(r.Group("/order")) //用户订单
  146. }