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

150 line
4.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. "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 rScheme(r *gin.RouterGroup) {
  47. r.GET("/list", hdl.SchemeList)
  48. r.POST("/add", hdl.AddScheme)
  49. r.POST("/update", hdl.UpdateScheme)
  50. r.POST("/bindEnterprise", hdl.SchemeBindEnterprise)
  51. r.POST("/updateSchemeState", hdl.UpdateSchemeState)
  52. r.DELETE("/delete/:id", hdl.DeleteScheme)
  53. r.GET("/goodsList", goodsHdl.GetMallGoodsList)
  54. r.GET("/goodsDetail", hdl.SchemeGoodsDetail)
  55. r.POST("/saveSchemeGoods", hdl.SaveSchemeGoods)
  56. }
  57. func rComm(r *gin.RouterGroup) {
  58. r.POST("/getMenuList", hdl.MenuList) // 获取菜单栏列表
  59. }
  60. func rOss(r *gin.RouterGroup) {
  61. r.POST("/upload/token", hdl.ImgReqUpload) // 文件上传获取七牛云上传token
  62. }
  63. func rSetCenter(r *gin.RouterGroup) {
  64. r.GET("/get", hdl.GetCenter) // 设置中心-获取
  65. r.POST("/set", hdl.SetCenter) // 设置中心-设置
  66. }
  67. func rUser(r *gin.RouterGroup) {
  68. }
  69. func rEnterprise(r *gin.RouterGroup) {
  70. r.POST("/list", hdl.EnterpriseList)
  71. r.POST("/add", hdl.EnterpriseAdd)
  72. r.POST("/update", hdl.EnterpriseUpdate)
  73. r.POST("/updateState", hdl.EnterpriseUpdateState)
  74. r.POST("/delete", hdl.EnterpriseDelete)
  75. }
  76. func rCategory(r *gin.RouterGroup) {
  77. r.GET("/list", categoryHdl.List)
  78. r.GET("/add", categoryHdl.Add)
  79. r.GET("/del", categoryHdl.Del)
  80. r.POST("/sort", categoryHdl.Sort)
  81. r.POST("/save", categoryHdl.Save)
  82. }
  83. func rGoods(r *gin.RouterGroup) {
  84. r.POST("/del", goodsHdl.DelMallGoods)
  85. r.POST("/add", goodsHdl.AddMallGoods)
  86. r.GET("/detail", goodsHdl.GetGoodsDetail)
  87. r.GET("/list", goodsHdl.GetMallGoodsList)
  88. r.GET("/checkSkuCode", goodsHdl.CheckSkuCode)
  89. r.POST("/change-sale-state", goodsHdl.ChangeSaleState)
  90. }
  91. func rRole(r *gin.RouterGroup) {
  92. r.GET("/roleList", hdl.RoleList) //角色列表
  93. r.POST("/addRole", hdl.AddRole) //角色添加
  94. r.POST("/roleBindPermissionGroup", hdl.RoleBindPermissionGroup) //角色绑定权限组
  95. r.POST("/updateRoleState", hdl.UpdateRoleState) //修改角色状态
  96. r.POST("/updateRole", hdl.UpdateRole) //修改角色
  97. r.DELETE("/deleteRole/:id", hdl.DeleteRole) //删除角色
  98. r.GET("/permissionGroupList", hdl.PermissionGroupList) //权限组列表
  99. r.POST("/adminList", hdl.AdminList) //管理员列表
  100. r.POST("/updateAdminState", hdl.UpdateAdminState) //修改管理员状态
  101. r.POST("/updateAdmin", hdl.UpdateAdmin) //修改管理员信息
  102. r.POST("/addAdmin", hdl.AddAdmin) //新增管理员
  103. r.DELETE("/deleteAdmin/:adm_id", hdl.DeleteAdmin) //删除管理员
  104. r.GET("/adminInfo", hdl.AdminInfo) //获取管理员信息
  105. r.POST("/bindAdminRole", hdl.BindAdminRole) //绑定角色
  106. }
  107. func AdminRoute(r *gin.RouterGroup) {
  108. r.GET("/demo", hdl.Demo)
  109. r.POST("/login", hdl.Login)
  110. r.Use(mw.Auth) //检测登录状态
  111. r.GET("/userInfo", hdl.UserInfo) //用户信息
  112. r.GET("/sysCfg", hdl.GetSysCfg) //基础配置-获取
  113. rOss(r.Group("/oss"))
  114. rComm(r.Group("/comm"))
  115. r.Use(mw.CheckPermission) //检测权限
  116. rHomePage(r.Group("/homePage")) //首页
  117. rCompany(r.Group("/company")) //公司管理
  118. rScheme(r.Group("/scheme")) //方案管理
  119. rEnterprise(r.Group("/enterprise")) //校企
  120. rCategory(r.Group("/category")) //商品类目
  121. rGoods(r.Group("/goods")) //商品
  122. rRole(r.Group("/role")) //权限管理
  123. rSetCenter(r.Group("/setCenter")) //设置中心
  124. rUser(r.Group("/user")) //用户管理
  125. }