完成剩余模块 Context 超时控制改造

This commit is contained in:
yml2213
2026-06-10 12:58:59 +08:00
parent d2858c529d
commit 6ae8f0e830
24 changed files with 370 additions and 323 deletions
+1 -3
View File
@@ -1,7 +1,6 @@
package middleware
import (
"context"
"encoding/json"
"errors"
"fmt"
@@ -53,9 +52,8 @@ func getPermCodes(c *gin.Context, rdb *redis.Client, adminID uint64) ([]string,
if rdb == nil {
return nil, errors.New("redis unavailable")
}
ctx := context.Background()
key := fmt.Sprintf("admin:perms:%d", adminID)
raw, err := rdb.Get(ctx, key).Result()
raw, err := rdb.Get(c.Request.Context(), key).Result()
if errors.Is(err, redis.Nil) {
return nil, nil // 缓存未命中,视为无权限
}