first commit

This commit is contained in:
2026-04-23 13:53:09 +08:00
commit 9de47fa5b8
34 changed files with 2764 additions and 0 deletions

24
controller/base.go Normal file
View File

@@ -0,0 +1,24 @@
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)
}