初步完成举报功能
This commit is contained in:
@@ -21,6 +21,7 @@ type Handlers struct {
|
||||
Yggdrasil *YggdrasilHandler
|
||||
CustomSkin *CustomSkinHandler
|
||||
Admin *AdminHandler
|
||||
Report *ReportHandler
|
||||
}
|
||||
|
||||
// NewHandlers 创建所有Handler实例
|
||||
@@ -34,6 +35,7 @@ func NewHandlers(c *container.Container) *Handlers {
|
||||
Yggdrasil: NewYggdrasilHandler(c),
|
||||
CustomSkin: NewCustomSkinHandler(c),
|
||||
Admin: NewAdminHandler(c),
|
||||
Report: NewReportHandler(c),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,6 +79,9 @@ func RegisterRoutesWithDI(router *gin.Engine, c *container.Container) {
|
||||
|
||||
// 管理员路由(需要管理员权限)
|
||||
registerAdminRoutes(v1, c, h.Admin)
|
||||
|
||||
// 举报路由
|
||||
registerReportRoutes(v1, h.Report, c.JWT)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -236,3 +241,28 @@ func registerCustomSkinRoutes(v1 *gin.RouterGroup, h *CustomSkinHandler) {
|
||||
csl.GET("/textures/:hash", h.GetTexture)
|
||||
}
|
||||
}
|
||||
|
||||
// registerReportRoutes 注册举报路由
|
||||
func registerReportRoutes(v1 *gin.RouterGroup, h *ReportHandler, jwtService *auth.JWTService) {
|
||||
reportGroup := v1.Group("/report")
|
||||
{
|
||||
// 公开路由(无需认证)
|
||||
reportGroup.GET("/stats", h.GetStats)
|
||||
|
||||
// 需要认证的路由
|
||||
reportAuth := reportGroup.Group("")
|
||||
reportAuth.Use(middleware.AuthMiddleware(jwtService))
|
||||
{
|
||||
reportAuth.POST("", h.CreateReport)
|
||||
reportAuth.GET("/:id", h.GetByID)
|
||||
reportAuth.GET("/reporter_id", h.GetByReporterID)
|
||||
reportAuth.GET("/target", h.GetByTarget)
|
||||
reportAuth.GET("/status", h.GetByStatus)
|
||||
reportAuth.GET("/search", h.Search)
|
||||
reportAuth.PUT("/:id/review", h.Review)
|
||||
reportAuth.POST("/batch-review", h.BatchReview)
|
||||
reportAuth.DELETE("/:id", h.Delete)
|
||||
reportAuth.POST("/batch-delete", h.BatchDelete)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user