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

142 line
4.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. "applet/app/admin/mw"
  7. "applet/app/cfg"
  8. "github.com/gin-gonic/gin"
  9. )
  10. // Init 初始化路由
  11. func Init() *gin.Engine {
  12. mode := "release"
  13. if cfg.Debug {
  14. mode = "debug"
  15. }
  16. gin.SetMode(mode)
  17. //创建一个新的启动器
  18. r := gin.New()
  19. // 是否打印访问日志, 在非正式环境都打印
  20. if mode != "release" {
  21. r.Use(gin.Logger())
  22. }
  23. r.Use(gin.Recovery())
  24. r.GET("/favicon.ico", func(c *gin.Context) {
  25. c.Status(204)
  26. })
  27. r.NoRoute(func(c *gin.Context) {
  28. c.JSON(404, gin.H{"code": 404, "msg": "page not found", "data": []struct{}{}})
  29. })
  30. r.NoMethod(func(c *gin.Context) {
  31. c.JSON(405, gin.H{"code": 405, "msg": "method not allowed", "data": []struct{}{}})
  32. })
  33. r.Use(mw.Cors)
  34. AdminRoute(r.Group("/api/admin"))
  35. IpadInit(r.Group("/api/ipad"))
  36. return r
  37. }
  38. func rCompany(r *gin.RouterGroup) {
  39. r.GET("/list", hdl.CompanyList)
  40. r.POST("/add", hdl.CompanyAdd)
  41. r.POST("/update", hdl.CompanyUpdate)
  42. r.DELETE("/delete/:id", hdl.CompanyDelete)
  43. }
  44. func rHomePage(r *gin.RouterGroup) {
  45. }
  46. func rBanner(r *gin.RouterGroup) {
  47. }
  48. func rComm(r *gin.RouterGroup) {
  49. r.POST("/getMenuList", hdl.MenuList) // 获取菜单栏列表
  50. }
  51. func rOss(r *gin.RouterGroup) {
  52. r.POST("/upload/token", hdl.ImgReqUpload) // 文件上传获取七牛云上传token
  53. }
  54. func rSetCenter(r *gin.RouterGroup) {
  55. r.GET("/get", hdl.GetCenter) // 设置中心-获取
  56. r.POST("/set", hdl.SetCenter) // 设置中心-设置
  57. }
  58. func rUser(r *gin.RouterGroup) {
  59. }
  60. func rEnterprise(r *gin.RouterGroup) {
  61. r.GET("/list", hdl.EnterpriseList)
  62. r.POST("/add", hdl.EnterpriseAdd)
  63. r.POST("/update", hdl.EnterpriseUpdate)
  64. r.POST("/updateState", hdl.EnterpriseUpdateState)
  65. r.POST("/delete", hdl.EnterpriseDelete)
  66. }
  67. func rCategory(r *gin.RouterGroup) {
  68. r.GET("/list", categoryHdl.List)
  69. r.GET("/add", categoryHdl.Add)
  70. r.GET("/del", categoryHdl.Del)
  71. r.POST("/sort", categoryHdl.Sort)
  72. r.POST("/save", categoryHdl.Save)
  73. }
  74. func rGoods(r *gin.RouterGroup) {
  75. r.POST("/del", goodsHdl.DelMallGoods)
  76. r.POST("/add", goodsHdl.AddMallGoods)
  77. r.GET("/detail", goodsHdl.MallGoodsDetail)
  78. r.GET("/list", goodsHdl.GetMallGoodsList)
  79. r.GET("/checkSkuCode", goodsHdl.CheckSkuCode)
  80. r.POST("/change-sale-state", goodsHdl.ChangeSaleState)
  81. }
  82. func rRole(r *gin.RouterGroup) {
  83. r.GET("/roleList", hdl.RoleList) //角色列表
  84. r.POST("/addRole", hdl.AddRole) //角色添加
  85. r.POST("/roleBindPermissionGroup", hdl.RoleBindPermissionGroup) //角色绑定权限组
  86. r.POST("/updateRoleState", hdl.UpdateRoleState) //修改角色状态
  87. r.POST("/updateRole", hdl.UpdateRole) //修改角色
  88. r.DELETE("/deleteRole/:id", hdl.DeleteRole) //删除角色
  89. r.GET("/permissionGroupList", hdl.PermissionGroupList) //权限组列表
  90. r.POST("/adminList", hdl.AdminList) //管理员列表
  91. r.POST("/updateAdminState", hdl.UpdateAdminState) //修改管理员状态
  92. r.POST("/updateAdmin", hdl.UpdateAdmin) //修改管理员信息
  93. r.POST("/addAdmin", hdl.AddAdmin) //新增管理员
  94. r.DELETE("/deleteAdmin/:adm_id", hdl.DeleteAdmin) //删除管理员
  95. r.GET("/adminInfo", hdl.AdminInfo) //获取管理员信息
  96. r.POST("/bindAdminRole", hdl.BindAdminRole) //绑定角色
  97. }
  98. func AdminRoute(r *gin.RouterGroup) {
  99. r.GET("/demo", hdl.Demo)
  100. r.POST("/login", hdl.Login)
  101. r.Use(mw.Auth) //检测登录状态
  102. r.GET("/userInfo", hdl.UserInfo) //用户信息
  103. r.GET("/sysCfg", hdl.GetSysCfg) //基础配置-获取
  104. rOss(r.Group("/oss"))
  105. rComm(r.Group("/comm"))
  106. r.Use(mw.CheckPermission) //检测权限
  107. rHomePage(r.Group("/homePage")) //首页
  108. rCompany(r.Group("/company")) //公司管理
  109. rBanner(r.Group("/banner")) //轮播图管理
  110. rEnterprise(r.Group("/enterprise")) //校企
  111. rCategory(r.Group("/category")) //商品类目
  112. rGoods(r.Group("/goods")) //商品
  113. rRole(r.Group("/role")) //权限管理
  114. rSetCenter(r.Group("/setCenter")) //设置中心
  115. rUser(r.Group("/user")) //用户管理
  116. }