kra-new/internal/biz/data_scope.go

21 lines
425 B
Go

package biz
import "context"
type DataScope struct {
All bool
OwnerUserID uint
DepartmentIDs []uint
}
type dataScopeKey struct{}
func NewDataScopeContext(ctx context.Context, scope DataScope) context.Context {
return context.WithValue(ctx, dataScopeKey{}, scope)
}
func DataScopeFromContext(ctx context.Context) (DataScope, bool) {
scope, ok := ctx.Value(dataScopeKey{}).(DataScope)
return scope, ok
}