package common import ( "context" "time" context2 "git.ikuban.com/server/kratos-utils/http/context" ) func NewContext(parentCtx context.Context) context.Context { ctx := &AccountContext{ctx: parentCtx} return ctx } func NewContextWithAccountID(parentCtx context.Context, accountID int64) context.Context { ctx := &AccountContext{ctx: parentCtx} newCtx := context2.AppendToContext(ctx, "user_id", accountID) newCtx = context2.AppendToContext(ctx, "account_id", accountID) return newCtx } type AccountContext struct { ctx context.Context } func (this *AccountContext) Deadline() (deadline time.Time, ok bool) { return this.ctx.Deadline() } func (*AccountContext) Done() <-chan struct{} { return nil } func (this *AccountContext) Err() error { return this.ctx.Err() } func (this *AccountContext) Value(key interface{}) interface{} { return this.ctx.Value(key) }