feat(handler): add AdminHandler with admin routes

This commit is contained in:
2026-07-04 17:18:23 +08:00
parent 118b7e4d2a
commit 170e54495d
2 changed files with 120 additions and 0 deletions
+9
View File
@@ -12,6 +12,7 @@ func setupProtectedRoutes(rg *gin.RouterGroup, webApp *app.WebApp) {
jwtSecret := []byte(webApp.Config.JWT.Secret)
accountHandler := handler.NewAccountHandler(webApp.AuthService)
fileHandler := handler.NewFileHandler(webApp.FileService)
adminHandler := handler.NewAdminHandler(webApp.UserRepo)
rg.Use(middleware.AuthRequired(jwtSecret))
@@ -36,4 +37,12 @@ func setupProtectedRoutes(rg *gin.RouterGroup, webApp *app.WebApp) {
files.PUT("/:id", fileHandler.Update)
files.DELETE("/:id", fileHandler.Delete)
}
admin := rg.Group("/admin")
admin.Use(middleware.AdminRequired(webApp.UserRepo))
{
admin.GET("/users", adminHandler.ListUsers)
admin.GET("/users/:id", adminHandler.GetUser)
admin.DELETE("/users/:id", adminHandler.DeleteUser)
}
}