package router import ( "hfb_sys/backend/internal/modules/adminmgr" "hfb_sys/backend/internal/modules/adminrole" "hfb_sys/backend/internal/modules/announcement" "hfb_sys/backend/internal/modules/chat" "hfb_sys/backend/internal/modules/mohong" "hfb_sys/backend/internal/modules/payment" "hfb_sys/backend/internal/modules/supportgroup" "github.com/gin-gonic/gin" ) type permissionMiddleware func(string) gin.HandlerFunc func registerCrashAdminRoutes(routes *gin.RouterGroup, requirePerm permissionMiddleware, mohongHandler *mohong.Handler, paymentHandler *payment.Handler) { if mohongHandler == nil { return } register := func(prefix string) { routes.GET(prefix+"/categories", requirePerm("mohong:product_view"), mohongHandler.AdminListCategories) routes.POST(prefix+"/categories", requirePerm("mohong:category"), mohongHandler.AdminCreateCategory) routes.PUT(prefix+"/categories/:id", requirePerm("mohong:category"), mohongHandler.AdminUpdateCategory) routes.DELETE(prefix+"/categories/:id", requirePerm("mohong:category"), mohongHandler.AdminDeleteCategory) routes.GET(prefix+"/products", requirePerm("mohong:product_view"), mohongHandler.AdminListProducts) routes.GET(prefix+"/products/:id", requirePerm("mohong:product_view"), mohongHandler.AdminGetProduct) routes.POST(prefix+"/products", requirePerm("mohong:product_manage"), mohongHandler.AdminCreateProduct) routes.PUT(prefix+"/products/:id", requirePerm("mohong:product_manage"), mohongHandler.AdminUpdateProduct) routes.DELETE(prefix+"/products/:id", requirePerm("mohong:product_manage"), mohongHandler.AdminDeleteProduct) routes.GET(prefix+"/orders", requirePerm("mohong:order_view"), mohongHandler.AdminListOrders) routes.GET(prefix+"/orders/:id", requirePerm("mohong:order_view"), mohongHandler.AdminGetOrder) routes.POST(prefix+"/orders/:id/receive", requirePerm("mohong:order_manage"), mohongHandler.AdminReceiveOrder) routes.POST(prefix+"/orders/:id/complete", requirePerm("mohong:order_manage"), mohongHandler.AdminCompleteOrder) routes.POST(prefix+"/orders/:id/cancel", requirePerm("mohong:order_manage"), mohongHandler.AdminCancelOrder) routes.POST(prefix+"/orders/:id/refund", requirePerm("mohong:order_manage"), paymentHandler.AdminRefundMohong) routes.GET(prefix+"/config", requirePerm("mohong:config"), mohongHandler.AdminGetConfig) routes.PUT(prefix+"/config", requirePerm("mohong:config"), mohongHandler.AdminUpdateConfig) } register("/crash") register("/mohong") } type adminManagementHandlers struct { chat *chat.Handler supportGroup *supportgroup.Handler role *adminrole.Handler admin *adminmgr.Handler announcement *announcement.Handler } func registerAdminManagementRoutes(routes *gin.RouterGroup, requirePerm permissionMiddleware, handlers adminManagementHandlers) { routes.POST("/chats/qrcodes", requirePerm("qrcode:manage"), handlers.chat.CreateQrCodeHandler) routes.POST("/chats/qrcodes/batch", requirePerm("qrcode:manage"), handlers.chat.BatchCreateQrCodeHandler) routes.POST("/chats/qrcodes/batch-delete", requirePerm("qrcode:manage"), handlers.chat.BatchDeleteQrCodeHandler) routes.GET("/chats/qrcodes", requirePerm("qrcode:view"), handlers.chat.ListQrCodesHandler) routes.GET("/chats/qrcodes/stats", requirePerm("qrcode:view"), handlers.chat.GetQrCodeStatsHandler) routes.POST("/chats/qrcodes/ocr-group-name", requirePerm("qrcode:manage"), handlers.chat.RecognizeQrCodeGroupNameHandler) routes.POST("/chats/qrcodes/ocr-group-name/async", requirePerm("qrcode:manage"), handlers.chat.SubmitOCRJobHandler) routes.GET("/chats/qrcodes/ocr-group-name/async/:jobId", requirePerm("qrcode:manage"), handlers.chat.GetOCRJobResultHandler) routes.PATCH("/chats/qrcodes/:id", requirePerm("qrcode:manage"), handlers.chat.UpdateQrCodeHandler) routes.DELETE("/chats/qrcodes/:id", requirePerm("qrcode:manage"), handlers.chat.DeleteQrCodeHandler) routes.GET("/chat-support-groups", requirePerm("chat:manage"), handlers.supportGroup.List) routes.GET("/chat-support-groups/support-admins", requirePerm("chat:manage"), handlers.supportGroup.ListSupportAdmins) routes.GET("/chat-support-groups/:id", requirePerm("chat:manage"), handlers.supportGroup.FindByID) routes.POST("/chat-support-groups", requirePerm("chat:manage"), handlers.supportGroup.Create) routes.PUT("/chat-support-groups/:id", requirePerm("chat:manage"), handlers.supportGroup.Update) routes.DELETE("/chat-support-groups/:id", requirePerm("chat:manage"), handlers.supportGroup.Delete) routes.PUT("/chat-support-groups/:id/members", requirePerm("chat:manage"), handlers.supportGroup.AssignMembers) routes.GET("/roles", requirePerm("role:manage"), handlers.role.List) routes.GET("/roles/:id", requirePerm("role:manage"), handlers.role.FindByID) routes.POST("/roles", requirePerm("role:manage"), handlers.role.Create) routes.PUT("/roles/:id", requirePerm("role:manage"), handlers.role.Update) routes.DELETE("/roles/:id", requirePerm("role:manage"), handlers.role.Delete) routes.PUT("/roles/:id/permissions", requirePerm("role:manage"), handlers.role.AssignPermissions) routes.GET("/permissions", requirePerm("role:manage"), handlers.role.ListPermissions) routes.GET("/admin-users", requirePerm("admin_user:manage"), handlers.admin.List) routes.GET("/admin-users/:id", requirePerm("admin_user:manage"), handlers.admin.FindByID) routes.POST("/admin-users", requirePerm("admin_user:manage"), handlers.admin.Create) routes.PUT("/admin-users/:id", requirePerm("admin_user:manage"), handlers.admin.Update) routes.DELETE("/admin-users/:id", requirePerm("admin_user:manage"), handlers.admin.Delete) routes.PUT("/admin-users/:id/roles", requirePerm("admin_user:manage"), handlers.admin.AssignRoles) routes.PUT("/admin-users/me/password", handlers.admin.ChangeOwnPassword) routes.PUT("/admin-users/:id/password", requirePerm("admin_user:manage"), handlers.admin.ResetPassword) routes.GET("/announcements", requirePerm("announcement:view"), handlers.announcement.AdminList) routes.GET("/announcements/:id", requirePerm("announcement:view"), handlers.announcement.AdminGetByID) routes.POST("/announcements", requirePerm("announcement:manage"), handlers.announcement.Create) routes.PUT("/announcements/:id", requirePerm("announcement:manage"), handlers.announcement.Update) routes.POST("/announcements/:id/publish", requirePerm("announcement:manage"), handlers.announcement.Publish) routes.POST("/announcements/:id/archive", requirePerm("announcement:manage"), handlers.announcement.Archive) routes.POST("/announcements/:id/unarchive", requirePerm("announcement:manage"), handlers.announcement.Unarchive) routes.DELETE("/announcements/:id", requirePerm("announcement:manage"), handlers.announcement.Delete) }