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

181 rivejä
6.2 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 rStaff(r *gin.RouterGroup) {
  70. r.POST("/list", hdl.StaffList)
  71. r.POST("/delete", hdl.StaffDelete)
  72. r.POST("/add", hdl.StaffAdd)
  73. r.POST("/update", hdl.StaffUpdate)
  74. }
  75. func rEnterprise(r *gin.RouterGroup) {
  76. r.POST("/list", hdl.EnterpriseList)
  77. r.POST("/add", hdl.EnterpriseAdd)
  78. r.POST("/update", hdl.EnterpriseUpdate)
  79. r.POST("/updateState", hdl.EnterpriseUpdateState)
  80. r.POST("/delete", hdl.EnterpriseDelete)
  81. }
  82. func rCategory(r *gin.RouterGroup) {
  83. r.GET("/list", categoryHdl.List)
  84. r.GET("/add", categoryHdl.Add)
  85. r.GET("/del", categoryHdl.Del)
  86. r.POST("/sort", categoryHdl.Sort)
  87. r.POST("/save", categoryHdl.Save)
  88. }
  89. func rGoods(r *gin.RouterGroup) {
  90. r.POST("/del", goodsHdl.DelMallGoods)
  91. r.POST("/add", goodsHdl.AddMallGoods)
  92. r.GET("/detail", goodsHdl.GetGoodsDetail)
  93. r.GET("/list", goodsHdl.GetMallGoodsList)
  94. r.GET("/checkSkuCode", goodsHdl.CheckSkuCode)
  95. r.POST("/change-sale-state", goodsHdl.ChangeSaleState)
  96. }
  97. func rRole(r *gin.RouterGroup) {
  98. r.GET("/roleList", hdl.RoleList) //角色列表
  99. r.POST("/addRole", hdl.AddRole) //角色添加
  100. r.POST("/roleBindPermissionGroup", hdl.RoleBindPermissionGroup) //角色绑定权限组
  101. r.POST("/updateRoleState", hdl.UpdateRoleState) //修改角色状态
  102. r.POST("/updateRole", hdl.UpdateRole) //修改角色
  103. r.DELETE("/deleteRole/:id", hdl.DeleteRole) //删除角色
  104. r.GET("/permissionGroupList", hdl.PermissionGroupList) //权限组列表
  105. r.POST("/adminList", hdl.AdminList) //管理员列表
  106. r.POST("/updateAdminState", hdl.UpdateAdminState) //修改管理员状态
  107. r.POST("/updateAdmin", hdl.UpdateAdmin) //修改管理员信息
  108. r.POST("/addAdmin", hdl.AddAdmin) //新增管理员
  109. r.DELETE("/deleteAdmin/:adm_id", hdl.DeleteAdmin) //删除管理员
  110. r.GET("/adminInfo", hdl.AdminInfo) //获取管理员信息
  111. r.POST("/bindAdminRole", hdl.BindAdminRole) //绑定角色
  112. }
  113. func rGoodsPay(r *gin.RouterGroup) {
  114. r.POST("/enterpriseList", hdl.EnterpriseList) //校企列表
  115. r.GET("/goodsList", goodsHdl.GetMallGoodsList) //商品列表
  116. r.POST("/calcAmount", orderHdl.GoodsPayCalcAmount) //商品下单计算价格
  117. r.POST("/create", orderHdl.GoodsPayCreate) //商品下单
  118. }
  119. func rOrder(r *gin.RouterGroup) {
  120. r.POST("/list", orderHdl.OrderList) //用户订单
  121. r.POST("/total", orderHdl.OrderTotal) //用户订单统计
  122. r.POST("/cancel", orderHdl.OrderCancel) //用户订单取消
  123. r.POST("/detail", orderHdl.OrderDetail) //用户订单详情
  124. r.POST("/output", orderHdl.OrderOutput) //用户订单导出
  125. r.POST("/del", orderHdl.OrderDel) //用户订单商品删除
  126. r.POST("/edit", orderHdl.OrderEdit) //用户订单修改购买人信息
  127. r.POST("/editNum", orderHdl.OrderEditNum) //用户订单修改订单数
  128. r.POST("/makeRecord", orderHdl.MarkRecord) //制作记录
  129. }
  130. func rFinanceManage(r *gin.RouterGroup) {
  131. r.POST("/list", orderHdl.OrderList) //用户订单
  132. r.POST("/export", orderHdl.OrderExport) //用户订单导出
  133. r.POST("/total", orderHdl.OrderTotal) //用户订单统计
  134. }
  135. func AdminRoute(r *gin.RouterGroup) {
  136. r.GET("/demo", hdl.Demo)
  137. r.POST("/login", hdl.Login)
  138. r.Use(mw.Auth) //检测登录状态
  139. r.GET("/userInfo", hdl.UserInfo) //用户信息
  140. r.GET("/sysCfg", hdl.GetSysCfg) //基础配置-获取
  141. rOss(r.Group("/oss"))
  142. rComm(r.Group("/comm"))
  143. r.Use(mw.CheckPermission) //检测权限
  144. rHomePage(r.Group("/homePage")) //首页
  145. rCompany(r.Group("/company")) //公司管理
  146. rScheme(r.Group("/scheme")) //方案管理
  147. rEnterprise(r.Group("/enterprise")) //校企
  148. rCategory(r.Group("/category")) //商品类目
  149. rGoods(r.Group("/goods")) //商品
  150. rRole(r.Group("/role")) //权限管理
  151. rSetCenter(r.Group("/setCenter")) //设置中心
  152. rStaff(r.Group("/staff")) //员工管理
  153. rGoodsPay(r.Group("/goodsPay")) //商品下单
  154. rOrder(r.Group("/order")) //用户订单
  155. rFinanceManage(r.Group("/financeManage")) //财务管理
  156. }