package router import ( hdl2 "applet/app/admin/hdl" hdl "applet/app/admin/hdl/enterprise_manage" "applet/app/admin/mw" "applet/app/cfg" "github.com/gin-gonic/gin" ) // Init 初始化路由 func Init() *gin.Engine { mode := "release" if cfg.Debug { mode = "debug" } gin.SetMode(mode) //创建一个新的启动器 r := gin.New() // 是否打印访问日志, 在非正式环境都打印 if mode != "release" { r.Use(gin.Logger()) } r.Use(gin.Recovery()) r.GET("/favicon.ico", func(c *gin.Context) { c.Status(204) }) r.NoRoute(func(c *gin.Context) { c.JSON(404, gin.H{"code": 404, "msg": "page not found", "data": []struct{}{}}) }) r.NoMethod(func(c *gin.Context) { c.JSON(405, gin.H{"code": 405, "msg": "method not allowed", "data": []struct{}{}}) }) r.Use(mw.Cors) AdminRoute(r.Group("/api/admin")) CustomerInit(r.Group("/api/v1")) return r } func rCompany(r *gin.RouterGroup) { r.GET("/list", hdl2.CompanyList) r.POST("/add", hdl2.CompanyAdd) r.POST("/update", hdl2.CompanyUpdate) r.DELETE("/delete/:id", hdl2.CompanyDelete) } func rNotice(r *gin.RouterGroup) { r.GET("/list", hdl2.NoticeList) r.POST("/add", hdl2.NoticeAdd) r.POST("/sort", hdl2.NoticeSort) r.POST("/update", hdl2.NoticeUpdate) r.DELETE("/delete/:id", hdl2.NoticeUpdate) } func rBanner(r *gin.RouterGroup) { r.GET("/list", hdl2.BannerList) r.POST("/add", hdl2.BannerAdd) r.POST("/sort", hdl2.BannerSort) r.POST("/update", hdl2.BannerUpdate) r.DELETE("/delete/:id", hdl2.BannerDelete) } func rOss(r *gin.RouterGroup) { r.POST("/upload/token", hdl2.ImgReqUpload) // 文件上传获取七牛云上传token } func rSetCenter(r *gin.RouterGroup) { r.GET("/get", hdl2.GetCenter) // 设置中心-获取 r.POST("/set", hdl2.SetCenter) // 设置中心-设置 } func rAuditCenter(r *gin.RouterGroup) { r.POST("/centralKitchenForSchoolOrderRefundList", hdl2.CentralKitchenForSchoolOrderRefundList) //审核中心-央厨-学校-订单退款列表 r.POST("/centralKitchenForSchoolOrderRefundAudit", hdl2.CentralKitchenForSchoolOrderRefundAudit) //审核中心-央厨-学校-订单退款审核 } func rUser(r *gin.RouterGroup) { r.POST("/list", hdl2.UserList) //列表 r.POST("/update", hdl2.UserUpdate) //编辑 r.DELETE("/delete/:id", hdl2.UserDelete) //删除 } func rEnterprise(r *gin.RouterGroup) { r.POST("/list", hdl2.EnterpriseList) r.POST("/add", hdl2.EnterpriseAdd) r.POST("/update", hdl2.EnterpriseUpdate) r.POST("/delete", hdl2.EnterpriseDelete) r.POST("/updateState", hdl2.EnterpriseUpdateState) r.POST("/addGrade", hdl2.EnterpriseAddGrade) r.GET("/detail", hdl2.Detail) r.GET("/schoolBelowGrade", hdl2.SchoolBelowGrade) //"学校"下年级 r.GET("/schoolGradeBelowClass", hdl2.SchoolGradeBelowClass) //"学校"年级下班级 } func rEnterpriseManage(r *gin.RouterGroup) { r.GET("/info", hdl.EnterpriseManageInfo) //校企管理信息 r.POST("/userIdentityList", hdl.UserIdentityList) //用户列表 r.POST("/centralKitchenForSchool/userUpdate", hdl.CentralKitchenForSchoolUserUpdate) //"央厨-学校"用户编辑 r.POST("/centralKitchenForSchool/userDelete", hdl.CentralKitchenForSchoolUserDelete) //"央厨-学校"用户删除 r.POST("/centralKitchenForSchool/studentList", hdl.CentralKitchenForSchoolStudentList) //"央厨-学校"学生列表 r.POST("/centralKitchenForSchool/studentUpdate", hdl.CentralKitchenForSchoolStudentUpdate) //"央厨-学校"学生编辑 r.POST("/centralKitchenForSchool/studentDelete", hdl.CentralKitchenForSchoolStudentDelete) //"央厨-学校"学生删除 r.POST("/centralKitchenForSchool/studentAdmission", hdl.CentralKitchenForSchoolStudentAdmission) //"央厨-学校"学生升学 r.POST("/centralKitchenForSchool/teacherList", hdl.CentralKitchenForSchoolTeacherList) //"央厨-学校"教师列表 r.POST("/centralKitchenForSchool/teacherUpdate", hdl.CentralKitchenForSchoolTeacherUpdate) //"央厨-学校"教师编辑 r.POST("/centralKitchenForSchool/teacherDelete", hdl.CentralKitchenForSchoolTeacherDelete) //"央厨-学校"教师删除 r.POST("/centralKitchenForSchool/ordList", hdl.CentralKitchenForSchoolOrdList) //"央厨-学校"订单列表 r.GET("/centralKitchenForSchool/ordDetail", hdl.CentralKitchenForSchoolOrdDetail) //"央厨-学校"订单详情 r.POST("/centralKitchenForSchool/ordRefund", hdl.CentralKitchenForSchoolOrdRefund) //"央厨-学校"订单退款 r.POST("/setBasicCentralKitchenForSchool", hdl.SetBasicCentralKitchenForSchool) //"央厨-学校"设置基础设置 r.GET("/getBasicCentralKitchenForSchool", hdl.GetBasicCentralKitchenForSchool) //"央厨-学校"获取基础设置 r.POST("/setCentralKitchenForSchoolWithSpec", hdl.SetCentralKitchenForSchoolWithSpec) //设置"央厨-学校-规格" r.GET("/getCentralKitchenForSchoolWithSpec", hdl.GetCentralKitchenForSchoolWithSpec) //获取"央厨-学校-规格" r.POST("/listCentralKitchenForSchoolPackage", hdl.ListCentralKitchenForSchoolPackage) //"央厨-学校-套餐" 列表 r.GET("/detailCentralKitchenForSchoolPackage", hdl.DetailCentralKitchenForSchoolPackage) //"央厨-学校-套餐" 详情 r.POST("/saveCentralKitchenForSchoolPackage", hdl.SaveCentralKitchenForSchoolPackage) //新增/编辑 "央厨-学校-套餐" r.DELETE("/deleteCentralKitchenForSchoolPackage/:id", hdl.DeleteCentralKitchenForSchoolPackage) //删除 "央厨-学校-套餐" r.POST("/selfSupportForSchool/studentList", hdl.CentralKitchenForSchoolStudentList) //"央厨-学校"学生列表 } func rRole(r *gin.RouterGroup) { r.GET("/roleList", hdl2.RoleList) //角色列表 r.POST("/addRole", hdl2.AddRole) //角色添加 r.POST("/roleBindPermissionGroup", hdl2.RoleBindPermissionGroup) //角色绑定权限组 r.POST("/updateRoleState", hdl2.UpdateRoleState) //修改角色状态 r.POST("/updateRole", hdl2.UpdateRole) //修改角色状态 r.DELETE("/deleteRole/:id", hdl2.DeleteRole) //删除角色 r.GET("/permissionGroupList", hdl2.PermissionGroupList) //权限组列表 r.POST("/adminList", hdl2.AdminList) //管理员列表 r.POST("/updateAdminState", hdl2.UpdateAdminState) //修改管理员状态 r.POST("/updateAdmin", hdl2.UpdateAdmin) //修改管理员信息 r.POST("/addAdmin", hdl2.AddAdmin) //新增管理员 r.DELETE("/deleteAdmin/:adm_id", hdl2.DeleteAdmin) //删除管理员 r.GET("/adminInfo", hdl2.AdminInfo) //获取管理员信息 r.POST("/bindAdminRole", hdl2.BindAdminRole) //绑定角色 } func AdminRoute(r *gin.RouterGroup) { r.POST("/login", hdl2.Login) r.Use(mw.Auth) //检测登录状态 r.GET("/demo", hdl2.Demo) r.GET("/userInfo", hdl2.UserInfo) //用户信息 r.Any("/changePwd", hdl2.Demo) //修改密码 r.GET("/sysCfg", hdl2.GetSysCfg) //基础配置-获取 r.Use(mw.CheckPermission) //检测权限 rOss(r.Group("/oss")) rCompany(r.Group("/company")) //公司管理 rNotice(r.Group("/notice")) //公告管理 rBanner(r.Group("/banner")) //轮播图管理 rEnterprise(r.Group("/enterprise")) //校企管理 rEnterpriseManage(r.Group("/enterpriseManage")) //校企管理详情 rRole(r.Group("/role")) //权限管理 rSetCenter(r.Group("/setCenter")) //设置中心 rUser(r.Group("/user")) //用户管理 rAuditCenter(r.Group("/auditCenter")) //审核中心 }