This commit is contained in:
2026-05-12 13:45:08 +08:00
parent e81df5ce5a
commit 37d3461983
38 changed files with 1721 additions and 1113 deletions

View File

@@ -1,24 +1 @@
package controller
import (
"context"
"gitea.com/red-future/common/beans"
)
// ensureUser 用于本地/无网关环境下的兜底用户信息,避免 gfdb Hook 因缺少用户上下文而报错。
// 生产环境建议由网关透传 X-User-Info 或鉴权中间件注入 ctx.Value("user")。
func ensureUser(ctx context.Context) context.Context {
if ctx == nil {
ctx = context.Background()
}
if ctx.Value("user") != nil {
return ctx
}
u := &beans.User{
UserName: "admin",
TenantId: 1,
}
return context.WithValue(ctx, "user", u)
}