21 lines
438 B
Go
21 lines
438 B
Go
package agent
|
|
|
|
import "context"
|
|
|
|
type contextKey string
|
|
|
|
const ctxKeyDramaID contextKey = "drama_id"
|
|
|
|
// WithDramaID 将短剧ID存入context
|
|
func WithDramaID(ctx context.Context, dramaID int64) context.Context {
|
|
return context.WithValue(ctx, ctxKeyDramaID, dramaID)
|
|
}
|
|
|
|
// GetDramaID 从context中获取短剧ID
|
|
func GetDramaID(ctx context.Context) int64 {
|
|
if id, ok := ctx.Value(ctxKeyDramaID).(int64); ok {
|
|
return id
|
|
}
|
|
return 0
|
|
}
|