This commit is contained in:
2026-07-18 10:52:32 +08:00
parent 2dcafae465
commit b5ef58f434
61 changed files with 1274 additions and 2142 deletions

View File

@@ -155,6 +155,19 @@ func GetCurrentUserID(c *gin.Context) uint64 {
return userID.(uint64)
}
// RequireFeature 功能授权检查中间件
// 检查当前授权是否包含指定功能
func RequireFeature(feature string) gin.HandlerFunc {
return func(c *gin.Context) {
if !utils.HasFeature(feature) {
utils.Forbidden(c, "当前授权不支持此功能: "+feature)
c.Abort()
return
}
c.Next()
}
}
// GetCurrentUsername 从上下文获取当前用户名
func GetCurrentUsername(c *gin.Context) string {
username, exists := c.Get("username")