优化结构

This commit is contained in:
Yvan
2026-08-28 09:52:27 +08:00
parent bfb6295153
commit a16d362bb5
4 changed files with 52 additions and 60 deletions
-19
View File
@@ -1,19 +0,0 @@
package system
import "context"
type actorContextKey struct{}
type Actor struct {
UserID uint
AuthorityID uint
}
func NewActorContext(ctx context.Context, actor Actor) context.Context {
return context.WithValue(ctx, actorContextKey{}, actor)
}
func ActorFromContext(ctx context.Context) (Actor, bool) {
actor, ok := ctx.Value(actorContextKey{}).(Actor)
return actor, ok
}
@@ -2,6 +2,22 @@ package system
import "context"
type actorContextKey struct{}
type Actor struct {
UserID uint
AuthorityID uint
}
func NewActorContext(ctx context.Context, actor Actor) context.Context {
return context.WithValue(ctx, actorContextKey{}, actor)
}
func ActorFromContext(ctx context.Context) (Actor, bool) {
actor, ok := ctx.Value(actorContextKey{}).(Actor)
return actor, ok
}
type DataScope struct {
All bool
Scope int