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

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